python Tkinter基础 Button bg 设置按钮的背景颜色


code:

# Tkinter基础 Button bg 设置按钮的背景颜色
import tkinter as tk

class App():
    def __init__(self, master):
        frame = tk.Frame(master)
        frame.pack()
        self.testButton = tk.Button(frame, text = "hello", fg = "red", bg = "blue", command = self.testPrint)
        self.testButton.pack()

    def testPrint(self):
        print("test")



root = tk.Tk()
app = App(root)
root.mainloop()

结果:

注:

fg:前景色

参数:颜色

bg:背景色

参数:颜色

tkinter 颜色

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM