Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import choice ## random is a module and choice is a function
- from tkinter import*
- hex_chars = ['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'] ## create the list of characters from which to choose
- colour_code = '#' ## this is the start of any colour code in python
- for i in range (0,6):
- colour_code = colour_code + choice(hex_chars)
- print ('The hexadecimal colour code generated is:' ,colour_code)
- my_window =Tk() ##function in tkinder that opens a window
- my_canvas = Canvas (my_window,width=200,height=200,background= colour_code) ## the window's size and color is defined here
- my_canvas.grid(row=0,column=0)
- my_window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement