daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Jan 11th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from tkinter import *
  2. import time
  3.  
  4. root = Tk()
  5.  
  6. message = StringVar()
  7. label = Label(root, textvariable=message, fg='black', anchor=CENTER)
  8. counter = 0
  9.  
  10.  
  11. def gas():
  12.     root.configure(background='DarkOrchid3')
  13.     message.set("gas")
  14.     label.config(bg='DarkOrchid3')
  15.  
  16.  
  17. def doorbell():
  18.     root.configure(background='chartreuse3')
  19.     message.set("doorbell")
  20.     label.config(bg='chartreuse3')
  21.  
  22.  
  23. def fridge():
  24.     root.configure(background='RoyalBlue2')
  25.     message.set("fridge")
  26.     label.config(bg='RoyalBlue2')
  27.  
  28.  
  29. def timer():
  30.     root.configure(background='orange')
  31.     message.set("timer")
  32.     label.config(bg='orange')
  33.  
  34.  
  35. def base():
  36.     root.configure(background='snow')
  37.     message.set("hoi")
  38.     label.config(bg='snow')
  39.  
  40.  
  41. def switchScreens():
  42.     root.after(1000, base())
  43.     root.after(1000, gas())
  44.     root.after(1000, doorbell())
  45.     root.after(1000, fridge())
  46.     root.after(1000, timer())
  47.  
  48. def switch():
  49.     global counter
  50.  
  51.     if counter == 0:
  52.         base()
  53.     elif counter == 1:
  54.         gas()
  55.     elif counter == 2:
  56.         fridge()
  57.     elif counter == 3:
  58.         timer()
  59.     elif counter == 4:
  60.         doorbell()
  61.  
  62.     if counter == 4:
  63.         counter = 0
  64.     else:
  65.         counter += 1
  66.  
  67.  
  68. switchButton=Button(root, text='Change Color', command=switch)
  69. exitButton=Button(root, text='Exit Program', command=root.destroy)
  70.  
  71. exitButton.pack()
  72. switchButton.pack()
  73. label.pack(fill=BOTH, expand=1)
  74.  
  75. switchScreens()
  76.  
  77. root.attributes('-fullscreen', True)
  78. root = mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top