Exemple #1
0
def test_clear():
    a = App()
    b = ButtonGroup(a, [["foo", "f"], ["bar", "b"]])

    b.clear()
    assert len(b.options) == 0
    assert b.value == ""

    a.destroy()
Exemple #2
0
def test_remove():
    a = App()
    b = ButtonGroup(a, [["foo", "f"], ["bar", "b"], ["car", "c"]])

    assert b.options == [["foo", "f"], ["bar", "b"], ["car", "c"]]
    b.remove("f")
    assert b.options == [["bar", "b"], ["car", "c"]]

    a.destroy()
Exemple #3
0
def create_list():
    global Display_list
    Display_list = ButtonGroup(app,
                               options=Todolist,
                               selected=Selectedlist,
                               grid=[0, 3, 2, 1],
                               align="left")
    Display_list.text_color = "light gray"
    Display_list.text_size = 20
    Display_list.font = "Century Gothic Bold"
Exemple #4
0
def test_grid_layout():
    a = App(layout="grid")

    w = ButtonGroup(a, grid=[1, 2])
    grid_layout_test(w, 1, 2, 1, 1, None)

    ws = ButtonGroup(a, grid=[1, 2, 3, 4])
    grid_layout_test(ws, 1, 2, 3, 4, None)

    wa = ButtonGroup(a, grid=[1, 2], align="top")
    grid_layout_test(wa, 1, 2, 1, 1, "top")

    a.destroy()
Exemple #5
0
def test_getters_setters():
    a = App()
    b = ButtonGroup(a, ["foo", ["bar", "b"]])
    assert b.value == "foo"
    assert b.value_text == "foo"

    b.value = "b"
    assert b.value == "b"
    assert b.value_text == "bar"

    b.value_text = "foo"
    assert b.value == "foo"
    assert b.value_text == "foo"

    a.destroy()
def test_update_command_with_args():
    a = App()
    
    callback_event = Event()
    def callback(value):
        assert value == "foo"
        callback_event.set()

    b = ButtonGroup(a, ["foo", "bar"])
    
    b.update_command(callback, ["foo"])
    b._rbuttons[1].tk.invoke()
    assert callback_event.is_set()

    a.destroy()
Exemple #7
0
def test_default_values():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    assert b.master == a
    assert b.value == "foo"
    assert b.value_text == "foo"
    assert b.grid == None
    assert b.align == None
    a.destroy()
Exemple #8
0
def test_alt_values():
    a = App(layout="grid")
    b = ButtonGroup(a, ["foo", "bar"], 2, grid=[0, 1], align="top")

    assert b.value == "2"
    assert b.value_text == "bar"
    assert b.grid[0] == 0
    assert b.grid[1] == 1
    assert b.align == "top"
    a.destroy()
def test_command_with_args():
    a = App()
    
    callback_event = Event()
    def callback(value):
        assert value == "foo"
        assert b.value == "bar"
        assert b.value_text == "bar"
        callback_event.set()

    b = ButtonGroup(a, ["foo", "bar"], command = callback, args = ["foo"])
    
    b._rbuttons[1].tk.invoke()
    assert callback_event.is_set()

    a.destroy()
Exemple #10
0
def test_alt_values():
    a = App(layout="grid")
    b = ButtonGroup(a, ["foo", "bar"],
                    "bar",
                    grid=[0, 1],
                    align="top",
                    width=11,
                    height=10)

    assert b.value == "bar"
    assert b.value_text == "bar"
    assert b.grid[0] == 0
    assert b.grid[1] == 1
    assert b.align == "top"
    assert b.width == 11
    assert b.height == 10
    a.destroy()
Exemple #11
0
def test_command():
    a = App()

    callback_event = Event()

    def callback():
        assert b.value == "2"
        assert b.value_text == "bar"
        callback_event.set()

    b = ButtonGroup(a, ["foo", "bar"], command=callback)

    assert not callback_event.is_set()
    b._options[1].tk.invoke()
    assert callback_event.is_set()

    a.destroy()
def test_append():
    a = App()
    b = ButtonGroup(a, [["foo", "f"], ["bar", "b"]])
    
    assert b.options == [["foo", "f"], ["bar", "b"]]

    b.append("car")
    assert b.options == [["foo", "f"], ["bar", "b"], ["car", "car"]]
    
    b.append(["lah", "l"])
    assert b.options == [["foo", "f"], ["bar", "b"], ["car", "car"], ["lah", "l"]]

    a.destroy()
def test_insert():
    a = App()
    b = ButtonGroup(a, [["foo", "f"], ["bar", "b"]])
    
    assert b.options == [["foo", "f"], ["bar", "b"]]
    
    b.insert(1, "car")
    assert b.options == [["foo", "f"], ["car", "car"], ["bar", "b"]]
    
    b.insert(2, ["lah", "l"])
    assert b.options == [["foo", "f"], ["car", "car"], ["lah", "l"], ["bar", "b"]]
    
    a.destroy()
Exemple #14
0
def create_app():
    app = App(title="Main window for admin")
    status_for_all = Text(app, text="")
    status_for_all.repeat(1000, update_info_for_all_farms, [status_for_all])

    operation_history_text = Text(app, text="\n\nTransaction history:")
    history = ListBox(app, scrollbar=True)

    for i, farm in enumerate(farms):
        window = Window(app, title=f"Window for {farm.account_name}")
        text = Text(window, text="")
        text.repeat(1000, update_info_for_farm, [text, farm])
        bg = ButtonGroup(window, options=animals)
        text = Text(window, text="Send to:")
        whom = TextBox(window, text='')
        text = Text(window, text="Amount:")
        how_many = TextBox(window)
        status = Text(window, text="Status:")
        button = PushButton(window,
                            transfer,
                            text="Transfer!",
                            args=[farm, whom, bg, how_many, status, history])

    app.display()
def test_update_command():
    a = App()
    
    callback_event = Event()
    def callback():
        callback_event.set()

    b = ButtonGroup(a, ["foo", "bar"])
    
    b._rbuttons[1].tk.invoke()
    assert not callback_event.is_set()
    
    b.update_command(callback)
    b._rbuttons[1].tk.invoke()
    assert callback_event.is_set()
    callback_event.clear()

    b.update_command(None)
    b._rbuttons[1].tk.invoke()
    assert not callback_event.is_set()
    
    a.destroy()
Exemple #16
0
def test_repeat_schedule():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    schedule_repeat_test(a, b)
    a.destroy()
Exemple #17
0
def test_2d_options_list():
    a = App()
    b = ButtonGroup(a, [["foo", "f"], ["bar", "b"]])
    assert b.value == "f"
    assert b.value_text == "foo"
    a.destroy()
Exemple #18
0
def test_inherited_properties():
    a = App()
    inherited_properties_test(a, lambda: ButtonGroup(a, ["foo", "bar"]), True)
    a.destroy()
Exemple #19
0
def test_cascaded_properties():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    cascaded_properties_test(a, b, True)
    a.destroy()
Exemple #20
0
def test_events():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    events_test(b)
    a.destroy()
Exemple #21
0
def test_size():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    size_text_test(b)
    a.destroy()
salaryScale = Slider(app,
                     start=10000,
                     end=100000,
                     grid=[2, 1, 2, 1],
                     command=do_salaryScale,
                     align="left")

fullTimeCheckBox = CheckBox(app,
                            text="Full-time?",
                            grid=[2, 2, 2, 1],
                            command=do_fullTimeCheckBox,
                            align="left")
jobButtonGroup = ButtonGroup(
    app,
    options=["Programmer", "Developer", "Web Developer", "Designer"],
    selected=0,
    grid=[2, 3, 2, 4],
    command=do_jobButtonGroup,
    align="left")

okPushButton = PushButton(app,
                          text="OK",
                          command=do_okPushButton,
                          grid=[2, 9],
                          padx=5,
                          pady=5)
closePushButton = PushButton(app,
                             text="Close",
                             command=do_closePushButton,
                             grid=[3, 9],
                             padx=5,
from guizero import App, TextBox, Text, Slider, PushButton, Picture, Combo, CheckBox, ButtonGroup, Box

app = App(title="different sizes", width=700, height=700)

text = Text(app, "lets change some sizes", width=20, height=2)

text_box = TextBox(app, "some text", width=50)

slider = Slider(app, width=300, height=30)

button = PushButton(app, width=20, height=2)

pic = Picture(app, image="guizero.gif", width=400, height=50)

combo = Combo(app, ["martin", "laura", "rik"], width="fill", height="fill")

check = CheckBox(app, "tick me", width=20, height=3)
check.bg = "blue"

button_group = ButtonGroup(app, ["cheese", "onion", "crisps"],
                           1,
                           width=20,
                           height=9)
button_group.bg = "darkgrey"

box = Box(app, width=100, height=100)
box.border = True

box.bg = "red"

app.display()
Exemple #24
0
def test_after_schedule():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    schedule_after_test(a, b)
    a.destroy()
Exemple #25
0
from guizero import App, Text, ButtonGroup, Combo, PushButton, TextBox, Box
app = App(title="Hero-o-matic", width=300, bg="red")

message1 = Text(app, text="Choose an adjective")
bgp_adjective = ButtonGroup(
    app,
    options=["Amazing", "Bonny", "Charming", "Delightful"],
    selected="Amazing")

message2 = Text(app, text="Choose a colour")
txt_colour = TextBox(app)
message2.text_color = "blue"

message3 = Text(app, text="Pick an animal")
cmb_animal = Combo(
    app,
    options=["Aardvark", "Badger", "Cat", "Dolphin", "Velociraptor"],
    selected="Aardvark",
    width=20)

# create a box
box = Box(app)

# modify each widget so it is now housed in the box
btn_make_name = PushButton(box, text='Make me a hero')
lbl_output = Text(box, text="Your hero name will appear here")

# now change the properties of the box
box.bg = "white"
box.text_size = 12
Exemple #26
0
def test_enable():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    enable_test(b)
    a.destroy()
def setup_gui():
    """ Create the GUI for controlling the STS-Pi Rover.
    """

    global app, statusWaffle, roverChoice, connectButton, exitButton
    global forwardButton, stopButton, backwardButton, spdSlider, durationSlider
    global spinRightButton, spinLeftButton, photoButton, videoButton
    global buttonWaffle

    # Declare the GUI application
    app = App("STS Controller", layout="grid")

    # Bluetooth connection status waffle. Single cell, blue=connected, red=not.
    statusWaffle = Waffle(app, 1, 4, 10, 10, grid=[0, 0])
    if connected:
        statusWaffle.set_pixel(0, 0, "blue")
        statusWaffle.set_pixel(1, 0, "white")
        statusWaffle.set_pixel(2, 0, "white")
        statusWaffle.set_pixel(3, 0, "white")

    # Choice of STS-PI Rover
    roverChoice = ButtonGroup(app,
                              options=["STS-Pi 2", "STS-Pi 3"],
                              selected="STS-Pi 2",
                              grid=[1, 0])

    # Reconnect button for when the Bluetooth connection has been lost or reset
    connectButton = PushButton(app, connect, text="Connect", grid=[2, 0])

    #Create forwards and backwards buttons
    forwardButton = PushButton(app, forwards, text="Forwards", grid=[1, 1])

    #Create spin left and right buttons
    spinLeftButton = PushButton(app,
                                spinAntiClockwise,
                                text="Spin Left",
                                grid=[0, 2])

    #Button to stop the STS-PI in an emergency
    stopButton = PushButton(app, stop, text="STOP", grid=[1, 2])

    spinRightButton = PushButton(app,
                                 spinClockwise,
                                 text="Spin Right",
                                 grid=[2, 2])

    backwardButton = PushButton(app, backwards, text="Backwards", grid=[1, 3])

    #Create a slider to set the speed.
    speedTitle = Text(app, "Speed %", grid=[0, 4])
    spdSlider = Slider(app, command=changeSpeed, grid=[1, 4, 3, 1])
    spdSlider.value = 15

    #Create a slider to set the duration of the next movement
    durationTitle = Text(
        app,
        "Duration (secs)",
        grid=[0, 5],
    )
    durationSlider = Slider(app,
                            command=changeDuration,
                            start=1,
                            end=10,
                            grid=[1, 5, 3, 1])
    durationSlider.value = 1

    #Buttons to take videos and photos.
    photoButton = PushButton(app, takePhoto, text="Photo", grid=[0, 6])
    videoButton = PushButton(app, takeVideo, text="Video", grid=[2, 6])

    #Waffle to display button presses
    buttonWaffle = Waffle(app, 1, 8, grid=[0, 7, 3, 2])

    # Ids for the buttons on the STS-PI rover
    buttonIds = Text(app,
                     "1    2    3    4    5    6    7    8 ",
                     grid=[0, 9, 3, 1])

    # This spacer text increases the gap below the controls and the exit button.
    spacer = Text(app, "", grid=[0, 10])

    # Button to quit the application
    exitButton = PushButton(app, closeDown, text="Exit", grid=[1, 11])
Exemple #28
0
def test_display():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    display_test(b)
    a.destroy()
Exemple #29
0
    print(vip_seat.value)
    print(row_choice.value)


app = App(title="My second GUI app", width=300, height=200, layout="grid")

film_choice = Combo(app,
                    options=["Star Wars", "Frozen", "Lion King"],
                    grid=[1, 0],
                    align="left")
film_description = Text(app, text="Which film?", grid=[0, 0], align="left")

vip_seat = CheckBox(app, text="VIP seat?", grid=[1, 1], align="left")
seat_type = Text(app, text="Seat Type", grid=[0, 1], align="left")

row_choice = ButtonGroup(app,
                         options=[["Front", "F"], ["Middle", "M"],
                                  ["Back", "B"]],
                         selected="M",
                         horizontal=True,
                         grid=[1, 2],
                         align="left")
seat_location = Text(app, text="Seat location", grid=[0, 2], align="left")

book_seats = PushButton(app,
                        command=do_booking,
                        text="Book seat",
                        grid=[1, 3],
                        align="left")

app.display()
Exemple #30
0
def test_color():
    a = App()
    b = ButtonGroup(a, ["foo", "bar"])
    color_test(b)
    a.destroy()