大神bind传递参数的问题,不能绑定的方式传递数值吗?
import tkinter as tkglobal m
def handleKeypress(event):
if event.char=='w':
m=1
if event.char=='s':
m=-1
def main():
win=tk.Tk()
win.title('KEY')
win.geometry('400x300')
win.bind_all('<Key>', handleKeypress)
while(1):
print(m)
main()
求大神帮忙啊,我想用绑定方式来通过函数触发更改m的值,有什么好办法?这段程序的m值总是没有变化。bind的函数,更改不了m的值。系统总是提示未定义的m name. import Tkinter as tk
def handleKeypress(event):
if event.char=='w':
m=1
if event.char=='s':
m=-1
print m
def main():
win=tk.Tk()
win.title('KEY')
win.geometry('400x300')
win.bind_all('<Key>', handleKeypress)
win.mainloop()
main()是要这个? 在handlkeypress里肯定能现实正确的m值。
可是想在main()里,使用 handlekeypress的值。有什么好办法吗?
页:
[1]