开发者

TkInter: how can I pass a numeric value to specify the color?

开发者 https://www.devze.com 2023-01-20 03:26 出处:网络
how can I assign a numeric value instead of a string to specify the color of my button ? What the exact syntax ?

how can I assign a numeric value instead of a string to specify the color of my button ? What the exact syntax ?

 button = tk.Button(itemFrame, text="", b开发者_JAVA技巧g="red", width=10, command=callback)

i.e bg = #FF0000

thanks


There are two general ways to specify colors in Tkinter.

  1. You can use a string specifying the proportion of red, green, and blue in hexadecimal digits.
  2. You can also use any locally defined standard color name

#rgb Four bits per color

#rrggbb Eight bits per color

#rrrgggbbb Twelve bits per color

The format should be string

bg='#FF0000'

and not bg=#FF0000
0

精彩评论

暂无评论...
验证码 换一张
取 消