示例#1
0
def test_getters_setters():
    a = App()
    b = PushButton(a, text="foo")
    assert b.text == "foo"
    b.text = "bar"
    assert b.text == "bar"
    a.destroy()
示例#2
0
def draw_init(day_window, on_off_hour_list):
    i = 1
    count2 = 0
    hours = range(0, 24)
    for count in hours:
        if count < 10:
            button_text = "0" + str(count)
            button_text2 = "0" + str(count + 1)
        else:
            button_text = str(count)
            button_text2 = str(count + 1)
        text = Text(day_window,
                    text=button_text + ":00",
                    size=5,
                    grid=[count2, i],
                    align="right")

        button = PushButton(day_window,
                            text="OFF",
                            grid=[count2 + 1, i],
                            align="left")
        button.when_clicked = partial(set_hour_on_off, count, button)

        if on_off_hour_list[count] == "OFF":
            button.bg = "blue"
            button.text = "OFF"
        else:
            button.bg = "red"
            button.text = "ON"
        button.text_size = 5
        text = Text(day_window,
                    text=button_text2 + ":00",
                    size=5,
                    grid=[count2 + 2, i],
                    align="left")
        count2 = count2 + 3

        if count2 % 9 == 0:
            if i != 0:
                i = i + 1
                count2 = 0

def button1_action():
    random_number_1.value = random.randint(1, 101)


def button2_action():
    random_number_2.value = random.randint(1, 101)


def button3_action():
    random_number_3.value = random.randint(1, 101)


app = App()
text = Text(app)

button1 = PushButton(app, command=button1_action)
button1.text = "Push Me to Make a Random Number"
random_number_1 = Text(app, "random number")

button2 = PushButton(app, command=button2_action)
button2.text = "Push Me to Make a Random Number"
random_number_2 = Text(app, "random number")

button3 = PushButton(app, command=button3_action)
button3.text = "Push Me to Make a Random Number"
random_number_3 = Text(app, "random number")

app.display()
示例#4
0
#!/usr/bin/python3


from guizero import App, Text, PushButton
from subprocess import call

def say_hello():
    call('espeak hello world&', shell=True)

def say_goodbye():
    call('espeak hello world&', shell=True)

app = App()
text = Text(app)
button1 = PushButton(app, command=say_hello)
button1.text = "Say Hello"
button2 = PushButton(app, command=say_goodbye)
button2.text = "Say Goodbye"
app.display()
#!/usr/bin/python3

from guizero import App, Text, PushButton
from subprocess import call


def push_me():
    call('xdg-open https://www.youtube.com/watch?v=oHg5SJYRHA0', shell=True)


app = App()
text = Text(app)
button1 = PushButton(app, command=push_me)
button1.text = "Push Me : D"
app.display()