[Tkinter-discuss] get root.winfo_pointerxy()
守株待兔
1248283536 at qq.com
Thu Sep 1 16:21:54 CEST 2011
[code]
from Tkinter import *
root = Tk()
root.title('Simple Plot - Version 1')
canvas = Canvas(root, width=450, height=300, bg = 'white')
canvas.pack()
Button(root, text='Quit', command=root.quit).pack()
canvas.create_line(100,250,400,250, width=2)
canvas.create_line(100,250,100,50, width=2)
for i in range(11):
x = 100 + (i * 30)
canvas.create_line(x,250,x,245, width=2)
#canvas.create_text(x,320, text='%d'% (10*i), anchor=N)
for i in range(6):
y = 250 - (i * 40)
canvas.create_line(100,y,105,y, width=2)
canvas.create_text(96,y, text='%5.1f'% (50.*i), anchor=E)
for x,y in [(12, 56), (20, 94), (33, 98), (45, 120), (61, 180),
(75, 160), (98, 223)]:
x = 100 + 3*x
y = 250 - (4*y)/5
canvas.create_oval(x-6,y-6,x+6,y+6, width=1,
outline='black', fill='SkyBlue2')
def myprint():
print root.winfo_pointerxy()
canvas.bind("<Button-1>",myprint)
root.mainloop()
[/code]
when i click my left mouse,there is a output:
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
TypeError: myprint() takes no arguments (1 given)
what's wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20110901/650c9149/attachment.html>
More information about the Tkinter-discuss
mailing list