2016-08-01 60 views
-1

我想設置一個框架的背景顏色一個十六進制值,我已經存儲在一個變量。我做了錯誤的事情,它給了我這個錯誤「未知顏色名稱'hex_value'」。我究竟做錯了什麼?TKinter - 如何在十六進制中使用變量來着色小部件?

hex_value = "#f35123" 
root = Tk() 
top_frame = Frame(root, bg="hex_value") 
top_frame.pack(side=TOP, fill=X) 
root.mainloop() 

回答

2

,因爲你在「hex_value」通過你得到這個錯誤。而不是包含你想要的字符串的變量。刪除"

+1

哦,上帝,我在想什麼? –

0

我會假設你想要的變量內容

hex_value = "#f35123" 
root = Tk() 
top_frame = Frame(root, bg=hex_value) 
top_frame.pack(side=TOP, fill=X) 
root.mainloop() 
相關問題