from Tkinter import *
def printSomething():
# if you want the button to disappear:
# button.destroy() or button.pack_forget()
label = Label(root, text= "Hey whatsup bro, i am doing something very interresting.")
#this creates a new label to the GUI
label.pack()
root = Tk()
button = Button(root, text="Print Me", command=printSomething)
button.pack()
root.mainloop()
您的评论示例
from Tkinter import *
def printSomething():
# if you want the button to disappear:
# button.destroy() or button.pack_forget()
for x in range(9): # 0 is unnecessary
label = Label(root, text= str(x))
# this creates x as a new label to the GUI
label.pack()
root = Tk()
button = Button(root, text="Print Me", command=printSomething)
button.pack()
root.mainloop()
使用“仅打印”将打印到终端或fp。您可以创建一个新标签以“打印”到GUI。
您的评论示例
我想你没什么好放的了。在tkinter中,您需要一个标签来输出文本,或者您创建一个新的def并在那里定义按钮必须执行的操作(如果有人单击它)。
相关问题 更多 >
编程相关推荐