def new_lot(): print("new lot") STATE["LOTNAME"] = app.question("New Lot Number", "What is the lot number?") lotname = STATE["LOTNAME"] if lotname is not None and len(lotname) > 0: try: print(lotname) GPIO.remove_event_detect(40) pictures_path = Path(settings['pictures_directory']) / lotname # lot already exists check pictures_path.mkdir(parents=True, exist_ok=False) # init cameras logging.debug("Starting Camera Preview") camera.camera.start_preview() sleep(2) # capture_image(lotname ,camera) # starting conveyor turn_on_plug() # set up beam GPIO.add_event_detect(settings['beam_pin'], GPIO.BOTH, callback=beam_break_cb) # update UI destroy_kids([title_box, options_box]) destroy_kids([options_box]) title_text = Text(title_box, text=f"Lot: {lotname}", size=20, font="Arial") take_picture_button = PushButton(options_box, text="Take Picture", align="left", width="fill", height="fill", pady=20) take_picture_button.text_size = 20 take_picture_button.when_clicked = take_picture_handler except: print(traceback.format_exc()) else: app.error("No lotname", "You must enter a lot name")
def draw_init(day_window, on_off_hour_list): i = 1 count2 = 0 hours = range(0, 24) for count in hours: if count < 10: button_text = "0" + str(count) button_text2 = "0" + str(count + 1) else: button_text = str(count) button_text2 = str(count + 1) text = Text(day_window, text=button_text + ":00", size=5, grid=[count2, i], align="right") button = PushButton(day_window, text="OFF", grid=[count2 + 1, i], align="left") button.when_clicked = partial(set_hour_on_off, count, button) if on_off_hour_list[count] == "OFF": button.bg = "blue" button.text = "OFF" else: button.bg = "red" button.text = "ON" button.text_size = 5 text = Text(day_window, text=button_text2 + ":00", size=5, grid=[count2 + 2, i], align="left") count2 = count2 + 3 if count2 % 9 == 0: if i != 0: i = i + 1 count2 = 0
def open_lot(): pictures_dir = settings["pictures_directory"] file_path = filedialog.askdirectory(initialdir=pictures_dir, title="Select Lot") print(Path(file_path).stem) STATE["LOTNAME"] = Path(file_path).stem lotname = STATE["LOTNAME"] if lotname is not None and len(lotname) > 0: print(len(lotname)) # fix when nothing is selevted you get a blank folder error GPIO.remove_event_detect(40) # init camera camera.camera.start_preview( fullscreen=False, window=(settings['gui_preview_x'], settings['gui_preview_y'], settings['picture_width'], settings['picture_height'])) sleep(2) # sleep to let camera's sensors adjust # update UI destroy_kids([title_box, options_box]) destroy_kids([options_box]) title_text = Text(title_box, text=f"Lot: {lotname}", size=20, font="Arial") take_picture_button = PushButton(options_box, text="Take Picture", align="left", width="fill", height="fill", pady=20) take_picture_button.text_size = 20 take_picture_button.when_clicked = take_picture_handler GPIO.add_event_detect(settings['beam_pin'], GPIO.BOTH, callback=beam_break_cb)
btn_list.append(btn) title_box = Box(app, width="fill", align="top", border=True) text_box = TextBox(title_box, text="Copy paste text here and hit ANALYZE", width="100", height="5", multiline='True') text_box.font = "Corbel" text_box.text_size = resolution[rt]['select_box'] preprocess_checkbox = CheckBox(app, text="Analyze Raw Data", command=analyze) analyzebutton = PushButton(title_box, text="Analyze") analyzebutton.when_clicked = analyze button_box_r1 = Box(app, align="top", border=True) button_box_r2 = Box(app, align="top", border=True) button_box_r3 = Box(app, align="top", border=True) button_box_r4 = Box(app, align="top", border=True) button_box_r5 = Box(app, align="top", border=True) button_box_r6 = Box(app, align="top", border=True) button_box_r7 = Box(app, align="top", border=True) button_box_r8 = Box(app, align="top", border=True) form_box = Box(app, width="fill", border=True) form_box.text_size = resolution[rt]['form_box'] select_box = Box(app, width="fill", border=True) select_box.text_size = resolution[rt]['select_box']
text="LAMP 1", color=(52, 52, 52), width=100, height=80) lamp2_text = Text(lamp2, text="LAMP 2", color=(52, 52, 52), width=100, height=80) lamp3_text = Text(lamp3, text="LAMP 3", color=(52, 52, 52), width=100, height=80) lamp1_button = PushButton(button1, width=100, height=20, text="OK 1") lamp2_button = PushButton(button2, width=100, height=20, text="OK 2") lamp3_button = PushButton(button3, width=100, height=20, text="OK 3") light1_on = False light2_on = False light3_on = False lamp1_button.when_clicked = button1_clicked lamp2_button.when_clicked = button2_clicked lamp3_button.when_clicked = button3_clicked color_the_lamps() window.display()
#Save Images save_img_check = CheckBox(app, text="Keep images?", grid=[1, 1], align="left") Text(app, "Specify save directory:", size=10, color="#000000") save_img_dir = TextBox(app, width=20, text="/home/pi/Desktop/4-19/") #Sampling sample_freq_text = Text(app, text="Specify sample frequency:", size=10, color="#000000") sample_frequency = ButtonGroup(app, options=[["1min", "60"],["30min", "1800"], ["1hr", "3600"], ["2hr", "7200"], ["6hr", "21600"], ["12hr", "43200"]], selected="1", horizontal=True, grid=[1, 2], align="left") #Sample Volume sample_volume_box = Text(app, text="Specify sample volume (uL):", size=10, color="#000000") sample_volume = TextBox(app, width=3, text="1") #Save Button save_button = PushButton(app, text="Save Settings?") save_button.bg = "#ff4b4b" save_button.when_clicked = save_inputs input_log_name.when_clicked = reset save_img_check.when_clicked = reset save_img_dir.when_clicked = reset sample_frequency.when_clicked = reset sample_volume_box.when_clicked = reset #Calibrate Button cal_button = PushButton(app, text="Calibrate MicrobeScope") cal_button.when_clicked = calibrate #Run Button run_button = PushButton(app, text="Run MicrobeScope") run_button.when_clicked = run #Stop Button
app.tk.update() #if(SoR == "Send"): #publish to mqtt # mqtt_publish.single(button_number, text, hostname=mqtt_server_id) ############################################################################### ############################################################################### ############################### Button Functions ############################## ############################################################################### ############################################################################### # Main Page Buttons button1.when_clicked = button_1_clicked button2.when_clicked = button_2_clicked button3.when_clicked = button_3_clicked button4.when_clicked = button_4_clicked button5.when_clicked = button_5_clicked button6.when_clicked = button_6_clicked ############################################################################### ############################################################################### ############################### Show the Application ########################## ############################################################################### ############################################################################### app.set_full_screen() app.tk.update()
app = App(title="TV GUI", width=1920, height=1050) # not full HD dimensions to give space to the taskbar # Contains the buttons for the different channels channel_box = Box(app, width="fill", layout="grid", align="top", border=False) channel_box.bg = "#ecf0f1" # Defining the channel buttons button1 = PushButton(channel_box, command=load_channel_asianet, text="Asianet News", grid=[0, 0], width=27, height=5) button1.text_size = 19 button1.when_clicked = highlight1 button1.when_mouse_leaves = lowlight1 button2 = PushButton(channel_box, command=load_channel_manorama, text="Manorama News", grid=[1, 0], width=27, height=5) button2.text_size = 19 button2.when_clicked = highlight1 button2.when_mouse_leaves = lowlight1 button3 = PushButton(channel_box, command=load_channel_24news, text="24 News", grid=[2, 0], width=27,
button2.text = "off" def toggle_LED3(): LED3.toggle() time.sleep(1) if button3.text == "off": button3.text = "on" elif button3.text == "on": button3.text = "off" app = App() #app initialiseren button1 = PushButton(app, text="off", align="left") #knoppen aanmaken button2 = PushButton(app, text="off", align="left") button3 = PushButton(app, text="off", align="left") button1.when_clicked = toggle_LED1 #knoppen functionaliteit geven button2.when_clicked = toggle_LED2 button3.when_clicked = toggle_LED3 app.display() #app laten zien if __name__ == '__main__': # code to execute if called from command-line PROCESS_ONE = multiprocessing.Process(target=toggle_Led1) PROCESS_TWO = multiprocessing.Process(target=toggle_Led2) PROCESS_THREE = multiprocessing.Process(target=toggle_Led3) PROCESS_ONE.start() PROCESS_TWO.start() PROCESS_THREE.start()
height=5, grid=[0, 4]) button6 = PushButton(windowBox, text=button6Text, width=20, height=5, grid=[1, 4]) button1.text_size = 20 button2.text_size = 20 button3.text_size = 20 button4.text_size = 20 button5.text_size = 20 button6.text_size = 20 button1.when_clicked = punjac1 button2.when_clicked = punjac2 button3.when_clicked = punjac3 button4.when_clicked = punjac4 button5.when_clicked = punjac5 button6.when_clicked = punjac6 activationButton = PushButton(box, text=reklamniText, width=50, height=20, grid=[0, 0, 3, 1]) activationButton.bg = "white" activationButton.text_size = 30 activationButton.repeat(1000, print1) # update reklame activationButton.when_clicked = setupScreen
txt = Text(settings_box, text=f"{key}", grid=[0, i], align="left", size=16) txtBox = TextBox(settings_box, text=f"{value}", grid=[1, i], align="left", width=30) txtBox.text_size = 16 i = i + 1 save_btn = PushButton(settings_window, text="Save", align="left", width="fill", height="fill", pady=20) save_btn.when_clicked = save_btn_handler save_btn.text_size = 20 cancel_btn = PushButton(settings_window, text="Cancel", align="left", width="fill", height="fill", pady=20) cancel_btn.when_clicked = cancel_btn_handler cancel_btn.text_size = 20 view_pictures_window = Window(app, title="Pictures") view_pictures_window.hide() # init the menu bar menubar = MenuBar(app,