File: after_repeat.py

package info (click to toggle)
python-guizero 1.1.1%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,676 kB
  • sloc: python: 6,286; makefile: 28; sh: 17
file content (31 lines) | stat: -rw-r--r-- 629 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from guizero import App, PushButton, TextBox

def welcome():
    print("Welcome")

def hi():
    print("Hi")

def message(my_message):
    print(my_message)

def whatever():
    # say whatever using the message function, passing the text as an argument
    app.after(200, message, args=["Whatever"])

def cancel_hi():
    app.cancel(hi)

app = App()

# create some buttons
hi_button = PushButton(app, cancel_hi, text="Stop hi")
what_button = PushButton(app, whatever, text="Whatever")

# after a very short pause, say welcome
app.after(10, welcome)

# keep repeating hi, until it is cancelled
app.repeat(1000, hi)

app.display()