from Tkinter import *
def on_click():
label['text'] = text.get()
root = Tk(className='bitunion')
label = Label(root)
label['text'] = 'be on your own'
label.pack()
text = StringVar()
text.set('hello')
entry = Entry()
entry['textvariable'] = text
entry.pack()
button = Button(root)
button['text'] = 'hello my button'
button['command'] = on_click
button.pack()
root.mainloop()
参考:http://kb.cnblogs.com/page/75245/
def on_click():
label['text'] = text.get()
root = Tk(className='bitunion')
label = Label(root)
label['text'] = 'be on your own'
label.pack()
text = StringVar()
text.set('hello')
entry = Entry()
entry['textvariable'] = text
entry.pack()
button = Button(root)
button['text'] = 'hello my button'
button['command'] = on_click
button.pack()
root.mainloop()
参考:http://kb.cnblogs.com/page/75245/
来源:oschina
链接:https://my.oschina.net/u/174445/blog/33593