0

How to set specific color such as #B0BF1A instead of black,white,grey

window.configure(background='white')
browse_label = gui.Label(window, text="Image path :", bg="white").place(x=20, y=20)
gongsun
  • 534
  • 7
  • 18

3 Answers3

2

From the official tkinter documentation:

Colors can be given as the names of X colors in the rgb.txt file, or as strings representing RGB values in 4 bit: "#RGB", 8 bit: "#RRGGBB", 12 bit” "#RRRGGGBBB", or 16 bit "#RRRRGGGGBBBB" ranges, where R,G,B here represent any legal hex digit. See page 160 of Ousterhout’s book for details.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
2

You can replace it from your example. such as if you want to use #B0BF1A

window.configure(background='#B0BF1A')
browse_label = gui.Label(window, text="Image path :", bg="#B0BF1A").place(x=20, y=20)
tiermix
  • 42
  • 6
1

I'm not sure whether this is compatible in python 2.7, but try this: Default window colour Tkinter and hex colour codes

The code of the accepted answer is as follows (NOT MINE):

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()
Community
  • 1
  • 1
boboquack
  • 249
  • 5
  • 15