コード例 #1
0
    elif (board_squares[0][1].text == board_squares[1][1].text ==
          board_squares[2][1].text) and board_squares[2][1].text in ["X", "O"]:
        winner = board_squares[0][1]
    elif (board_squares[0][2].text == board_squares[1][2].text ==
          board_squares[2][2].text) and board_squares[2][2].text in ["X", "O"]:
        winner = board_squares[0][2]

    # Diagonals
    elif (board_squares[0][0].text == board_squares[1][1].text ==
          board_squares[2][2].text) and board_squares[2][2].text in ["X", "O"]:
        winner = board_squares[0][0]
    elif (board_squares[2][0].text == board_squares[1][1].text ==
          board_squares[0][2].text) and board_squares[0][2].text in ["X", "O"]:
        winner = board_squares[0][2]

    if winner is not None:
        message.value = winner.text + " wins!"


# Variables -------------
turn = "X"

# App -------------------
app = App("Tic tac toe")

board = Box(app, layout="grid")
board_squares = clear_board()
message = Text(app, text="It is your turn, " + turn)

app.display()
コード例 #2
0
    # 		data_boxes[2][j].bg = colorOrange
    # 	else:
    # 		data_boxes[2][j].bg = colorDefault

    tkr.value = 'System: ' + str(datetime.datetime.now())


app = App(title="Aquarium GUI", width=800, height=400, layout="grid")

# Build the data display grid
data_boxes = []
for r_idx, row in enumerate(data_types):
    cols = []
    for c_idx, col in enumerate(row):
        bx = Box(app, grid=[c_idx, r_idx])
        txt_label = Text(bx, text=col)
        txt_label.size = label_size
        pb = PushButton(bx, text='')
        pb.text_size = data_size
        pb.height = 2
        pb.width = 8
        pb.bg = (225, 225, 225)
        # if col == 'Laser On':
        # 	pb.update_command(toggle_laser)
        # if col == 'Recording':
        # 	pb.update_command(toggle_recording)
        cols.append(pb)
    data_boxes.append(cols)

logo = Picture(app,
               image="/home/pi/aquariumController/logoSmall.gif",
コード例 #3
0
ファイル: PerfectCrops.py プロジェクト: fmtvup/hackathon
                sleep(1)

                if t > tmax:
                    sense.set_pixels(hot)
                    sleep(2)

                if t < tmin:
                    sense.set_pixels(cold)
                    sleep(2)

                if h < hmin:
                    sense.set_pixels(dry)
                    sleep(2)

                if h > hmax:
                    sense.set_pixels(wet)
                    sleep(2)
        ''' ------------------------------------------------------------------------------------------------------------------------------------------- '''


app = App(title="Perfect CROPS")
update_text = PushButton(app, command=start, text="START")
perfect_crops = Picture(app, image="PC.gif")
welcome_message = Text(app,
                       text="Press START",
                       size=40,
                       font="Times New Roman",
                       color="green")
app.display()
コード例 #4
0
thread = threading.Thread(target=client.loop_forever)
thread.setDaemon(True)
thread.start()

# Set up camera (with resolution of the touchscreen)
camera = PiCamera()
camera.rotation = 180
camera.resolution = (800, 480)
camera.hflip = True

# Start camera preview
camera.start_preview(alpha=128)

# Set up filename
output = ""

latest_photo = './latest.gif'

app = App("The All Seeing Pi", 800, 480)
#app.attributes("-fullscreen", True)
message = Text(app, "I spotted you!")
your_pic = Picture(app, latest_photo)
new_pic = PushButton(app, new_picture, text="New picture")
tweet_pic = PushButton(app, send_tweet, text="Tweet picture")
take_pic = PushButton(app, take_picture, text="Take picture")
next_over = PushButton(app, next_overlay, text="Next overlay")
#lights_on = PushButton(app, switch_lights(light_on), text="Lights on/off")

app.display()
print(dir(camera))
コード例 #5
0
"""
question pop-up demo
"""

from guizero import App, PushButton, Text


def ask():
    quest = app.question("Hello", "What's your name?")
    if quest is not None:
        hello.value = "Sorry I don't care Mr." + quest
        hello.size = 40
        hello.text_size = 30


app = App(title='Answer My Question', bg='green', width=1000, height=600)
btn = button = PushButton(app, command=ask, text="Hello")
btn.text_color = "yellow"
btn.text_size = 15
btn.height = 10
btn.width = 10
hello = Text(app, color='yellow')
app.display()
コード例 #6
0
ファイル: survey.py プロジェクト: Nanich87/gnss-app
    button_measure.enabled = False

app = App(title="Land Survey", width=350, height=400)
#app.tk.attributes("-fullscreen", True)

menubar = MenuBar(app,
                  toplevel=["File", "Help"],
                  options=[
                      [ ["New", createProject], ["Open", openProject], ["Exit", closeApp] ],
                      [ ["About", about] ]
                  ])

# Set up instrument height
instrument_setup_box = Box(app, width="fill", align="top")

text_instrument_height = Text(instrument_setup_box, text="Instrument Height:", align="left")
input_instrument_height = TextBox(instrument_setup_box, text="{:.3f}".format(instrument_height), align="left")
text_height_unit = Text(instrument_setup_box, text="m", align="left")
button = PushButton(instrument_setup_box, text="Set", padx=20, command=setInstrumentHeight, align="right")

# Measure
buttons_box = Box(app, width="fill", align="bottom")

button_connect = PushButton(buttons_box, text="Connect", command=connectDevice, align="left")
button_measure = PushButton(buttons_box, text="Measure", command=savePoint, align="right")

# Location
location_box = Box(app, width="fill", align="top")
location_inner_box = Box(location_box, layout="grid", align="left")

## 3D Position
コード例 #7
0
from guizero import App, Text, PushButton
from gpiozero import TrafficLights

lights = TrafficLights(22, 27, 17)

app = App()

PushButton(app, command=lights.red.on, text="on")

app.display()

app = App("Traffic Lights controller", layout="grid")

Text(app, "Red", grid=[0, 0])
PushButton(app, command=lights.red.on, text="on", grid=[1, 0])
PushButton(app, command=lights.red.off, text="off", grid=[2, 0])

# Try adding all three Lights
コード例 #8
0
def test_text():
    a = App()
    t = Text(a)
    text_test(t)
    a.destroy()
コード例 #9
0
def test_color():
    a = App()
    t = Text(a)
    color_test(t)
    a.destroy()
コード例 #10
0
def test_enable():
    a = App()
    t = Text(a)
    enable_test(t)
    a.destroy()
コード例 #11
0
def test_display():
    a = App()
    t = Text(a)
    display_test(t)
    a.destroy()
コード例 #12
0
ファイル: chat.py プロジェクト: yasusii/networkzero
import os, sys

import networkzero as nw0
from guizero import App, Box, Text, TextBox

app = App(width=400)
box = Box(app)
chatter = Text(box, align="top")
speaking = TextBox(box, align="bottom", width=400)

chatter.append("Hello\n")
chatter.append("World\n")
chatter.color("blue")
chatter.append("!")

app.display()
コード例 #13
0
ファイル: changing_sizes.py プロジェクト: sobreira/guizero
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=50, height=2)

check = CheckBox(app, "tick me", width=17, height=2)

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

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

box.bg = "red"

app.display()
コード例 #14
0
ファイル: tabataGUI.py プロジェクト: Xynth22/guided_tabata
numCats = len(catStarts)
numExerInCatComplete = [0] * numCats
plotStats()

repetitions = 3
numExercises = 10

minExerPerCat = int(numExercises / numCats)

frequency = 2500  # Set Frequency To 2500 Hertz
duration = 50  # Set Duration To 1000 ms == 1 second

app = App(title="Tapata", width=2000, height=400)

text = Text(app, text="", size=200, align="bottom")
counter = Text(app, text="0 , 0", size=24, align="top")


def close_app():
    app.destroy()


closeButton = PushButton(app,
                         text="End Workout",
                         align="right",
                         command=close_app)


def tabataTimer(exer, reps, work):
    t = 0
コード例 #15
0
def test_repeat_schedule():
    a = App()
    t = Text(a)
    schedule_repeat_test(a, t)
    a.destroy()
コード例 #16
0
def test_size():
    a = App()
    t = Text(a)
    size_text_test(t)
    size_fill_test(t)
    a.destroy()
コード例 #17
0
def test_destroy():
    a = App()
    t = Text(a)
    destroy_test(t)
    a.destroy()
コード例 #18
0
def test_events():
    a = App()
    t = Text(a)
    events_test(t)
    a.destroy()
コード例 #19
0
'''Demonstrates how guizero works.'''
#import the wedgets we need from quizero

from guizero import App, Text

#create the main window
App = App(layout="grid",
          title="Omris guizero window",
          bg=(200, 200, 200),
          width=(700))
#creating a text label
# the first paramiter is the location of the widget
Header = Text(App,
              grid=[0, 5],
              text="Sub g, heres my program!",
              font="calibri",
              size=40)
Header.text_color = (50, 0, 200)
#starts the program by displaying the module
App.display()
コード例 #20
0
def test_cascaded_properties():
    a = App()
    t = Text(a)
    cascaded_properties_test(a, t, True)
    a.destroy()
コード例 #21
0

#function gives feedback after booking your seat
def do_booking():
    info(
        "Booking", "Thank you for booking \n" + "Movie: " + film_choice.value +
        "\nSeat type: " + seat_type.value + "\nSeat location: " +
        row_choice.value)


#adds a text widget
app = App(title="My Second GUI app", width=300, height=200, layout="grid")

#adds a text widget
film_description = Text(app,
                        text="Select movie to watch",
                        grid=[0, 0],
                        align="left")
#adds a combo widget
film_choice = Combo(app,
                    options=["Star Wars", "Frozen", "Lion King"],
                    grid=[1, 0],
                    align="left")
#adds a text widget
seat_type_label = Text(app, text="Seat type", grid=[0, 1], align="left")
#adds radio button widget
seat_type = ButtonGroup(app,
                        options=[["VIP seat", "vip"],
                                 ["Regular seat", "regular"]],
                        selected="regular",
                        horizontal="True",
                        grid=[1, 1],
コード例 #22
0
def test_inherited_properties():
    a = App()
    inherited_properties_test(a, lambda: Text(a), True)
    a.destroy()
コード例 #23
0
            #delete from both the student_list and the student_list lists
            del (student_names[i])
            del (student_list[i])


# create the application interface
from guizero import App, Text, ListBox, PushButton, TextBox, Box, Combo, yesno, error

app = App(title="Student management system", layout="grid")

# Set up the Box areas for our layout
add_box = Box(app, grid=[0, 0], layout="grid")
search_box = Box(app, grid=[1, 0])
delete_box = Box(app, grid=[2, 0])
# This section has the GUI widgets in the add_box area
heading = Text(add_box, text="Add new student", grid=[0, 0])
name_lbl = Text(add_box, text="Name", grid=[0, 1])
name_text = TextBox(add_box, grid=[1, 1])
age_lbl = Text(add_box, text="Age", grid=[0, 2])
age_text = TextBox(add_box, grid=[1, 2])
phone_lbl = Text(add_box, text="Phone", grid=[0, 3])
phone_text = TextBox(add_box, grid=[1, 3])
gender_lbl = Text(add_box, text="Gender", grid=[0, 4])
gender_combo = Combo(add_box, options=["Male", "Female", "Other"], grid=[1, 4])
class_lbl = Text(add_box, text="Classes", grid=[0, 5], align="top")
class_listbox = ListBox(
    add_box, ["GRA", "BIO", "PHY", "MAT", "DTC", "ART", "ENG", "XYZ"],
    grid=[1, 5],
    multiselect=True)
add_button = PushButton(add_box,
                        text="Add student",
コード例 #24
0
def test_clear():
    a = App()
    t = Text(a, text="foo")
    t.clear()
    assert t.value == ""
    a.destroy()
コード例 #25
0
ファイル: titlebox.py プロジェクト: maroph/guizero
from guizero import App, Text, TitleBox
app = App()

titlebox = TitleBox(app, "Title of the box")

# change properties
# titlebox.text_size = 15
# titlebox.font = "courier new"
# titlebox.text_color = "red"

message = Text(titlebox, "Text inside a TitleBox")

app.display()
コード例 #26
0
def test_append():
    a = App()
    t = Text(a, text="foo")
    t.append("bar")
    assert t.value == "foobar"
    a.destroy()
コード例 #27
0
ファイル: clockGUI.py プロジェクト: OfficialPouya/SmartClock
clock, o_seconds, ampm, day, month, year, day_num, day_string = time_parse(
    time_page)
# print(clock,o_seconds,ampm,day,month,year,day_num,postfix)
weather_print(temp_F, description)

local_seconds = time.time()
local_time = time.ctime(local_seconds)
local_time_parsed = local_time.split(' ')
local_clock = local_time_parsed[3].split(':')
local_seconds = local_clock[2]
local_seconds = int(local_seconds)

print(day, "the", day_string, "of", month)

time_page = time_zone_time(time_zone)
clock, o_seconds, ampm, day, month, year, day_num, postfix = time_parse(
    time_page)

app = App(title="Smart Clock",
          bg="black",
          layout="auto",
          width=750,
          height=750)
time_text = Text(app,
                 text=time_print(day, day_num, postfix, month, clock, ampm),
                 size=40,
                 font="Times New Roman",
                 color="#FA8072")
time_text.repeat(10000, time_print(day, day_num, postfix, month, clock, ampm))
app.display()
コード例 #28
0
def test_after_schedule():
    a = App()
    t = Text(a)
    schedule_after_test(a, t)
    a.destroy()
コード例 #29
0
ファイル: guiTest.py プロジェクト: dglasson18/iotTest
def displayTank(deviceData, data):
    #tank depth is stored in val1, i.e. deviceData[2]
    percentage = (int(data) / int(deviceData[2])) * 100
    tankMinusPercentage = 100 - percentage
    d.rectangle(300, 200, 200, percentage * 2, color="green", outline=True)
    d.rectangle(300, percentage * 2, 200, 0, color="white", outline=True)
    d.text(100,
           110,
           "Tank " + deviceData[0] + " " + str(tankMinusPercentage) + "%",
           color="black",
           size="15",
           max_width=100)


def displayIrri(deviceData, data):
    #bay in which the sensor is found stored in val1
    if data == "0000":
        writing.value = "bay " + str(deviceData[2]) + " has not detected water"
    elif data == "1111":
        writing.value = "bay " + str(deviceData[2]) + " has detected water"
    else:
        writing.value = "Unsure how to display data: " + data


app = App(title="Hello world")
uInput = TextBox(app)
updateText = PushButton(app, command=updateValues, text="update")
writing = Text(app, text="", color="black", size="20")
d = Drawing(app, width=1000, height=1000)
app.display()
コード例 #30
0
    robot.stop()


robot = CamJamKitRobot()


def Stop():
    robot.stop()


app = App()

slider = Slider(app, command=slider_changed)
textbox = TextBox(app)

instructions = Text(app, text="Choose a forward speed")
combo = Combo(app,
              options=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1],
              command=you_chose_forward)
combo.width = 60
combo.height = 5
result = Text(app)

instructions = Text(app, text="Choose a backward speed")
combo = Combo(app,
              options=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1],
              command=you_chose_backward)
combo.width = 60
combo.height = 5
result = Text(app)