473,387 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

example code sought

There's something quite simple I'd like to do, but I'm hampered by
lack of knowledge regarding Tkinter. If someone could help me out with
a snippet of maximally-simple code showing, in general terms, how to
do this, that would be really great. What I want to do is simply to
move a shape around on the screen using the mouse. I've looked at
Tkdnd.py but I can't seem to extract what I need from the more
involved stuff in there.

Peace,
STM
Jul 18 '05 #1
1 1304

"Sean McIlroy" <se**********@yahoo.com> wrote in message
news:e5**************************@posting.google.c om...
There's something quite simple I'd like to do, but I'm hampered by
lack of knowledge regarding Tkinter. If someone could help me out with
a snippet of maximally-simple code showing, in general terms, how to
do this, that would be really great. What I want to do is simply to
move a shape around on the screen using the mouse. I've looked at
Tkdnd.py but I can't seem to extract what I need from the more
involved stuff in there.

Peace,
STM


Use Canvas.move(). Here is some code from a program of mine that may give
you an idea of how to go about this. In my case each component consisted of
several pieces, each having a unique tag. If they had had the same tag only
one move command would have been needed. self.xLast and self.yLast need to
be initialized to the current cursor position before the move starts.

def onMouseMotion(self, event):
x, y = event.x, event.y
dx = x - self.xLast
dy = y - self.yLast
for c in self.selectedComponents:
for k in range(c.count):
self.canvas.move(c.tags[k], dx, dy) # Move each piece of the
component
self.xLast, self.yLast = x, y
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
16
by: Jason | last post by:
Hi, I need a way to use random numbers in c++. In my c++ project, when using the mingw compiler I used a mersenne twister that is publicly available and this did its job well. Now I have...
3
by: Crypto Loko | last post by:
Hello everyone, I was wondering if anyone should have any TC++ v3.0 / BC++ v3.1, or DJGPP v2.03 code for RSA implementation (or similar public-key scheme(s)) - of either a module, a library,...
29
by: John Rivers | last post by:
Hello, What good reason there is for not allowing methods in ASPX pages I can't imagine, but here is how to get around that limitation: (START) <body MS_POSITIONING="FlowLayout"> <form...
41
by: Jordan | last post by:
While writing some code, I realized I had never developed a consistent pattern for checking errors from a method. I have two styles I jump back and forth between, but I'm wondering which is...
0
by: januwan | last post by:
Hi, We want to set some benchmark value for .NET programming as part of our process imporvement initiative. Please guide if there are any industry standards or some source from where the figures can...
5
by: januwan | last post by:
Hi, We want to set some benchmark value for C/C++ programming as part of our process imporvement initiative. Please guide if there are any industry standards or some source from where the figures...
67
by: gator | last post by:
I am quite new to XML and posted a request for example code yesterday. Unfortunately, I did not do a very good job in explaining what I was looking for. Here is an example of a small piece of the...
2
by: Wikicodia Admin | last post by:
Dears, Wikicodia is a wiki based project for sharing code snippets. We're collecting large number of code snippets for all code-based programming languages, scripts, shells and consoles. We wish...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.