Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Countdown Timer - not guiZero
- from time import sleep
- def decrease():
- global currentTime
- sleep(1)
- currentTime -= 1
- def displayTime(currentTime):
- mins = currentTime // 60
- secs = currentTime % 60
- if secs < 10:
- secs = '0'+str(secs)
- print(f"{mins}:{secs}")
- print('Starting')
- currentTime = 120
- while currentTime >= 0:
- displayTime(currentTime)
- decrease()
- print('Game Over')
- #................................................
- # Change Button bg colour using .repeat
- from guizero import App, PushButton
- app = App(title="Timers",width="600",height="100",bg="white")
- # Event Handlers
- def changeBg():
- if btn_open.bg == 'white':
- btn_open.bg = 'black'
- btn_open.text_color = 'white'
- else:
- btn_open.bg = 'white'
- btn_open.text_color = 'black'
- # Widgets
- btn_open = PushButton(app,align="top", text="Click Me", width="fill")
- btn_open.bg = 'white'
- btn_open.text_color = 'black'
- btn_open.repeat(1000,changeBg)
- # Show the GUI on the screen
- app.display()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement