Python 2.7 Python中Tk的特定背景色
如何设置特定颜色,例如#B0BF1A,而不是黑色、白色、灰色Python 2.7 Python中Tk的特定背景色,python-2.7,user-interface,tkinter,Python 2.7,User Interface,Tkinter,如何设置特定颜色,例如#B0BF1A,而不是黑色、白色、灰色 window.configure(background='white') browse_label = gui.Label(window, text="Image path :", bg="white").place(x=20, y=20) 我不确定这在python 2.7中是否兼容,但请尝试以下方法: 接受答案的代码如下(不是我的): 我不确定这在python 2.7中是否兼容,但请尝试以下方法: 接受答案的代码如下(不是我的
window.configure(background='white')
browse_label = gui.Label(window, text="Image path :", bg="white").place(x=20, y=20)
我不确定这在python 2.7中是否兼容,但请尝试以下方法: 接受答案的代码如下(不是我的):
我不确定这在python 2.7中是否兼容,但请尝试以下方法: 接受答案的代码如下(不是我的): 从: 颜色可以在rgb.txt文件中以X颜色的名称给出,或者 作为表示RGB值的字符串,4位为“#RGB”,8位为“#RRGGBB”, 12位“#RRRGGGBBB”或16位“#RRRGGGBBB”范围,其中R、G、B 这里表示任何合法的十六进制数字。参见Ousterhout的书第160页 详情请参阅 从: 颜色可以在rgb.txt文件中以X颜色的名称给出,或者 作为表示RGB值的字符串,4位为“#RGB”,8位为“#RRGGBB”, 12位“#RRRGGGBBB”或16位“#RRRGGGBBB”范围,其中R、G、B 这里表示任何合法的十六进制数字。参见Ousterhout的书第160页 详情请参阅
您可以从示例中替换它。例如,如果您想使用#B0BF1A
您可以从示例中替换它。例如,如果您想使用#B0BF1A
import Tkinter
mycolor = '#%02x%02x%02x' % (64, 204, 208) # set your favourite rgb color
mycolor2 = '#40E0D0' # or use hex if you prefer
root = Tkinter.Tk()
root.configure(bg=mycolor)
Tkinter.Button(root, text="Press me!", bg=mycolor, fg='black',
activebackground='black', activeforeground=mycolor2).pack()
root.mainloop()
window.configure(background='#B0BF1A')
browse_label = gui.Label(window, text="Image path :", bg="#B0BF1A").place(x=20, y=20)