Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. from tkinter import *
  2.  
  3.  
  4. def bg1():
  5.     root.configure(background="blue".format(clicks))
  6.  
  7. def bg2():
  8.     root.configure(background="red".format(clicks))
  9.  
  10. def Clicker():
  11.     global clicks
  12.     global flag
  13.     clicks += 1
  14.     root.title("Clicks {}".format(clicks))
  15.     if flag: bg1(); flag = False
  16.     else: bg2(); flag = True
  17.  
  18.  
  19. clicks = 0
  20. flag = False
  21. root = Tk()
  22. root.geometry("400x200")
  23. root.configure()
  24. but = Button(bg="grey", width=30, command=Clicker)
  25. but.pack()
  26. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement