from Tkinter import *
class ButtonHandler:
def __init__(self):
self.root = Tk()
self.root.geometry('600x500+200+200')
self.label = Label(self.root, text=str(self.mousedown))
self.can = Canvas(self.root, width='500', height='400', bg='white')
self.can.bind("<Motion>",lambda x:self.handler(x,'motion'))
self.can.bind("<Button-1>",lambda x:self.handler(x,'press'))
self.can.bind("<ButtonRelease-1>",lambda x:self.handler(x,'release'))
self.label.pack()
self.can.pack()
self.root.mainloop()
def mouseDown(self, event ):
return 1
def handler(self,event,x):
if x == 'press':
self.mousedown = 1
elif x == 'release':
self.mousedown = 0
elif x == 'motion':
if self.mousedown:
r = 5
self.can.create_oval(event.x-r, event.y-r, event.x+r, event.y+r, fill="orange")
self.label.config(text=str(self.mousedown))
x = ButtonHandler()
#x.__init__()
bettersaid 0 Light Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
TrustyTony 888 ex-Moderator Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.