簡體   English   中英

使用python tkinter更改按鈕邊框的顏色

[英]Changing the colour of button border with python tkinter

我正在嘗試更改此按鈕上邊框的顏色,但是它什么也沒做或給我一個灰色邊框。

self._lqbutton = tk.Button(self._longquestionframe, 
                           text="TEST",
                           bg="blue", fg="#fff",
                           highlightbackground="red",
                           highlightcolor="red",
                           highlightthickness=4,
                           relief=tk.SOLID,
                           borderwidth="4")
self._lqbutton.pack()

我也嘗試過使用relief = tk.FLAT

您無法更改小部件的邊框顏色。 highlightcolorhighlightbackground屬性更改了高亮環的顏色, 高亮環是僅當小部件具有焦點時才出現的邊框狀裝飾。

通過將效果放置在自己的框架中並更改框架屬性來實現效果。

self._lqbuttonborder = tk.Frame(self._longquestionframe,
                                    highlightbackground="#bce8f1",
                                    highlightcolor="#bce8f1",
                                    highlightthickness=1,
                                    bd=0)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM