Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- color = 'red'
- clicks = 0
- root = Tk()
- root.geometry('500x500')
- root.configure(bg='red')
- root.title(f'Clicks: {clicks}')
- def click():
- global color
- global clicks
- clicks += 1
- root.title(f'Clicks: {clicks}')
- if color == 'red':
- button['text'] = 'Change color to red'
- color = 'blue'
- root.configure(bg=color)
- elif color == 'blue':
- button['text'] = 'Change color to blue'
- color = 'red'
- root.configure(bg=color)
- button = Button(root, text='Change color to blue', command=click)
- button.pack()
- root.mainloop()
Add Comment
Please, Sign In to add comment