code;
# Tkinter 基础添加一个按钮,在按钮上显示文字,并设置文字颜色 import tkinter as tk # 面向对象编程 class App(): def __init__(self, master): frame = tk.Frame(master) # 框架??不是很理解 frame.pack() # 创建一个按钮,fg前景色:蓝色 self.testButton = tk.Button(frame, text = "hello", fg = "blue") self.testButton.pack() root = tk.Tk() app = App(root) root.mainloop()
结果:
原文地址:https://www.cnblogs.com/wilson-wu/p/8343266.html
时间: 2024-10-02 03:14:10