473,288 Members | 1,729 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,288 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 1301

"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: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.