def test_border():
    a = App()
    b = Box(a)
    assert not b.border
    assert b.border == 0

    b.border = True
    assert b.border
    assert b.border == 1
    assert b._get_tk_config("highlightbackground") == "black"

    b.border = False
    assert not b.border

    b.border = 10
    assert b.border
    assert b.border == 10

    b.set_border(11, "red")
    assert b.border
    assert b.border == 11
    assert b._get_tk_config("highlightbackground") == "red"
    a.destroy()
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()
from guizero import App, Box, ListBox, CheckBox, Combo, PushButton

app = App()

list_boxes = Box(app, width="fill")
ListBox(list_boxes, items=["Times New Roman", "Courier", "Verdana"], align="left", width="fill")
ListBox(list_boxes, items=["Regular", "Italic", "Bold", "Bold Italic"], align="left", width="fill")
ListBox(list_boxes, items=["8", "10", "12", "14", "16", "18"], align="left", width="fill")

combos = Box(app, width="fill")
combos.border = True
Combo(combos, options=["red", "green", "blue", "yellow"], align="left")
Combo(combos, options=["underline", "double underline"], align="right")

checks = Box(app, width="fill")
checks.border = True
CheckBox(checks, text="strike-through", align="left")
CheckBox(checks, text="double strike-through", align="left")
CheckBox(checks, text="sub-script", align="left")

buttons = Box(app, width="fill", align="bottom")
PushButton(buttons, text="Default", align="left")
PushButton(buttons, text="Ok", align="right")
PushButton(buttons, text="Cancel", align="right")

app.display()
def destroy3():
    t3.destroy()


def hide(widget):
    widget.hide()


def show(widget):
    widget.show()


a = App()
b = Box(a, layout="grid")
b.border = True

t1 = Text(a, text="1")
t2 = Text(a, text="2")
t3 = Text(a, text="3")

ta = Text(b, text="aa", grid=[0, 0], align="left")
tb = Text(b, text="bbb", grid=[1, 0])
tc = Text(b, text="cccc", grid=[2, 0])
tc = Text(b, text="ddddd", grid=[0, 1])

pbb = Box(a, layout="grid")

b1h = PushButton(pbb, text="hide 1", grid=[0, 1], command=hide, args=[t1])
b1s = PushButton(pbb, text="show 1", grid=[1, 1], command=show, args=[t1])
b2h = PushButton(pbb, text="hide 2", grid=[2, 1], command=hide, args=[t2])
Ejemplo n.º 5
0
from guizero import App, Text, TextBox, Combo, PushButton, Box

app = App()

Text(app, text="My form")

form = Box(app, width="fill", layout="grid")
form.border = True

Text(form, text="Title", grid=[0, 0], align="right")
TextBox(form, grid=[1, 0])

Text(form, text="Name", grid=[0, 1], align="right")
TextBox(form, grid=[1, 1])

Text(form, text="Age", grid=[0, 2], align="right")
TextBox(form, grid=[1, 2])

buttons = Box(app, width="fill", align="bottom")

PushButton(buttons, text="Ok", align="left")
PushButton(buttons, text="Cancel", align="left")

app.display()
Ejemplo n.º 6
0
def start():
    print('start')
    global timelimit

    sleep(0.5)
    button.hide()

    box = Box(app, width=800, height=80, grid=[0, 1], layout="grid")
    box.border = 1

    bapp = Box(app, width=790, height=100, layout="grid", grid=[0, 2])
    bapp.border = 1

    questionone = Text(app, text="What day is it today?", grid=[0, 0])
    questionone.text_size = 40

    monday = PushButton(bapp,
                        grid=[0, 2],
                        command=checkday,
                        height=2,
                        width=9,
                        text="Monday")
    monday.text_size = 21
    monday.bg = 'red'
    monday.update_command(checkday, args='0')

    tuesday = PushButton(bapp,
                         grid=[1, 2],
                         command=checkday,
                         height=2,
                         width=9,
                         text="Tuesday")
    tuesday.text_size = 21
    tuesday.bg = 'orange'
    tuesday.update_command(checkday, args='1')

    wednesday = PushButton(bapp,
                           grid=[2, 2],
                           command=checkday,
                           height=2,
                           width=9,
                           text="Wednesday")
    wednesday.text_size = 21
    wednesday.bg = 'yellow'
    wednesday.update_command(checkday, args='2')

    thursday = PushButton(bapp,
                          grid=[3, 2],
                          command=checkday,
                          height=2,
                          width=9,
                          text="Thursday")
    thursday.text_size = 21
    thursday.bg = 'green'
    thursday.update_command(checkday, args='3')

    friday = PushButton(bapp,
                        grid=[0, 3],
                        command=checkday,
                        height=2,
                        width=9,
                        text="Friday")
    friday.text_size = 21
    friday.bg = 'brown'
    friday.update_command(checkday, args='4')

    saturday = PushButton(bapp,
                          grid=[1, 3],
                          command=checkday,
                          height=2,
                          width=9,
                          text="Saturday")
    saturday.text_size = 21
    saturday.bg = 'grey'
    saturday.update_command(checkday, args='5')

    sunday = PushButton(bapp,
                        grid=[2, 3],
                        command=checkday,
                        height=2,
                        width=9,
                        text="Sunday")
    sunday.text_size = 21
    sunday.bg = 'purple'
    sunday.update_command(checkday, args='6')

    dunno = PushButton(bapp,
                       grid=[3, 3],
                       command=checkday,
                       height=2,
                       width=9,
                       text='Dunno?')
    dunno.text_size = 21
    dunno.bg = 'blue'
    dunno.update_command(checkday, args='7')
    app.update()
    timelimit = time()
Ejemplo n.º 7
0
from guizero import App, Box, Text, PushButton

a = App()

top_box = Box(a, width=500, height=100, align="top")
top_box.border = True

Text(top_box, text="left", align="left")
Text(top_box, text="right", align="right")
Text(top_box, text="top", align="top")
Text(top_box, text="bottom", align="bottom")

a_box = Box(a, width=500, height=100)
a_box.border = True

PushButton(a_box, text="side", align="left")
PushButton(a_box, text="by", align="left")
PushButton(a_box, text="side", align="left")

a_box_in_a_box = Box(a_box, align="right")
a_box_in_a_box.border = True
Text(a_box, text="a box on the right", align="right")
PushButton(a_box_in_a_box, text="on top", align="top")
PushButton(a_box_in_a_box, text="of each other", align="top")

full_button = PushButton(a, text="full button", width="fill", height="fill")

bottom_box = Box(a, width=500, height=100, align="bottom", layout="grid")
bottom_box.border = True

for x in range(16):
Ejemplo n.º 8
0
def questiontwo():
    global timelimit
    qt = Window(app,
                layout="grid",
                title="Question Two",
                width=800,
                height=400)
    qt.show()
    print("start question 2")

    f1 = Box(qt, width=100, height=400, grid=[0, 1])
    f1.border = 1
    f1.bg = "black"

    f2 = Box(qt, width=100, height=400, grid=[1, 1])
    f2.border = 1
    f2.bg = "black"

    f3 = Box(qt, width=100, height=400, grid=[3, 1])
    f3.border = 1
    f3.bg = "black"

    f4 = Box(qt, width=100, height=400, grid=[4, 1])
    f4.border = 1
    f4.bg = "black"

    f5 = Box(qt, width=100, height=400, grid=[5, 1])
    f5.border = 1
    f5.bg = "black"

    f6 = Box(qt, width=100, height=400, grid=[6, 1])
    f6.border = 1
    f6.bg = "black"

    f7 = Box(qt, width=100, height=400, grid=[7, 1])
    f7.border = 1
    f7.bg = "black"

    f8 = Box(qt, width=100, height=400, grid=[8, 1])
    f8.border = 1
    f8.bg = "black"

    bl = [f1, f3, f5, f7]
    x = 0
    for i in range(1, randint(1, 4)):
        bl[i - 1].bg = "yellow"
        x = i
    print(x)

    qt.update()
    sleep(7.35478205493597)

    f1.visible = False
    f2.visible = False
    f3.visible = False
    f4.visible = False
    f5.visible = False
    f6.visible = False
    f7.visible = False
    f8.visible = False

    bo2 = Box(qt, width=800, height=80, grid=[0, 1], layout="grid")
    bo2.border = 1

    b2pp = Box(qt, width=790, height=100, layout="grid", grid=[0, 2])
    b2pp.border = 1

    questiotwo = Text(qt,
                      text="How many yellow lines were there?",
                      grid=[0, 0])
    questiotwo.text_size = 38

    answer1 = PushButton(b2pp,
                         grid=[0, 2],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="One")
    answer1.text_size = 21
    answer1.bg = 'red'
    answer1.update_command(checknumber, args=['1', x])

    answer2 = PushButton(b2pp,
                         grid=[1, 2],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Two")
    answer2.text_size = 21
    answer2.bg = 'orange'
    answer2.update_command(checknumber, args=['2', x])

    answer3 = PushButton(b2pp,
                         grid=[2, 2],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Three")
    answer3.text_size = 21
    answer3.bg = 'yellow'
    answer3.update_command(checknumber, args=['3', x])

    answer4 = PushButton(b2pp,
                         grid=[3, 2],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Four")
    answer4.text_size = 21
    answer4.bg = 'green'
    answer4.update_command(checknumber, args=['4', x])

    answer5 = PushButton(b2pp,
                         grid=[0, 3],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Five")
    answer5.text_size = 21
    answer5.bg = 'brown'
    answer5.update_command(checknumber, args=['5', x])

    answer6 = PushButton(b2pp,
                         grid=[1, 3],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Six")
    answer6.text_size = 21
    answer6.bg = 'grey'
    answer6.update_command(checknumber, args=['6', x])

    answer7 = PushButton(b2pp,
                         grid=[2, 3],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Zero")
    answer7.text_size = 21
    answer7.bg = 'purple'
    answer7.update_command(checknumber, args=['0', x])

    answer8 = PushButton(b2pp,
                         grid=[3, 3],
                         command=checknumber,
                         height=2,
                         width=9,
                         text="Dunno")
    answer8.text_size = 21
    answer8.bg = 'blue'
    answer8.update_command(checknumber, args=['7', x])

    timelimit = time()
from guizero import App, PushButton, Text, Box

app = App()

top_box = Box(app, align="top", width="fill")
PushButton(top_box, text="to the left", align="left")
PushButton(top_box, text="to the left", align="left")

Text(app, text="everything you own", align="top")

left_box = Box(app, align="left")
left_box.border = True
Text(left_box, text="in a box to the left")

app.display()
Ejemplo n.º 10
0
# texts for menu. TBD: change names to meaningful

text_exit = "   EXIT    "
text_left = "Go Left"
text_right = "Go Right"
text_speed = "Speed: " + str(
    my_train.speed)  # YIGAL - First declaration, never used.

app = App(title="Train Control menu", bg="gray", width=500, height=700)

# TBD does not work. How to send messages to the GUI?
# text_msg.after(1000)
# I am using a button as a display, because I do not know how to write to test box

space_box0 = Box(app, width=500, height=50)
space_box0.border = False
# text_msg = Text(space_box0, text=my_train.msg_to_display)

button_message = PushButton(space_box0,
                            command=do_nothing,
                            text="",
                            width=50,
                            height=5,
                            align="left")
button_message.text_color = "blue"
button_message.text_size = 25

power_box = Box(app, width=500, height=100)
power_box.border = False
text_start = "Start Motor"
button_start = PushButton(power_box,
Ejemplo n.º 11
0
    grid=[0, 0],
    align="left",
)
openPearlerFile.bg = theme[4]
""" start Print button """
StartButton = PushButton(
    app,
    command=lambda: menuFunctions.start_print(file_name, app),
    text="Start Print",
    grid=[0, 1],
    align="left")
StartButton.bg = theme[4]
""" Manual Control """
# controller box title
controller_box = Box(app, layout="grid", grid=[1, 2])
controller_box.border = 2
controller_box.text_color = "white"
text_box = Box(controller_box, grid=[1, 2, 6, 1])
Text(
    text_box,
    text="Manual Control",
    color="white",
)
""" Aggregator """
slid_a = 0
a1 = Text(
    controller_box,
    text="Aggregator",
    grid=[1, 3],
)
sliderA = Slider(controller_box,
Ejemplo n.º 12
0
def LiveCollection(cycles):
    printedData = []
    liveTime = []
    liveTemp = []
    liveHumid = []
    livePress = []

    liveWindow = Window(app, title="Data Collection Window", layout="grid")
    liveWindow.width = 620
    liveWindow.height = 920

    try:
        localCycles = int(cycles)
    except:
        print("invalid variable")
        liveWindow.error("Error", "Invalid Variable")
    else:
        x = 0
        localCycles = int(cycles)
        liveDataList = ListBox(liveWindow)
        imageContainer = Box(liveWindow,
                             layout="grid",
                             grid=[1, 0],
                             align="top",
                             border=True)
        imageContainer.border = 10
        liveTempImage = Picture(imageContainer)
        liveHumidImage = Picture(imageContainer)
        livePressImage = Picture(imageContainer)

        while x < (localCycles):
            currentTemperature = (round(sense.get_temperature(), 2))
            currentHumidity = round(sense.get_humidity(), 2)
            currentPressure = round(sense.get_pressure(), 2)
            currentTime = time.strftime("%H%M%S", time.localtime())
            currentDate = time.strftime("%Y%m%d", gmtime())
            ID = str(currentTime) + str(currentDate)

            liveTime.append(currentTime)
            liveTemp.append(currentTemperature)
            liveHumid.append(currentHumidity)
            livePress.append(currentPressure)

            printedData.append(("ID:", ID))
            printedData.append(("Temp:", currentTemperature))
            printedData.append(("Humidity:", currentHumidity))
            printedData.append(("Pressure:", currentPressure))
            printedData.append(("Time:", currentTime))
            printedData.append(("Date:", currentDate))
            printedData.append(
                ("Entry: {0} Out of: {1}".format(x + 1, localCycles)))
            printedData.append("")

            connection.execute(
                "INSERT INTO WeatherData (ID, Temp, Humid, Press, Time, Date) Values ({0}, {1}, {2}, {3}, {4}, {5});"
                .format(ID, currentTemperature, currentHumidity,
                        currentPressure, currentTime, currentDate))
            connection.commit()

            plt.clf()
            plt.plot(liveTime, liveTemp)
            plt.ylabel("Temperature")
            plt.xlabel("Time")
            plt.savefig("liveTemp.png")
            plt.clf()
            plt.plot(liveTime, liveHumid)
            plt.ylabel("Pressure")
            plt.xlabel("Time")
            plt.savefig("liveHumid.png")
            plt.clf()
            plt.plot(liveTime, livePress)
            plt.ylabel("Humidity")
            plt.xlabel("Time")
            plt.savefig("livePress.png")
            plt.clf()

            liveDataList.destroy()
            liveDataList = ListBox(liveWindow,
                                   items=printedData,
                                   grid=[0, 0],
                                   scrollbar=True)
            liveDataList.width = 200
            liveDataList.height = 920
            liveTempImage.destroy()
            liveTempImage = Picture(imageContainer,
                                    image="liveTemp.png",
                                    grid=[0, 0])
            liveTempImage.width = 400
            liveTempImage.height = 300
            liveHumidImage.destroy()
            liveHumidImage = Picture(imageContainer,
                                     image="liveHumid.png",
                                     grid=[0, 1])
            liveHumidImage.width = 400
            liveHumidImage.height = 300
            livePressImage.destroy()
            livePressImage = Picture(imageContainer,
                                     image="livePress.png",
                                     grid=[0, 2])
            livePressImage.width = 400
            livePressImage.height = 300

            liveWindow.update()
            time.sleep(10)
            x += 1
            liveWindow.focus()