Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- class Btn:
- def __init__(self, master, color, col_name):
- self.but = Button(master, bg = color, width = 25, text = col_name)
- self.but.pack()
- self.but['command'] = self.pressed
- self.color = color
- self.col_name = col_name
- def pressed(self):
- lbl['text'] = self.col_name
- ent.delete(0, END)
- ent.insert(0, self.color)
- root = Tk()
- lbl = Label()
- lbl.pack()
- ent = Entry()
- ent.pack()
- Btn(root, '#ff0000', 'Красный')
- Btn(root, '#ffd700', 'Orange')
- Btn(root, '#ffff00', 'Yellow')
- Btn(root, '#00ff00', 'Green')
- Btn(root, '#007f00', 'Light Blue')
- Btn(root, '#0000ff', 'Blue')
- Btn(root, '#7f00ff', 'Violet')
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement