Пример #1
0
from guizero import App, Text


def spi_init(bus, device, mode, speed_hz):
    spi = spidev.SpiDev()
    spi.open(bus, device)
    spi.mode = mode
    spi.max_speed_hz = speed_hz
    #spi.no_cs = False
    #spi.cshigh = False
    return spi


app = App(title="Yo",
          width=200,
          height=160,
          layout="grid",
          visible=False,
          bg="black")
test_text = Text(app, text="Strobe", grid=[0, 0], align="left")
#app.set_full_screen('')
app.full_screen = True
app.show()
app.update()

spi = spi_init(0, 0, 2, 125000)
strobe_cam = PiStrobeCam(spi)
#strobe_cam.camera.resolution = ( 640, 400 )
#strobe_cam.camera.resolution = ( 320, 200 )
#strobe_cam.camera.sensor_mode = 4
print('Resolution: {}'.format(strobe_cam.camera.resolution))
strobe_cam.set_timing(10000, 10000000, 24000000)
Пример #2
0
        f.write(editor.value)
        save_button.disable()


def enable_save():
    save_button.enable()


# A new function that closes the app
def exit_app():
    app.destroy()


# This is where any additional functions needed to run your script go

app = App(title="textzero")

# The new MenuBar
menubar = MenuBar(app,
                  toplevel=["File", "Find"],
                  options=[[["open", open_file], ["save", save_file],
                            ["exit", exit_app]], [["Find", open_file]]])

file_controls = Box(app, align="top", width="fill", border=True)
file_name = TextBox(file_controls,
                    text="text_file.txt",
                    width=50,
                    align="left")

save_button = PushButton(file_controls,
                         text="Save",
Пример #3
0
# Imports ---------------

from guizero import App, Text

# Functions -------------


def flash_text():
    if title.visible:
        title.hide()
    else:
        title.show()


# App -------------------

app = App("its all gone wrong", bg="dark green")

title = Text(app,
             text="Hard to read",
             size="14",
             font="Comic Sans",
             color="green")

app.repeat(1000, flash_text)

app.display()
Пример #4
0
                "Longitude","Organization","Query"]
                   
                # list of criteria options for just RDAP data
rdapCriteriaList = ["ASN","ASN Routing Block","ASN Country Code","ASN Date",
                    "ASN Registry","ASN Description","Start Address","End Address",
                    "Handle","Parent Handle","IP Version","Name"]

fileToSearch = 'list_of_ips.txt'
ip_addresses = findIPAddresses(fileToSearch) #list of IP addresses found in text file
initialize() # initializes data for the IPs

#---------------------------------------------------------------------------#

##code to run guizero gui
# basic initializations and instructions
app = App(title="Filter Tool")
instructionText = Text(app, text = "Instructions: Select a criteria to filter by, then \nenter a value that you want the IP addresses\n to be filtered by. Or put in a list index in the first field \nprovided below and press one of the 'show' buttons to display data", size = 10)
# initializing GeoIP and RDAP lookup data windows and buttons to open them
ipIndexTextBox = TextBox(app)
geoDataButton = PushButton(app, text = "Show GeoIP Data", command = handleGeoButton)
geoWindow = Window(app, title = "GeoIP Lookup Data")
geoWindow.hide()
geoWText = Text(geoWindow, text = "", size = 10)
rdapDataButton = PushButton(app, text = "Show RDAP Data", command = handleRDAPButton)
rdapWindow = Window(app, title = "RDAP Lookup Data")
rdapWindow.hide()
rdapWText = Text(rdapWindow, text = "", size = 10)
# initializing filter tool buttons and text fields
criteriaText = Text(app, text = "Filter by Criteria:")
criteriaOptions = Combo(app, options=criteriaList)
valueText = Text(app, text = "Filter by Value:")
    }

    if game in LOSSES:
        outcome = 'Better luck next time!'
    elif game in TIES:
        outcome = "It's a tie!"
    else:
        outcome = 'You win!'

    end_game_message = 'You picked {} and the computer picked {}. {}'.format(game['player'],
                                                                             game['computer'],
                                                                             outcome
                                                                             )

    message.value = end_game_message

    button.text = 'Play again!'


app = App(title='Rock Paper Scissors')

content_box = Box(app, width='fill', align='top')
message = Text(content_box, text="Ready to play?")

button_box = Box(app, width='fill', align='bottom')

# Wire the button to our play_game function
button = PushButton(button_box, text='Play!', command=play_game)

app.display()
Пример #6
0
        GPIO.setup(35, GPIO.OUT)
        GPIO.output(35, GPIO.LOW)
    else:
        air_state = 0
        air_button.image = path + 'AirSystem_off.png'
        GPIO.setup(35, GPIO.OUT)
        GPIO.output(35, GPIO.HIGH)


def screen_brightness():
    global slider
    print(slider.value)
    bl.set_brightness(str(slider.value))


app = App(title="Keypad example", width=480, height=320, layout="grid")
app.bg = 'black'
rear_light_button = PushButton(app,
                               command=rear_light_callback,
                               grid=[0, 0],
                               align='left',
                               image=path + 'rear_lights_off.png')
front_light_button = PushButton(app,
                                command=front_light_callback,
                                grid=[1, 0],
                                align='left',
                                image=path + 'front_lights_off.png')
water_pump_button = PushButton(app,
                               command=water_pump_callback,
                               grid=[2, 0],
                               align='left',
Пример #7
0
        message.value = "It's a draw"

    resetbutton = PushButton(board, text="reset", command=clear_board)
    resetbutton.hide()
    if winner is not None:
        resetbutton.show()


def moves_taken():
    moves = 0
    for row in board_squares:
        for col in row:
            if col.text == "X" or col.text == "O":
                moves = moves + 1
    return moves


#def reset():
#   resetbutton = PushButton(board,text="reset",command=clear_board)
#  resetbutton.hide()
# if

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

# App -------------------
app = App("Tic tac toe")
board = Box(app, layout="grid")
board_squares = clear_board()
message = Text(app, text="It's your turn" + turn)
app.display()
Пример #8
0
def test_enable():
    a = App()
    c = Combo(a, ["foo", "bar"])
    enable_test(c)
    a.destroy()
Пример #9
0
def test_display():
    a = App()
    c = Combo(a, ["foo", "bar"])
    display_test(c)
    a.destroy()
Пример #10
0
def test_after_schedule():
    a = App()
    c = Combo(a, ["foo", "bar"])
    schedule_after_test(a, c)
    a.destroy()
Пример #11
0
def test_repeat_schedule():
    a = App()
    c = Combo(a, ["foo", "bar"])
    schedule_repeat_test(a, c)
    a.destroy()
Пример #12
0
from guizero import App, TextBox, Text, PushButton, info, \
    ButtonGroup, Combo


# Functions go here
def btn_make_name():
    generated = "You are a {} {} {}".format(txt_name.value, txt_color.value,
                                            txt_animal.value)
    lbl_generated_name.value = generated


# main routine goes here
app = App(title="Name Generator")

lbl_name = Text(app, text="Choose an adjective", size=14)
txt_name = ButtonGroup(app, options=["Great", "Amazing", "Marvelous"])

lbl_color = Text(app, text="Enter a colour", size=14)
txt_color = TextBox(app)

lbl_animal = Text(app, text="Pick an Animal", size=14)
txt_animal = Combo(app, options=["Sheep", "Goat", "Gold Fish"])

btn_generate = PushButton(app, command=btn_make_name, text="Generate")

lbl_generated_name = Text(app, text="")

app.display()
# import libraries
from guizero import App, PushButton, Slider, Text, Window
from gpiozero import Robot, CamJamKitRobot, AngularServo
from gpiozero.pins.pigpio import PiGPIOFactory

#Define the app and window for the servo sliders
app = App("Dual Robot Control", layout='grid')
servo_window = Window(app, "Servo Movement")
servo_window.bg = (51, 165, 255)
app.bg = (51, 246, 255)

#Define the factories
# insert IP addresses of both robots here
factory = PiGPIOFactory(host='')

# Define both robots
linus = Robot(left=(13, 21), right=(17, 27), pin_factory=factory)
torvalds = CamJamKitRobot()

# Define the servos
servo = AngularServo(22, min_angle=-90, max_angle=90, pin_factory=factory)
servo_two = AngularServo(23, min_angle=-90, max_angle=90, pin_factory=factory)


# Define the functions
def direction_one():
    linus.forward()


def direction_two():
    linus.backward()
Пример #14
0
# column into a seperate list

def newCompliment():
    newCompliment= complimentMe()
    message.value = newCompliment

adjectiveOne=[]
adjectiveTwo=[]
noun=[]
#open compliments.csv in read mode
with open("compliments.csv","r") as file:
    for singleLine in file:
        word = singleLine.split(",")
        adjectiveOne.append(word[0])
        adjectiveTwo.append(word[1])
        noun.append(word[2].strip())

#create gui
app = App(bg="#C0C5FF")
app.title="Compliment with Shakespear"
picture = Picture(app,image="theman.png")
picture.height = 400
picture.weidth = 350
picture.bg ="#C0C5FF"
message = Text (app,complimentMe()) # creates a Text object, adds it to the app and then calls the function to get an insult
message.font="arial bold"
message.bg="#C0C5FF"#create PushButton object
#calls new Insult function
button = PushButton(app, newCompliment, text="Compliment me again!")
app.display()
Пример #15
0
    speed = int(~((127 / 100) * speed) + 1)
    ser.write(b'L')
    ser.write([speed])
    sleep(.00001)
    ser.write(b'R')
    ser.write([speed])


def stop():

    ser.write(b'S')


init = "0"

app = App("Display Sensor", layout="auto")

batt = Text(app, text="Battery Voltage: " + init)
tof = Text(app, text="ToF sensor: " + str(vl53.range))
ir = Text(app, text="IR sensors: " + init)
bttn = Text(app, text="Button sensors: " + init)
mtr = Text(app, text="Motor Speed: " + init)

button1 = PushButton(app, text="Forward", command=forward, args=[25])
button2 = PushButton(app, text="Stop", command=stop)
button3 = PushButton(app, text="Backward", command=backward, args=[25])

tof.repeat(100, updateTof)
ir.repeat(50, getIR)
bttn.repeat(50, getBtns)
batt.repeat(1000, getVolt)
Пример #16
0
def test_text():
    a = App()
    c = Combo(a, ["foo", "bar"])
    text_test(c)
    a.destroy()
Пример #17
0
from guizero import App, Box, Text, TextBox

app = App()

box_fname = Box(app, width="fill")
lbl_fname = Text(box_fname, text="First name", align="left", width=10)
txt_fname = TextBox(box_fname, align="left")

box_sname = Box(app, width="fill")
lbl_sname = Text(box_sname, text="Surname", align="left", width=10)
txt_snmae = TextBox(box_sname, align="left")

box_dob = Box(app, width="fill")
lbl_dob = Text(box_dob, text="Date of birth", align="left", width=10)
txt_dob = TextBox(box_dob, align="left")

app.display()
Пример #18
0
def test_color():
    a = App()
    c = Combo(a, ["foo", "bar"])
    color_test(c)
    a.destroy()
Пример #19
0
from guizero import App, TextBox, Text, PushButton
import webbrowser

app = App(title="Kiosk")

# WIDGET CODE GOES HERE

input_msg = TextBox(app)
display_msg = Text(app,
                   "TEACHER'S MESSAGE",
                   size=16,
                   font="Times New Roman",
                   color="black")


def printMsg():
    display_msg.value = input_msg.value


def openCalendarLink():
    webbrowser.open("https://ee.calpoly.edu/faculty/phummel/")


def openSchedulerLink():
    webbrowser.open("https://phummel.youcanbook.me/")


update_text = PushButton(app, command=printMsg, text="Input a message")

openCalendar = PushButton(app, command=openCalendarLink, text="Open Calendar")
Пример #20
0
def test_size():
    a = App()
    c = Combo(a, ["foo", "bar"])
    size_text_test(c)
    size_fill_test(c)
    a.destroy()
Пример #21
0
from guizero import App, TextBox, PushButton, Picture, Box, info, Window, Text
import ast, json
from time import sleep

app = App(title="Bazaar Turflijst")
app.tk.attributes("-fullscreen",True)
turfknopArea = Box(app, layout="grid", align="left", width="fill", height="fill")
#settingknopArea = Box(app,align="left", width="fill", height="fill")
textArea = Box(app, align="left", width="fill", height="fill")
standText = TextBox(textArea, enabled=False,text="stand",
                    align="left",multiline=True, width = "fill", height = "fill")
standText.text_size = 23
doubleCheckWindow = Window(app,title="Zeker weten?", height=300, width=500, visible=False)
doubleCheckText = Text(doubleCheckWindow, text="Weet je zeker dat je de stand wilt resetten?", align="top")
doublecheckText2 = Text(doubleCheckWindow, text="Dit kan niet ongedaan gemaakt worden.", align="top")

voWindow = Window(app, title="73 bravo", height=300, width=500, visible=False)
voText = Text(voWindow, text="GEFELICITEERD JIJ ONTZETTENDE VOBAAS", align="top")
voText2 = Text(voWindow, text="73 pilsies gemurderd", align="top")

superVoWindow = Window(app, title="spiegeltje spiegeltje aan de wand, wie is de grootste pilsbaas van het land?", height=300, width=500, visible=False)
superVoText = Text(superVoWindow, text="LEKKER GEZOPEN OUWE!", align="top")
superVoText2 = Text(superVoWindow, text="Je hebt de bierlijst gewonnen", align="top")
superVoText3 = Text(superVoWindow, text="Check ff op wie je anytimers hebt", align="top")

huisgenoten = []
laatsteTurfjes = []

#functions
def turf(persoon):
   feedback()
Пример #22
0
def test_events():
    a = App()
    c = Combo(a, ["foo", "bar"])
    events_test(c)
    a.destroy()
Пример #23
0
          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!"
    elif moves_taken() == 9:
        message.value = "It's a draw!"


def moves_taken():
    moves = 0
    for row in board_squares:
        for col in row:
            if col.text == "X" or col.text == "O":
                moves = moves + 1
    return moves


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

# App ----------------------------
app = App("Tic-Tac-Toe")
board = Box(app, layout="grid")
board_squares = clear_board()
message = Text(app, text="Its your turn, " + turn)
button = PushButton(app, board_squares, text="Reset")

# Display ------------------------
app.display()
Пример #24
0
def test_cascaded_properties():
    a = App()
    c = Combo(a, ["foo", "bar"])
    cascaded_properties_test(a, c, True)
    a.destroy()
Пример #25
0

def reduce_time():
    timer.value = int(timer.value) - 1
    # is it game over?
    if int(timer.value) < 0:
        result.value = "Game over! Score = " + score.value
        # hide the game
        game_box.hide()


# ------------------------------
# App
# ------------------------------

app = App("emoji match")

game_box = Box(app, align="top")

top_box = Box(game_box, align="top", width="fill")
Text(top_box, align="left", text="Score ")
score = Text(top_box, text="4", align="left")
timer = Text(top_box, text="30", align="right")
Text(top_box, text="Time", align="right")

pictures_box = Box(game_box, layout="grid")
buttons_box = Box(game_box, layout="grid")

pictures = []
buttons = []
Пример #26
0
def test_inherited_properties():
    a = App()
    inherited_properties_test(a, lambda: Combo(a, ["foo", "bar"]), True)
    a.destroy()
Пример #27
0
#             forward(abs(output))
#             forward(output)
#             print(inputSudut, 'output : ', output)
#             print("forward")
#         elif inputSudut > setPoint and maju == True:
#             print(inputSudut, 'output : ', output)
#             print("back")
#             backward(abs(output))
#             backward(-output)
#         else:
#             equilibrium()
#             print("equi")
    else:
        print("berhenti")

app = App(title="PID Control Setting")
text = Text(app)
text.repeat(10, mainLoop)
welcomeMessage = Text(app, text="PID Control Setting")

calibrationSlider = Slider(app,
                           command=changeCalibrationValue,
                           start=-30,
                           end=30)
setPointSlider = Slider(app, command=changeSetPointValue, start=-30, end=30)
PSlider = Slider(app, command=changePValue, start=-1000, end=1000)
ISlider = Slider(app, command=changeIValue, start=-3000, end=3000)
DSlider = Slider(app, command=changeDValue, start=-3000, end=3000)
button1 = PushButton(app, command=berhenti)
button2 = PushButton(app, command=mulai)
app.display()
Пример #28
0
pwm = GPIO.PWM(FEED_SERVO_CONTROL_PIN, PWM_FREQUENCY)

def FullRight():
    pwm.start(FULL_SPEED_FORWARD_DC)
    time.sleep(0.5)
    pwm.ChangeDutyCycle(FULL_SPEED_PAUSE_DC)
    
def FineRight():
    pwm.start(FULL_SPEED_FORWARD_DC)
    time.sleep(0.1)
    pwm.ChangeDutyCycle(FULL_SPEED_PAUSE_DC)

def FullLeft():
    pwm.start(FULL_SPEED_BACKWARD_DC)
    time.sleep(0.5)
    pwm.ChangeDutyCycle(FULL_SPEED_PAUSE_DC)
  
def FineLeft():
    pwm.start(FULL_SPEED_BACKWARD_DC)
    time.sleep(0.1)
    pwm.ChangeDutyCycle(FULL_SPEED_PAUSE_DC)

     
app = App(layout="grid", title="Focus Control", bg="black", width=150, height=625)

button1 = PushButton(app, grid=[0,0], width=150, height=150, image="/home/pi/TouchCam/icon/fullleft.png", command=FullLeft)
button2 = PushButton(app, grid=[0,1], width=150, height=150, image="/home/pi/TouchCam/icon/fineleft.png", command=FineLeft)
button3 = PushButton(app, grid=[0,2], width=150, height=150, image="/home/pi/TouchCam/icon/fineright.png", command=FineRight)
button4 = PushButton(app, grid=[0,3], width=150, height=150, image="/home/pi/TouchCam/icon/fullright.png", command=FullRight)

app.display()
Пример #29
0
from guizero import App, Text, PushButton, TextBox
import serial
port = serial.Serial("/dev/ttyS0", baudrate=9600, timeout=1)

def enciende_rojo():
    cmd = "R"
    port.write(cmd.encode())
    rcv=port.read(20)

def enciende_azul():
    cmd = "B"
    port.write(cmd.encode())
    rcv=port.read(20)

def enciende_verde():
    cmd = "G"
    port.write(cmd.encode())
    rcv=port.read(20)

app = App(title="Control de LEDs RGB")
message = Text(app, text="Control de LEDs RGB!")
rojo = PushButton(app, text="Rojo",command=enciende_rojo)
rojo.bg="red"
verde = PushButton(app, text="Verde",command=enciende_verde)
verde.bg="light green"
azul= PushButton(app, text="Azul",command=enciende_azul)
azul.bg="light blue"
app.display()
Пример #30
0
def make_app() -> App:
    app = App(title="Hello world")
    message = Text(app, text="Welcome to the Hello world app!")
    return app