代码部分:
from Tkinter import *
import tkMessageBox
def getcode(mes):
tkMessageBox.showinfo("get code", 'this code:'+mes)
def win2(self):
root2=Toplevel()
aa = Entry(root2,width=5)
aa.pack()
bb=Button(root2,text='get')
bb.pack()
mes=aa.get()
bb.bind("<Button-1>",getcode(mes))
root2.mainloop()
root = Tk()
root.wm_title("TEST")
zh = Button(root,text="Test")
zh.bind("<Button-1>",win2)
zh.pack()
root.mainloop()
刚开始学习GUI编程,但是想获得tkinter子窗口的数据时候发生了奇怪的错误。
当点击Button:Test的时候,root2窗口弹出的同时触发了getcode函数,但是在root2窗口中点击Button:get无效。
求解!