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