def search(retrieve): #prints for confirmation on startup of function print("retrieval signalled") os.chdir(retrieve) rescue = os.listdir(os.getcwd()) print(rescue) #for debug #found = [] currently = os.getcwd() msg = ("Chose a file from " + currently) title = "Open File" choices = rescue #'\n'.join() choice = easygui.choicebox(msg, title, choices) #prints values of variables to console for debugging #print(choice, choices, msg, title, retrieve, rescue) print("current directory: " + str(os.getcwd())) print("choices are " + str(choices)) print("chosen document: " + str(choice)) #opens chosen file fow = open(choice, 'r') thing = fow.read() try: input_box = guizero.TextBox(app, width = app.width, height = app.height, multiline = True, scrollbar = True, text = thing) except: exceptionbox()
def main(): # making entertask a global variable so we can access its value from any method global enterTask global box enterTask = guizero.TextBox(app, text="Enter a Task", width=50) guizero.Text(app, text=" ") guizero.PushButton(app, command=addTask, text="Add Task") showAll() # drawing elements in the bottom of the screen # creating a box object to align to the bottom of the screen box = guizero.Box(app, width="fill", align="bottom") guizero.PushButton(box, text="Delete All", align="right", command=deleteAll) guizero.PushButton(box, text="Delete Selected", align="right", command=removeTask) guizero.PushButton(box, text="Complete task", align="left", command=completeTask)
def __init__(self, app): self.about_text = app_variables.about_window_text_file_location self.window = guizero.Window( app, title="About || KootNet Sensors - Control Center", width=610, height=325, layout="grid", visible=False) self.about_text1 = guizero.Text(self.window, text=app_variables.software_version, grid=[1, 1], align="right") self.about_textbox = guizero.TextBox(self.window, text="About", grid=[1, 2], width=75, height=18, multiline=True, align="left") # Window Tweaks self.window.tk.resizable(False, False) self._set_about_text() self.about_textbox.disable() self.about_textbox.bg = "black" self.about_textbox.text_color = "white"
def photoUpload(): box1=guizero.Box(app, layout="grid") text1=guizero.Text(box1,text="Hvor mange minutter skal der filmes? ", grid=[0,0]) minutes=guizero.TextBox(box1,text="", grid=[1,0]) minutes.focus() text2=guizero.Text(box1, text="hvor mange sekunder mellem hvert billede? ",grid=[0,1]) timelapse=guizero.TextBox(box1,text="", grid=[1,1]) text3=guizero.Text(box1, text="filnavn ? ",grid=[0,2]) filename=guizero.TextBox(box1,text="", grid=[1,2]) text4=guizero.Text(box1, text=("størrelse: "),grid=[0,3]) picsize=guizero.Slider(box1, start=640, end=3280, grid=[1,3]) button1=guizero.PushButton(box1, command=lambda:printit(minutes.get(),timelapse.get(),filename.get()), text="Submit",grid=[1,5])
def File_New(): msg = "Create a new file?" title = "New File" if easygui.ccbox(msg, title): input_box = guizero.TextBox(app, width = app.width, height = app.height, multiline = True, scrollbar = True) TextBox.update_command(txhx.hideit) else: exceptionbox()
def main(): guizero.Text(app, text=" ") guizero.Text(app, text="Youtube Video Downloader") guizero.Text(app, text=" ") guizero.Text(app, text="Insert the video link below") guizero.Text(app, text=" ") global video_link video_link = guizero.TextBox(app, width=int(display_width * 0.1)) guizero.Text(app, text=" ") global push_btn push_btn = guizero.PushButton(app, text="Search Video", command=start_download_thread) global video_box video_box = guizero.Box(app, width=int(display_width - 100), height=100)
def edit_identity_cards(identity_cards,matrix,desktop): windows=guizero.Window(desktop,layout='grid',title='Edit',visible=False) road={} text_box=guizero.TextBox(windows,grid=[20,0],width=45,enabled=False) end = guizero.PushButton(windows, grid=[20, 1], text='End',command=lambda: save_(identity_cards, road, matrix, windows)) directs=guizero.Combo(windows,options=["up", "down", "left","right"],grid=[20,2]) option=guizero.PushButton(windows,grid=[20,4],text='Nome') y=14 for i in range(15): for x in range(20): dictionary = {'X': 'black', 'o': 'green', ' ': 'white', 'v': 'yellow'} road[x,y]=box(x,i,identity_cards[x,y],windows,text_box,directs,option) road[x,y].step.bg=dictionary[matrix[x,y]] y-=1 windows.show(wait=True)
def __init__(self, app, ip_selection, current_config): self.ip_selection = ip_selection self.current_config = current_config self.window = guizero.Window(app, title="Sensors Configuration", width=625, height=385, layout="grid", visible=False) self.text_select = guizero.Text( self.window, text="Select Sensor IPs in the main window", grid=[1, 1, 3, 1], color='#CB0000', align="left") self.textbox_config = guizero.TextBox( self.window, text=app_variables.default_sensor_config_text.strip(), grid=[1, 2], width=75, height=18, multiline=True, scrollbar=True, align="right") self.button_get_config = guizero.PushButton( self.window, text="Get Sensor\nConfiguration", command=self.button_get, grid=[1, 10], align="left") self.text_select_combo = guizero.Text( self.window, text="Select Configuration File to Edit", grid=[1, 10], color='blue', align="top") self.combo_dropdown_selection = guizero.Combo( self.window, options=[ "Configuration", "Installed Sensors", "Wifi", "Trigger Variances" ], grid=[1, 10], command=self.combo_selection, align="bottom") self.button_set_config = guizero.PushButton( self.window, text="Set Sensor\nConfiguration", command=self.button_set, grid=[1, 10], align="right") # Window Tweaks self.window.tk.resizable(False, False) self.textbox_config.bg = "black" self.textbox_config.text_color = "white" self.textbox_config.tk.config(insertbackground="red")
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() zipfiler.zipper()
def __init__(self, app, current_config): self.current_config = current_config self.database_line_width = 40 self.textbox_table_width = 22 self.window = guizero.Window(app, title="DataBase Information", width=595, height=635, layout="grid", visible=False) self.button_open_database = guizero.PushButton( self.window, text="Open\nDatabase", command=self._open_database, grid=[1, 1, 1, 2], align="left") self.text_database_label = guizero.Text(self.window, text="Database: ", color='blue', grid=[1, 1], align="right") self.textbox_database_name = guizero.TextBox( self.window, text="Please Open a Database", width=self.database_line_width, grid=[2, 1, 2, 1], align="left") self.text_database_location_label = guizero.Text(self.window, text="Location: ", color='blue', grid=[1, 2], align="right") self.textbox_database_location = guizero.TextBox( self.window, text="Please Open a Database", width=self.database_line_width, height=2, grid=[2, 2, 2, 1], multiline=True, scrollbar=True, align="left") self.text_db_dates = guizero.Text(self.window, text="Date Range: ", color='blue', grid=[1, 3], align="right") self.textbox_db_dates = guizero.TextBox( self.window, text="First Recorded Date || Last Recorded Date", width=self.database_line_width, grid=[2, 3, 2, 1], align="left") self.text_db_size = guizero.Text(self.window, text="Database Misc. Info: ", color='blue', grid=[1, 4], align="right") self.textbox_misc_db_info = guizero.TextBox( self.window, text="DB Size: MB || Notes: XX || Reboots: XX", width=self.database_line_width, grid=[2, 4, 2, 1], align="left") self.text_name_changes = guizero.Text( self.window, text="\nRecorded Name Changes\nCurrent: ", color='purple', grid=[2, 7, 2, 1], align="left") self.text_name_date = guizero.Text(self.window, text="Date of Change", color='blue', grid=[1, 10], align="left") self.textbox_name_dates = guizero.TextBox( self.window, text="1. Date", width=self.textbox_table_width, height=10, grid=[1, 11], multiline=True, scrollbar=True, align="left") self.text_name_new = guizero.Text(self.window, text="New Name", color='blue', grid=[2, 10], align="left") self.textbox_new_names = guizero.TextBox( self.window, text="1. NewName", width=self.textbox_table_width, height=10, grid=[2, 11], multiline=True, scrollbar=True, align="left") self.text_name_old = guizero.Text(self.window, text="Old Name", color='blue', grid=[3, 10], align="left") self.textbox_old_names = guizero.TextBox( self.window, text="1. OldName", width=self.textbox_table_width, height=10, grid=[3, 11], multiline=True, scrollbar=True, align="left") self.text_ip_changes = guizero.Text( self.window, text="\nRecorded IP Changes\nCurrent: ", color='purple', grid=[2, 12], align="left") self.text_ip_date = guizero.Text(self.window, text="Date of Change", color='blue', grid=[1, 16], align="left") self.textbox_ip_dates = guizero.TextBox(self.window, text="1. Date", width=self.textbox_table_width, height=10, grid=[1, 17], multiline=True, scrollbar=True, align="left") self.text_ip_new = guizero.Text(self.window, text="New IP", color='blue', grid=[2, 16], align="left") self.textbox_new_ips = guizero.TextBox(self.window, text="1. NewIP", width=self.textbox_table_width, height=10, grid=[2, 17], multiline=True, scrollbar=True, align="left") self.text_ip_old = guizero.Text(self.window, text="Old IP", color='blue', grid=[3, 16], align="left") self.textbox_old_ips = guizero.TextBox(self.window, text="1. OldIP", width=self.textbox_table_width, height=10, grid=[3, 17], multiline=True, scrollbar=True, align="left") self.text_spacer = guizero.Text(self.window, text="", grid=[1, 18], align="left") # Window Tweaks self.window.tk.resizable(False, False) self.textbox_database_name.disable() self.textbox_database_location.disable() self.textbox_db_dates.disable() self.textbox_misc_db_info.disable() self.textbox_name_dates.bg = "black" self.textbox_name_dates.text_color = "white" self.textbox_name_dates.tk.config(insertbackground="red") self.textbox_new_names.bg = "black" self.textbox_new_names.text_color = "white" self.textbox_new_names.tk.config(insertbackground="red") self.textbox_old_names.bg = "black" self.textbox_old_names.text_color = "white" self.textbox_old_names.tk.config(insertbackground="red") self.textbox_ip_dates.bg = "black" self.textbox_ip_dates.text_color = "white" self.textbox_ip_dates.tk.config(insertbackground="red") self.textbox_new_ips.bg = "black" self.textbox_new_ips.text_color = "white" self.textbox_new_ips.tk.config(insertbackground="red") self.textbox_old_ips.bg = "black" self.textbox_old_ips.text_color = "white" self.textbox_old_ips.tk.config(insertbackground="red")
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()
button1=guizero.PushButton(box1, command=lambda:printit(minutes.get(),timelapse.get(),filename.get()), text="Submit",grid=[1,5]) def printit(minutes,timelapse,filename): print("virker knappen? {0},{1},{2}".format(minutes,timelapse,filename)) def photoNoUpload(): pass def videoUpload(): pass def videoNoUpload(): pass app=guizero.App(title="Surveillance tools") menu=guizero.MenuBar(app,toplevel=["Photo", "Video"],options=[[["With upload",photoUpload],["Without upload",photoNoUpload]],[["with upload",videoUpload],["Without upload",videoNoUpload]]]) picsize=guizero.Slider(box1, start=640, end=3280, grid=[1,3]) textbox_message=guizero.TextBox(app) message=guizero.Text(app, text="Hvad skal vi lave i dag?") app.display()
for _ in metadata.items(): # add each item in metadata to listbox listbox.append(f"{_[0]}: {_[1]}") except FileNotFoundError: message = guizero.Text(return_box, text="") thumbnail = guizero.Picture(return_box, image=f'error.jpeg', width=200, height=200) message = guizero.Text(return_box, text="") message = guizero.Text(return_box, text="Image not found") menubar = guizero.MenuBar(app, toplevel=['About'], options=[[['About Metas-Strip', about]]]) message = guizero.Text(app, text="") message = guizero.Text(app, text="Metas-Strip") message = guizero.Text(app, text="Enter image path") message = guizero.Text(app, text="") input_box = guizero.TextBox(app, width="70") message = guizero.Text(app, text="") button = guizero.PushButton(app, command=open_image, text="Open Image") cancel = guizero.PushButton(buttons_box, text="Clear", align="right", command=clear_all) app.display()
#!/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()
def __init__(self, app, current_config): self.current_config = current_config self.data_queue = Queue() # Sensor's Online / Offline IP List Selection 1 self.app_checkbox_all_column1 = guizero.CheckBox( app, text="Check ALL Column 1", command=self._app_check_all_ip1, grid=[1, 1, 3, 1], align="left") self.app_checkbox_ip1 = guizero.CheckBox(app, text="IP ", grid=[1, 2], align="left") self.app_textbox_ip1 = guizero.TextBox(app, text="192.168.10.11", width=21, grid=[2, 2], align="left") self.app_checkbox_ip2 = guizero.CheckBox(app, text="IP ", grid=[1, 3], align="left") self.app_textbox_ip2 = guizero.TextBox(app, text="192.168.10.12", width=21, grid=[2, 3], align="left") self.app_checkbox_ip3 = guizero.CheckBox(app, text="IP ", grid=[1, 4], align="left") self.app_textbox_ip3 = guizero.TextBox(app, text="192.168.10.13", width=21, grid=[2, 4], align="left") self.app_checkbox_ip4 = guizero.CheckBox(app, text="IP ", grid=[1, 5], align="left") self.app_textbox_ip4 = guizero.TextBox(app, text="192.168.10.14", width=21, grid=[2, 5], align="left") self.app_checkbox_ip5 = guizero.CheckBox(app, text="IP ", grid=[1, 6], align="left") self.app_textbox_ip5 = guizero.TextBox(app, text="192.168.10.15", width=21, grid=[2, 6], align="left") self.app_checkbox_ip6 = guizero.CheckBox(app, text="IP ", grid=[1, 7], align="left") self.app_textbox_ip6 = guizero.TextBox(app, text="192.168.10.16", width=21, grid=[2, 7], align="left") self.app_checkbox_ip7 = guizero.CheckBox(app, text="IP ", grid=[1, 8], align="left") self.app_textbox_ip7 = guizero.TextBox(app, text="192.168.10.17", width=21, grid=[2, 8], align="left") self.app_checkbox_ip8 = guizero.CheckBox(app, text="IP ", grid=[1, 9], align="left") self.app_textbox_ip8 = guizero.TextBox(app, text="192.168.10.18", width=21, grid=[2, 9], align="left") # Sensor's Online / Offline IP List Selection 2 self.app_checkbox_all_column2 = guizero.CheckBox( app, text="Check ALL Column 2", command=self._app_check_all_ip2, grid=[3, 1, 3, 1], align="left") self.app_checkbox_ip9 = guizero.CheckBox(app, text="IP ", grid=[3, 2], align="left") self.app_textbox_ip9 = guizero.TextBox(app, text="192.168.10.19", width=21, grid=[4, 2], align="left") self.app_checkbox_ip10 = guizero.CheckBox(app, text="IP ", grid=[3, 3], align="left") self.app_textbox_ip10 = guizero.TextBox(app, text="192.168.10.20", width=21, grid=[4, 3], align="left") self.app_checkbox_ip11 = guizero.CheckBox(app, text="IP ", grid=[3, 4], align="left") self.app_textbox_ip11 = guizero.TextBox(app, text="192.168.10.21", width=21, grid=[4, 4], align="left") self.app_checkbox_ip12 = guizero.CheckBox(app, text="IP ", grid=[3, 5], align="left") self.app_textbox_ip12 = guizero.TextBox(app, text="192.168.10.22", width=21, grid=[4, 5], align="left") self.app_checkbox_ip13 = guizero.CheckBox(app, text="IP ", grid=[3, 6], align="left") self.app_textbox_ip13 = guizero.TextBox(app, text="192.168.10.23", width=21, grid=[4, 6], align="left") self.app_checkbox_ip14 = guizero.CheckBox(app, text="IP ", grid=[3, 7], align="left") self.app_textbox_ip14 = guizero.TextBox(app, text="192.168.10.24", width=21, grid=[4, 7], align="left") self.app_checkbox_ip15 = guizero.CheckBox(app, text="IP ", grid=[3, 8], align="left") self.app_textbox_ip15 = guizero.TextBox(app, text="192.168.10.25", width=21, grid=[4, 8], align="left") self.app_checkbox_ip16 = guizero.CheckBox(app, text="IP ", grid=[3, 9], align="left") self.app_textbox_ip16 = guizero.TextBox(app, text="192.168.10.26", width=21, grid=[4, 9], align="left") # Window Tweaks self.app_checkbox_all_column1.value = 0 self.app_checkbox_all_column2.value = 0 self._app_check_all_ip1() self._app_check_all_ip2() self.app_checkbox_ip1.value = 1
def __init__(self, app, ip_selection, current_config): self.ip_selection = ip_selection self.current_config = current_config self.readable_column_names = app_variables.CreateSQLColumnsReadable() self.sql_columns = app_variables.CreateSQLColumnNames() self.window = guizero.Window(app, title="Remote Sensor Display", width=275, height=400, layout="grid", visible=False) self.text_temperature_offset = guizero.Text(self.window, text="Env Temp Offset:", color='green', grid=[1, 11], align="left") self.textbox_temperature_offset = guizero.TextBox(self.window, text="", width=5, grid=[2, 11], align="left") self.checkbox_default_offset = guizero.CheckBox( self.window, text="Use Sensor\nDefault", command=self._click_checkbox_offset, grid=[2, 11], align="right") self.checkbox_custom_text = guizero.CheckBox( self.window, text="Text Message", command=self._text_checkbox, grid=[1, 16], align="left") self.checkbox_master = guizero.CheckBox(self.window, text="All Sensors", command=self._master_checkbox, grid=[2, 16], align="left") self.text_space1 = guizero.Text(self.window, text=" ", grid=[1, 17], align="left") self.checkbox_up_time = guizero.CheckBox( self.window, text=self.readable_column_names.system_uptime, args=[self.sql_columns.system_uptime], grid=[1, 27], align="left") self.checkbox_cpu_temp = guizero.CheckBox( self.window, text=self.readable_column_names.cpu_temp, args=[self.sql_columns.cpu_temp], grid=[1, 28], align="left") self.checkbox_temperature = guizero.CheckBox( self.window, text=self.readable_column_names.environmental_temp, args=[self.sql_columns.environmental_temp], grid=[1, 29], align="left") self.checkbox_pressure = guizero.CheckBox( self.window, text=self.readable_column_names.pressure, args=[self.sql_columns.pressure], grid=[1, 30], align="left") self.checkbox_altitude = guizero.CheckBox( self.window, text=self.readable_column_names.altitude, args=[self.sql_columns.altitude], grid=[1, 31], align="left") self.checkbox_humidity = guizero.CheckBox( self.window, text=self.readable_column_names.humidity, args=[self.sql_columns.humidity], grid=[1, 32], align="left") self.checkbox_distance = guizero.CheckBox( self.window, text=self.readable_column_names.distance, args=[self.sql_columns.distance], grid=[1, 33], align="left") self.checkbox_gas = guizero.CheckBox( self.window, text=self.readable_column_names.gas, args=[self.sql_columns.gas], grid=[1, 34], align="left") self.checkbox_particulate_matter = guizero.CheckBox( self.window, text=self.readable_column_names.particulate_matter, args=[self.sql_columns.particulate_matter], grid=[2, 27], align="left") self.checkbox_lumen = guizero.CheckBox( self.window, text=self.readable_column_names.lumen, args=[self.sql_columns.lumen], grid=[2, 28], align="left") self.checkbox_colour = guizero.CheckBox( self.window, text=self.readable_column_names.colours, args=[self.sql_columns.rgb], grid=[2, 29], align="left") self.checkbox_ultra_violet = guizero.CheckBox( self.window, text=self.readable_column_names.ultra_violet, args=[self.sql_columns.ultra_violet], grid=[2, 30], align="left") self.checkbox_acc = guizero.CheckBox( self.window, text=self.readable_column_names.accelerometer_xyz, args=[self.sql_columns.accelerometer_xyz], grid=[2, 31], align="left") self.checkbox_mag = guizero.CheckBox( self.window, text=self.readable_column_names.magnetometer_xyz, args=[self.sql_columns.magnetometer_xyz], grid=[2, 32], align="left") self.checkbox_gyro = guizero.CheckBox( self.window, text=self.readable_column_names.gyroscope_xyz, args=[self.sql_columns.gyroscope_xyz], grid=[2, 33], align="left") self.text_space4 = guizero.Text(self.window, text=" ", grid=[1, 45], align="right") self.button_send_to_display = guizero.PushButton( self.window, text="Show Reading\non Remote\nSensor Display", command=self._remote_sensor_display_selection, grid=[1, 46, 2, 1], align="top") # Window Tweaks self.window.tk.resizable(False, False) self.checkbox_default_offset.value = 1 self._set_config() self._click_checkbox_offset() self.checkbox_up_time.value = 0 self.checkbox_temperature.value = 0 self.checkbox_pressure.value = 0 self.checkbox_humidity.value = 0 self.checkbox_lumen.value = 0 self.checkbox_colour.value = 0
grid=[0, 2]) box0_text1 = guizero.PushButton(box0, text="Tryk v for video", command=video_choice, grid=[0, 3]) box0_text2 = guizero.PushButton(box0, text="Tryk p for livepreview", command=preview_only, grid=[0, 4]) box0.show() box1 = guizero.Box(app, layout="grid") box1.hide() text1 = guizero.Text(box1, text="Hvor mange minutter skal der optages? ", grid=[0, 0]) minutes = guizero.TextBox(box1, text="", grid=[1, 0]) minutes.focus() text2 = guizero.Text(box1, text="hvor mange sekunder mellem hvert billede? ", grid=[0, 1]) timelapse = guizero.TextBox(box1, text="", grid=[1, 1]) text3 = guizero.Text(box1, text="filnavn ? ", grid=[0, 2]) filename = guizero.TextBox(box1, text="", grid=[1, 2]) text4 = guizero.Text(box1, text=("størrelse: "), grid=[0, 3]) picsize = guizero.Slider(box1, start=640, end=3280, grid=[1, 3], command=update_size) picsize.text_size = 1 picsize_message = guizero.Text(box1, text="billedstørrelse", grid=[0, 4])
# # Graph Properties Box graph_properties_box = gui.Box(app, grid=[0, 1, 3, 1], width=510, height=60, layout='grid') username_box = gui.Box(graph_properties_box, grid=[0, 0], width=150, height=60) username_text = gui.Text(username_box, text='Username: '******'red', align='left') username_entry_textbox = gui.TextBox(username_box, text='aeversme', width=11, align='right') graph_button_box = gui.Box(graph_properties_box, grid=[1, 0], width=160, height=60) graph_button_box.tk.config(pady=15) graph_button = gui.PushButton(graph_button_box, open_graph_url, text='Go to my graph!', pady=5) graph_id_box = gui.Box(graph_properties_box, grid=[2, 0], width=150, height=60) graph_id_text = gui.Text(graph_id_box, text='Graph ID: ',
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()
def __init__(self, app, current_config, ip_selection): self.current_config = current_config self.ip_selection = ip_selection self.window = guizero.Window(app, title="Control Center Configuration", width=580, height=300, layout="grid", visible=False) self.button_reset = guizero.PushButton(self.window, text="Reset to\nDefaults", command=self._reset_to_defaults, grid=[1, 1], align="right") self.checkbox_power_controls = guizero.CheckBox( self.window, text="Enable 'Reset to Defaults'", command=self._enable_config_reset, grid=[1, 1], align="top") self.button_save_apply = guizero.PushButton( self.window, text="Save", command=self._button_save_apply, grid=[1, 1], align="left") self.text3 = guizero.Text(self.window, text="Save files to", color='blue', grid=[1, 2], align="left") self.textbox_save_to = guizero.TextBox(self.window, text='', width=50, grid=[1, 3], align="bottom") self.button_save_dir = guizero.PushButton(self.window, text="Choose Folder", command=self._button_save_to, grid=[1, 4], align="left") self.button_set_http_auth = guizero.PushButton( self.window, text="Set Sensors Authentication", command=self._update_http_authentication_credentials, grid=[1, 4], align="right") self.checkbox_enable_open_gl_plotly = guizero.CheckBox( self.window, text="Render Plotly with OpenGL", grid=[1, 5], align="top") self.text_info = guizero.Text(self.window, text="Default graph date range", color='blue', grid=[1, 6], align="top") self.text_spacer3 = guizero.Text(self.window, text="YYYY-MM-DD HH:MM:SS", size=7, color='#CB0000', grid=[1, 7], align="right") self.text_start = guizero.Text(self.window, text=" Start DateTime: ", color='green', grid=[1, 8], align="left") self.textbox_start = guizero.TextBox(self.window, text="", width=20, grid=[1, 8], align="right") self.text_end = guizero.Text(self.window, text=" End DateTime: ", color='green', grid=[1, 9], align="left") self.textbox_end = guizero.TextBox(self.window, text="", width=20, grid=[1, 9], align="right") self.text_live_refresh = guizero.Text( self.window, text="Live graph refresh in seconds: ", color='green', grid=[1, 10], align="left") self.textbox_live_refresh = guizero.TextBox(self.window, text="", width=5, grid=[1, 10], align="right") self.text_database_time = guizero.Text( self.window, text="Sensor Databases are\nsaved in UTC 0", size=10, grid=[2, 1], color='#CB0000', align="top") self.text_time_offset2 = guizero.Text(self.window, text="DateTime offset in hours", color='blue', grid=[2, 1], align="bottom") self.textbox_time_offset = guizero.TextBox(self.window, text="", width="5", grid=[2, 2], align="bottom") self.text_sql_skip = guizero.Text( self.window, text="Graph sensor data every 'X' entries", color='blue', grid=[2, 3], align="top") self.textbox_sql_skip = guizero.TextBox(self.window, text="", width="5", grid=[2, 4], align="top") self.text_temperature_offset = guizero.Text( self.window, text="Manual temperature offset in °C", color='blue', grid=[2, 4], align="bottom") self.textbox_temperature_offset = guizero.TextBox(self.window, text="", width="5", grid=[2, 5], align="bottom") self.text_network_timeouts = guizero.Text( self.window, text="Network timeouts in seconds", color='blue', grid=[2, 6], align="top") self.text_network_timeouts1 = guizero.Text(self.window, text="Sensor checks", color='green', grid=[2, 7], align="top") self.textbox_network_check = guizero.TextBox(self.window, text="", width="5", grid=[2, 8], align="top") self.text_network_timeouts2 = guizero.Text(self.window, text="Sensor data", color='green', grid=[2, 9], align="top") self.textbox_network_details = guizero.TextBox(self.window, text="", width="5", grid=[2, 10], align="top") # Window Tweaks self.window.tk.resizable(False, False) self.set_config(self.current_config) self.textbox_save_to.disable() self._enable_config_reset()
def __init__(self, app, ip_selection, current_config): self.ip_selection = ip_selection self.current_config = current_config self.network_get_commands = app_variables.CreateNetworkGetCommands() self.window = guizero.Window(app, title="Sensor Logs", width=975, height=450, layout="grid", visible=False) self.app_menubar = guizero.MenuBar( self.window, toplevel=[["Download"]], options=[[[ "Download All Selected Sensors Logs", self._download_logs ]]]) self.text_select_ip = guizero.Text( self.window, text="Select Sensor IPs in the main window", color="#CB0000", grid=[1, 1], align="left") self.text_choose = guizero.Text(self.window, text="Last lines of selected log", color="blue", grid=[1, 1], align="top") self.radio_log_type = guizero.ButtonGroup( self.window, options=["Primary Log", "Network Log", "Sensors Log"], horizontal="True", grid=[1, 1], align="right") self.textbox_log = guizero.TextBox( self.window, text="\nPlease select the log type in the top right" + " and press 'Update Sensor Log View' in the bottom right\n\n" + "You may also use the 'Download' menu in the top left to " + "download ALL logs from selected sensors to a chosen folder", grid=[1, 2], width=118, height=22, multiline=True, scrollbar=True, align="left") self.button_get = guizero.PushButton(self.window, text="Update Sensor\nLog View", command=self._get_log, grid=[1, 3], align="right") # Window Tweaks self.window.tk.resizable(False, False) self.textbox_log.bg = "black" self.textbox_log.text_color = "white" self.textbox_log.tk.config(insertbackground="red")
def Disclaimerdecline(): Disclaimerwindow.destroy() mainwindow.destroy() #All widgets based on window #Disclaimerwindow Disclaimerdeclinebutton = guizero.PushButton(Disclaimerwindow, command = Disclaimerdecline, text = "Exit", align = "bottom", padx = 38) Disclaimeracceptbutton = guizero.PushButton(Disclaimerwindow, command = Disclaimeraccept, text = "I understand", align = "bottom") Disclaimertext1 = guizero.Text(Disclaimerwindow, text = "The creator of this program is not responsible for :\n1)Damage caused to electrical components\n2)Harm caused to the user by electrical components\n3)Loss of functionality of electrical components\n") Disclaimertext2 = guizero.Text(Disclaimerwindow, text = "Note that the program does not interact with any components\nIt merely creates code which the user can run at their own risk\n") Disclaimertext3 = guizero.Text(Disclaimerwindow, text = "Program made by arnitdo\ngithub.com/arnitdo") #Buttonwindow Buttonnametext = guizero.Text(Buttonwindow, text = "\nName of new Button") Buttonnamebox = guizero.TextBox(Buttonwindow) Buttonpinnumbertext = guizero.Text(Buttonwindow, text = "\nNumber of GPIO Pin to which button is connedted") Buttonpinnumberbox = guizero.TextBox(Buttonwindow) Buttonselectexitbutton = guizero.PushButton(Buttonwindow, command = Buttonwindowexit, text = "Cancel", align = "bottom", padx = 14) Buttonnameconfirmbutton = guizero.PushButton(Buttonwindow, command = updateButtonname, text = "Confirm", align = "bottom") #Buttoncontrolwindow Buttoncontrolhelptext = guizero.Text(Buttoncontrolwindow, text = "Interface with LEDs using Buttons here\nSelect Button from first list\nSelect trigger from second list\nSelect LED to interact with in third list\nSelect LED power option in the fourth list\nNote that Buttons and LEDs need to be created / defined first" ) Buttoncontrolbuttonselect = guizero.ListBox(Buttoncontrolwindow, items = [], scrollbar = True, height = 75, width = 150, align = "top") Buttoncontrolbuttonactionselect = guizero.ListBox(Buttoncontrolwindow, items = ["when pressed", "when released"], scrollbar = True, height = 75, width = 150, align = "top") ButtoncontrolLEDselect = guizero.ListBox(Buttoncontrolwindow, items = [], scrollbar = True, height = 75, width = 150, align = "top") ButtoncontrolLEDactionselect = guizero.ListBox(Buttoncontrolwindow, items = ["Turn ON", "Turn OFF"], height = 75, width = 150, align = "top",scrollbar = True) Buttoncontrolcancelactionbutton = guizero.PushButton(Buttoncontrolwindow, command = Buttoncontrolwindow.hide, text = "Cancel", padx = 10, align = "bottom") Buttoncontrolconfirmactionbutton = guizero.PushButton(Buttoncontrolwindow, command = Buttoncontrolconfirmaction, text = "Confirm", align = "bottom", padx = 6) #mainwindow
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()
def __init__(self, app, ip_selection, current_config, database_or_sensor): self.database_or_sensor = database_or_sensor self.current_config = current_config self.ip_selection = ip_selection self.selected_ip = "" self.db_location = "" self.database_notes = [] self.database_notes_dates = [] self.database_user_note_dates = [] self.text_variables_generic = CreateGenericNoteVariables() self.text_variables_sensor = CreateSensorNoteVariables() self.text_variables_database = CreateDatabaseNoteVariables() self.sql_column_names = app_variables.CreateSQLColumnNames() self.network_send_commands = app_variables.CreateNetworkSendCommands() self.sensor_get_commands = app_variables.CreateNetworkGetCommands() self.window = guizero.Window(app, title=self.text_variables_database.window_title, width=580, height=525, layout="grid", visible=False) self.text_connected_to = guizero.Text(self.window, text=self.text_variables_database.text_connected_to, color="red", size=8, grid=[1, 1, 3, 1], align="left") self.checkbox_use_current_datetime = guizero.CheckBox(self.window, text=self.text_variables_generic.checkbox_enable_datetime, command=self._reset_datetime, grid=[4, 1, 5, 1], align="left") self.button_connect = guizero.PushButton(self.window, text=self.text_variables_database.button_connect, command=self._open_database, grid=[1, 5], align="left") self.button_back_note = guizero.PushButton(self.window, text="Back", command=self._back_button, grid=[2, 5], align="left") self.text_note_current = guizero.Text(self.window, text=self.text_variables_generic.text_note_current, color="blue", grid=[3, 5], align="top") self.textbox_on_number_notes = guizero.TextBox(self.window, text="0", width=5, grid=[3, 5], align="bottom") self.text_date_label1 = guizero.Text(self.window, text=self.text_variables_generic.text_date_label1, color="blue", grid=[4, 5], align="top") self.textbox_note_date = guizero.TextBox(self.window, text=self.text_variables_generic.textbox_note_date, grid=[4, 5], width=23, align="bottom") self.text_total_notes_label = guizero.Text(self.window, text=self.text_variables_generic.text_total_notes_label, color="blue", grid=[5, 5], align="top") self.textbox_total_notes = guizero.TextBox(self.window, text="0", width=5, grid=[5, 5], align="bottom") self.button_next_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_next_note, command=self._next_button, grid=[6, 5], align="left") self.textbox_current_note = guizero.TextBox(self.window, text=self.text_variables_database.textbox_current_note, width=70, height=25, grid=[1, 10, 6, 1], multiline=True, scrollbar=True, align="left") self.button_new_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_new_note, command=self._database_add_note_button, grid=[1, 12], align="left") self.button_delete_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_delete_note, command=self._database_delete_button, grid=[4, 12], align="left") self.button_update_note = guizero.PushButton(self.window, text=self.text_variables_generic.button_update_note, command=self._database_update_note_button, grid=[5, 12, 2, 1], align="left") # Window Tweaks self.window.tk.resizable(False, False) self._disable_notes_window_functions() self.checkbox_use_current_datetime.value = True self.textbox_current_note.bg = "black" self.textbox_current_note.text_color = "white" self.textbox_current_note.tk.config(insertbackground="red") if database_or_sensor == self.text_variables_generic.sensor_notes_verification: self._change_for_sensor()
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()
def __init__(self, app, ip_selection, current_config): self.ip_selection = ip_selection self.current_config = current_config self.readable_column_names = app_variables.CreateSQLColumnsReadable() self.sql_columns = app_variables.CreateSQLColumnNames() self.window = guizero.Window(app, title="Graphing", width=280, height=580, layout="grid", visible=False) self.text_sensor_type_name = guizero.Text(self.window, text="Data Source", color='blue', grid=[1, 1, 2, 1], align="top") self.radio_sensor_type = guizero.ButtonGroup( self.window, options=["Live Sensor", "SQL Database"], horizontal="True", command=self._radio_source_selection, grid=[1, 2, 2, 1], align="top") self.text_space3 = guizero.Text(self.window, text="SQL Recording Type", color="blue", grid=[1, 3, 2, 1], align="top") self.radio_recording_type_selection = guizero.ButtonGroup( self.window, options=["Interval", "Triggers"], horizontal="True", command=self._radio_sql_type_selection, grid=[1, 4, 2, 1], align="top") self.text_sensor_type_name = guizero.Text(self.window, text="Graph Options", color='blue', grid=[1, 6, 2, 1], align="top") self.text_space2 = guizero.Text(self.window, text="YYYY-MM-DD HH:MM:SS", size=7, color='#CB0000', grid=[2, 7, 2, 1], align="left") self.text_start = guizero.Text(self.window, text="Start Date & Time: ", color='green', grid=[1, 8], align="left") self.textbox_start = guizero.TextBox(self.window, text="", width=20, grid=[2, 8], align="left") self.text_end = guizero.Text(self.window, text="End Date & Time:", color='green', grid=[1, 9], align="left") self.textbox_end = guizero.TextBox(self.window, text="", width=20, grid=[2, 9], align="left") self.text_sql_skip = guizero.Text(self.window, text="Plot Data - Skip: ", color='green', grid=[1, 10], align="right") self.textbox_sql_skip = guizero.TextBox(self.window, text="", width=10, grid=[2, 10], align="left") self.text_sql_skip2 = guizero.Text(self.window, text=" Plot 1 ", color='green', grid=[2, 10], align="right") self.text_temperature_offset = guizero.Text(self.window, text="Env Temp Offset:", color='green', grid=[1, 11], align="left") self.textbox_temperature_offset = guizero.TextBox(self.window, text="", width=5, grid=[2, 11], align="left") self.checkbox_default_offset = guizero.CheckBox( self.window, text="Use Sensor\nDefault", command=self._click_checkbox_offset, grid=[2, 11], align="right") self.text_refresh_time = guizero.Text(self.window, text="Live refresh (Sec):", color='green', grid=[1, 12], align="left") self.textbox_refresh_time = guizero.TextBox(self.window, text="2", width=5, grid=[2, 12], align="left") self.checkbox_master = guizero.CheckBox(self.window, text="All Sensors", command=self._master_checkbox, grid=[1, 16, 2, 1], align="top") self.checkbox_up_time = guizero.CheckBox( self.window, text=self.readable_column_names.system_uptime, command=self._disable_other_checkboxes, args=[self.sql_columns.system_uptime], grid=[1, 17], align="left") self.checkbox_cpu_temp = guizero.CheckBox( self.window, text=self.readable_column_names.cpu_temp, command=self._disable_other_checkboxes, args=[self.sql_columns.cpu_temp], grid=[1, 18], align="left") self.checkbox_env_temperature = guizero.CheckBox( self.window, text=self.readable_column_names.environmental_temp, command=self._disable_other_checkboxes, args=[self.sql_columns.environmental_temp], grid=[1, 19], align="left") self.checkbox_pressure = guizero.CheckBox( self.window, text=self.readable_column_names.pressure, command=self._disable_other_checkboxes, args=[self.sql_columns.pressure], grid=[1, 20], align="left") self.checkbox_altitude = guizero.CheckBox( self.window, text=self.readable_column_names.altitude, command=self._disable_other_checkboxes, args=[self.sql_columns.altitude], grid=[1, 21], align="left") self.checkbox_humidity = guizero.CheckBox( self.window, text=self.readable_column_names.humidity, command=self._disable_other_checkboxes, args=[self.sql_columns.humidity], grid=[1, 22], align="left") self.checkbox_distance = guizero.CheckBox( self.window, text=self.readable_column_names.distance, command=self._disable_other_checkboxes, args=[self.sql_columns.distance], grid=[1, 23], align="left") self.checkbox_gas = guizero.CheckBox( self.window, text=self.readable_column_names.gas, command=self._disable_other_checkboxes, args=[self.sql_columns.gas], grid=[1, 24], align="left") self.checkbox_particulate_matter = guizero.CheckBox( self.window, text=self.readable_column_names.particulate_matter, command=self._disable_other_checkboxes, args=[self.sql_columns.particulate_matter], grid=[2, 17], align="left") self.checkbox_lumen = guizero.CheckBox( self.window, text=self.readable_column_names.lumen, command=self._disable_other_checkboxes, args=[self.sql_columns.lumen], grid=[2, 18], align="left") self.checkbox_colour = guizero.CheckBox( self.window, text=self.readable_column_names.colours, command=self._disable_other_checkboxes, args=[self.sql_columns.rgb], grid=[2, 19], align="left") self.checkbox_ultra_violet = guizero.CheckBox( self.window, text=self.readable_column_names.ultra_violet, command=self._disable_other_checkboxes, args=[self.sql_columns.ultra_violet], grid=[2, 20], align="left") self.checkbox_acc = guizero.CheckBox( self.window, text=self.readable_column_names.accelerometer_xyz, command=self._disable_other_checkboxes, args=[self.sql_columns.accelerometer_xyz], grid=[2, 21], align="left") self.checkbox_mag = guizero.CheckBox( self.window, text=self.readable_column_names.magnetometer_xyz, command=self._disable_other_checkboxes, args=[self.sql_columns.magnetometer_xyz], grid=[2, 22], align="left") self.checkbox_gyro = guizero.CheckBox( self.window, text=self.readable_column_names.gyroscope_xyz, command=self._disable_other_checkboxes, args=[self.sql_columns.gyroscope_xyz], grid=[2, 23], align="left") self.text_space4 = guizero.Text(self.window, text=" ", grid=[1, 35], align="right") self.button_live = guizero.PushButton( self.window, text="Create Graph", command=self._create_graph_button, grid=[1, 36, 2, 1], align="top") # Window Tweaks self.window.tk.resizable(False, False) self.checkbox_default_offset.value = 1 self._set_config() self._radio_source_selection() self._click_checkbox_offset() self.checkbox_up_time.value = 0 self.checkbox_env_temperature.value = 0 self.checkbox_pressure.value = 0 self.checkbox_humidity.value = 0 self.checkbox_lumen.value = 0 self.checkbox_colour.value = 0 # Temp disable radio box until triggers working self.radio_recording_type_selection.disable()
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") note_text = "Note: Use a custom port with Address:Port\nExamples: 10.0.1.1:1655 or sensor.location.com:4445" app_note_text = guizero.Text(app, text=note_text, grid=[1, 2, 3, 1], align="top") app_text_user = guizero.Text(app, text="Username", grid=[1, 4], align="right")
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: loop.run() except KeyboardInterrupt: end_app()
# consumer_secret = guizero.TextBox(list_of_keys_area, "consumer_secret", width=60) # access_token = guizero.TextBox(list_of_keys_area, "access_token", width=60) # access_token_secret = guizero.TextBox(list_of_keys_area, "access_token_secret", width=60) # # insert_key = guizero.PushButton(api_key_line, text="submit key", align="right") # # # one line: read from file # import_key_area = guizero.Box(app, visible=False) # api_key = guizero.TextBox(import_key_area, "./apikey.txt", width=60, align="left") # import_button = guizero.PushButton(import_key_area, text="Import", align="right") # tweet composition box tweet_composition_area = guizero.Box(app) tweet = guizero.TextBox(tweet_composition_area, text="Compose Tweet Here", height=15, width='fill', multiline=True) tweet.when_key_released = count # stats area stats_area = guizero.Box(app) # num of tweets line number_of_tweets = guizero.Text(stats_area, text="Number of Tweets: 1") tweet.when_key_released = count_tweets # wait time slider wait_time_area = guizero.Box(stats_area) wait_time_text = guizero.Text(wait_time_area, text="Seconds Between tweets:",