Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_random_color.py
- import Tkinter
- from random import randint
- def random_color():
- rgb = tuple([randint(0,255) for _ in 'rgb'])
- print rgb
- rgb = '#%02x%02x%02x'%rgb
- print rgb
- print
- root.configure(bg=rgb)
- #
- root = Tkinter.Tk()
- root.wm_geometry('200x200')
- Tkinter.Button(root, text="Press Me!", bg='white', fg='red', command=random_color).pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement