dino3vr

Untitled

Dec 5th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. from tkinter import *
  2.  
  3. color = 'red'
  4. clicks = 0
  5.  
  6. root = Tk()
  7. root.geometry('500x500')
  8. root.configure(bg='red')
  9. root.title(f'Clicks: {clicks}')
  10.  
  11.  
  12. def click():
  13.     global color
  14.     global clicks
  15.  
  16.     clicks += 1
  17.     root.title(f'Clicks: {clicks}')
  18.  
  19.     if color == 'red':
  20.         button['text'] = 'Change color to red'
  21.         color = 'blue'
  22.         root.configure(bg=color)
  23.  
  24.     elif color == 'blue':
  25.         button['text'] = 'Change color to blue'
  26.         color = 'red'
  27.         root.configure(bg=color)
  28.  
  29.  
  30. button = Button(root, text='Change color to blue', command=click)
  31. button.pack()
  32.  
  33. root.mainloop()
Add Comment
Please, Sign In to add comment