这是👉python Tkinter基础 Button command在窗体中添加一个按钮,单击按钮 在IDLE中打印一行字👈的摘要
code
# Tkinter基础 Button command在窗体中添加一个按钮,单击按钮 在IDLE中打印一行字
import tkinter as tk
class App():
def __init__(self, master):
frame = tk.Frame(master)
frame.pack()
self.testButton = tk.Button(frame, text = "hello", fg = "blue", command = self.testPrint)
self.testButton.pack()
def testPrint(self):
print("测试消息!!!!")
root = tk.Tk()
app = App(root)
root.mainloop()
结果: