我正在尝试在运行绑定事件的同时更新画布背景。
(来自代码)会在do_popup
弹出菜单中实现并conti
不断改变画布背景颜色。我如何在画布不断更新时使用弹出选项。
示例代码:
from Tkinter import *
root = Tk()
def do_popup(event,w2):
print w2 # inplace of print some popupmenu will be implemented
def conti():
idt=1
while idt==1:
w.config(bg="red") # in place of red it will be a random color
w.update_idletasks()
w= Canvas(root, width=600, height=600)
w.grid(row=0, column=0)
line1 = w.create_line(200,200,300,300, width=10, tags="line1", fill="black")
w.tag_bind(line1, "<Button-3>", lambda e, w2="test1" :do_popup(e,w2))
f = Frame(root)
f.grid(row=0, column=1, sticky=N)
f1=Button(f, text='visual', command=lambda :conti())
f1.grid(row=0, column=1,columnspan=1, sticky=W+N+S+E)
mainloop()
多处理会起作用吗?我正在使用带有 python 2.7.3 的 windows 7 32 位
提前致谢