def spin_up_main_buttons(parent, commands): global buttons_box buttons_box = Box(parent, width='fill', height='fill', layout='auto') scan_in_button = PushButton(buttons_box, text='SCAN IN', height='fill', width='fill') scan_in_button.font = display_config.text_font scan_in_button.text_color = '#00FF21' scan_in_button.text_size = display_config.button_text_size scan_in_button.update_command(commands[0]) scan_out_button = PushButton(buttons_box, text='SCAN OUT', height='fill', width='fill') scan_out_button.font = display_config.text_font scan_out_button.text_color = '#B60000' scan_out_button.text_size = display_config.button_text_size scan_out_button.update_command(commands[1]) look_up_button = PushButton(buttons_box, text='LOOKUP', height='fill', width='fill') look_up_button.font = display_config.text_font look_up_button.text_color = '#FFD800' look_up_button.text_size = display_config.button_text_size look_up_button.update_command(commands[2])
def main(): global ledButton # App app = App(title="Project house", height=400, width=400) # Boxes displayBox = Box(app, border=True, height=35, width=400) buttonBox = Box(app, layout="grid", align="top") # Title title = Text(displayBox, text="Push a button") title.text_size = 20 # Buttons ledButton = PushButton(buttonBox, toggle_led, text="LED ON", grid=[0, 0]) ledButton.text_size = 25 blinkButton = PushButton(buttonBox, led_blink, text="Push to party", grid=[10, 0]) blinkButton.text_size = 25 exitButton = PushButton(app, exit_app, text="EXIT", align="bottom", width=16, height=2) exitButton.text_size = 32 app.display()
def game(): global app, questions, answers, correct_answers, qnum, questionText, btn1, btn2, btn3, btn4, nextBtn eh.light.on() questionText = Text(app, questions[qnum]) questionText.text_size = 40 buttons_box = Box(app, width="fill", align="top") btn1 = PushButton(buttons_box, text=answers[qnum][0], align="left") btn1.bg = "blue" btn1.text_color = "white" btn1.text_size = 40 btn2 = PushButton(buttons_box, text=answers[qnum][1], align="left") btn2.bg = (209, 182, 16) btn2.text_color = "white" btn2.text_size = 40 btn3 = PushButton(buttons_box, text=answers[qnum][2], align="left") btn3.bg = "red" btn3.text_color = "white" btn3.text_size = 40 btn4 = PushButton(buttons_box, text=answers[qnum][3], align="left") btn4.bg = "green" btn4.text_color = "white" btn4.text_size = 40 nextBtn = PushButton(app, command=nextQ, text="Next", align="left")
def get_hip(): window = Window(app, title="R&B", height="320", width="480", bg="light slate blue") window.tk.attributes("-fullscreen", True) def play_hiphop(): get_files(directories[6], window) def play_classicrb(): get_files(directories[7], window) def close_get_hip(): window.hide() welcome_message = Text(window, text="R&B", size=30, font="Arial", color="white", align="top") hiphop_button = PushButton(window, command=play_hiphop, text="Hip Hop", align="left") hiphop_button.text_color = "purple4" hiphop_button.text_size = "12" hiphop_button.font = "Arial" hiphop_button.bg = "white" classicrb_button = PushButton(window, command=play_classicrb, text="Classic R & B", align="right") classicrb_button.text_color = "purple4" classicrb_button.text_size = "12" classicrb_button.font = "Arial" classicrb_button.bg = "white" close_get_hip = PushButton(window, text="go back", command=close_get_hip, align="bottom") close_get_hip.text_color = "purple4" close_get_hip.text_size = "12" close_get_hip.font = "Arial" close_get_hip.bg = "white"
def spin_up_edit_button(parent, command): global new_item_confirm_button new_item_confirm_button = PushButton(parent, text='DONE', command=command, width='fill', grid=[3, 4, 1, 2], align='left') new_item_confirm_button.font = display_config.text_font new_item_confirm_button.text_color = '#00FF21' new_item_confirm_button.text_size = display_config.text_size new_item_confirm_button.hide()
def question3(): global sb, txt, qth qth = Window(app, title="Question Three", width=800, height=400) qth.show() print("start question 3") txt = Text(qth, text="Hold the screen out in front of you") txt.text_size = 40 txt.text_color = 'magenta' sb = PushButton(qth, text="Begin", padx=240, pady=80, command=balancetest) sb.bg = 'green' sb.text_size = 100
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 make_main(): global main_box global welcome_message global initial_box main_box = Box(app, layout="auto") welcome_message = Text(main_box, text="Choose Method of Entry", size=20) #box to hold 2 buttons initial_box = Box(main_box, layout="grid") enter_code = PushButton(initial_box, grid=[0, 0], text="Enter Code", command=onclick_code, padx=30, pady=30) enter_code.text_size = 20 nfc = PushButton(initial_box, grid=[0, 1], text="NFC", command=onclick_nfc, padx=77, pady=30) nfc.text_size = 20
def spin_up_confirm_widget(parent): global question # question = Text(parent, text='Item not known!\r\rWould you like to enter missing values?') question = Text(parent) question.font = display_config.text_font question.text_size = display_config.text_size question.text_color = display_config.text_color question.height = 4 global buttons_box buttons_box = Box(parent) global yes_button yes_button = PushButton(buttons_box, text='Yes', align='left', width=5) yes_button.font = display_config.text_font yes_button.text_color = '#00FF21' yes_button.text_size = display_config.button_text_size global no_button no_button = PushButton(buttons_box, text='No', align='right', width=5) no_button.font = display_config.text_font no_button.text_color = '#B60000' no_button.text_size = display_config.button_text_size
def createButton(box, def_text_size, def_colour, text='', command=passFunction, args=[], grid=[]): width = 15 height = 1 b1 = PushButton(box, text=text, command=command, args=args, grid=grid, width=width, height=height, align='left') b1.text_size = def_text_size b1.text_color = def_colour
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)
def Make_keys(): global Keyboard_box global keys_exist global uppercase global lower_letters if (keys_exist == 0): Weather_drawing.grid = [0, 7, 2, 1] Keyboard_box = Box(app, width=500, height=300, layout="grid", grid=[0, 6, 4, 1]) keys_exist = 1 uppercase = 0 elif (keys_exist == 1 and uppercase == 1): Keyboard_box.destroy() Keyboard_box = Box(app, width=500, height=300, layout="grid", grid=[0, 6, 2, 1]) uppercase = 0 #Keyboard #1st Row Q_button = PushButton(Keyboard_box, grid=[0, 0], width=2, height=2, text=lower_letters[0], command=type_function, args=lower_letters[0]) Q_button.bg = "light gray" Q_button.text_size = 10 W_button = PushButton(Keyboard_box, grid=[1, 0], width=2, height=2, text=lower_letters[1], command=type_function, args=lower_letters[1]) W_button.bg = "light gray" W_button.text_size = 10 E_button = PushButton(Keyboard_box, grid=[2, 0], width=2, height=2, text=lower_letters[2], command=type_function, args=lower_letters[2]) E_button.bg = "light gray" E_button.text_size = 10 R_button = PushButton(Keyboard_box, grid=[3, 0], width=2, height=2, text=lower_letters[3], command=type_function, args=lower_letters[3]) R_button.bg = "light gray" R_button.text_size = 10 T_button = PushButton(Keyboard_box, grid=[4, 0], width=2, height=2, text=lower_letters[4], command=type_function, args=lower_letters[4]) T_button.bg = "light gray" T_button.text_size = 10 Y_button = PushButton(Keyboard_box, grid=[5, 0], width=2, height=2, text=lower_letters[5], command=type_function, args=lower_letters[5]) Y_button.bg = "light gray" Y_button.text_size = 10 U_button = PushButton(Keyboard_box, grid=[6, 0], width=2, height=2, text=lower_letters[6], command=type_function, args=lower_letters[6]) U_button.bg = "light gray" U_button.text_size = 10 I_button = PushButton(Keyboard_box, grid=[7, 0], width=2, height=2, text=lower_letters[7], command=type_function, args=lower_letters[7]) I_button.bg = "light gray" I_button.text_size = 10 O_button = PushButton(Keyboard_box, grid=[8, 0], width=2, height=2, text=lower_letters[8], command=type_function, args=lower_letters[8]) O_button.bg = "light gray" O_button.text_size = 10 P_button = PushButton(Keyboard_box, grid=[9, 0], width=2, height=2, text=lower_letters[9], command=type_function, args=lower_letters[9]) P_button.bg = "light gray" P_button.text_size = 10 #2nd Row A_button = PushButton(Keyboard_box, grid=[0, 1, 2, 1], width=2, height=2, text=lower_letters[10], command=type_function, args=lower_letters[10]) A_button.bg = "light gray" A_button.text_size = 10 S_button = PushButton(Keyboard_box, grid=[1, 1, 2, 1], width=2, height=2, text=lower_letters[11], command=type_function, args=lower_letters[11]) S_button.bg = "light gray" S_button.text_size = 10 D_button = PushButton(Keyboard_box, grid=[2, 1, 2, 1], width=2, height=2, text=lower_letters[12], command=type_function, args=lower_letters[12]) D_button.bg = "light gray" D_button.text_size = 10 F_button = PushButton(Keyboard_box, grid=[3, 1, 2, 1], width=2, height=2, text=lower_letters[13], command=type_function, args=lower_letters[13]) F_button.bg = "light gray" F_button.text_size = 10 G_button = PushButton(Keyboard_box, grid=[4, 1, 2, 1], width=2, height=2, text=lower_letters[14], command=type_function, args=lower_letters[14]) G_button.bg = "light gray" G_button.text_size = 10 H_button = PushButton(Keyboard_box, grid=[5, 1, 2, 1], width=2, height=2, text=lower_letters[15], command=type_function, args=lower_letters[15]) H_button.bg = "light gray" H_button.text_size = 10 J_button = PushButton(Keyboard_box, grid=[6, 1, 2, 1], width=2, height=2, text=lower_letters[16], command=type_function, args=lower_letters[16]) J_button.bg = "light gray" J_button.text_size = 10 K_button = PushButton(Keyboard_box, grid=[7, 1, 2, 1], width=2, height=2, text=lower_letters[17], command=type_function, args=lower_letters[17]) K_button.bg = "light gray" K_button.text_size = 10 L_button = PushButton(Keyboard_box, grid=[8, 1, 2, 1], width=2, height=2, text=lower_letters[18], command=type_function, args=lower_letters[18]) L_button.bg = "light gray" L_button.text_size = 10 #3rd Row shift_button = PushButton(Keyboard_box, grid=[0, 2, 2, 1], align="left", width=2, height=2, padx=15, pady=10, text="Shift", command=Make_upperkeys) shift_button.bg = "light gray" shift_button.text_size = 10 Z_button = PushButton(Keyboard_box, grid=[1, 2, 2, 1], width=2, height=2, text=lower_letters[19], command=type_function, args=lower_letters[19]) Z_button.bg = "light gray" Z_button.text_size = 10 X_button = PushButton(Keyboard_box, grid=[2, 2, 2, 1], width=2, height=2, text=lower_letters[20], command=type_function, args=lower_letters[20]) X_button.bg = "light gray" X_button.text_size = 10 C_button = PushButton(Keyboard_box, grid=[3, 2, 2, 1], width=2, height=2, text=lower_letters[21], command=type_function, args=lower_letters[21]) C_button.bg = "light gray" C_button.text_size = 10 V_button = PushButton(Keyboard_box, grid=[4, 2, 2, 1], width=2, height=2, text=lower_letters[22], command=type_function, args=lower_letters[22]) V_button.bg = "light gray" V_button.text_size = 10 B_button = PushButton(Keyboard_box, grid=[5, 2, 2, 1], width=2, height=2, text=lower_letters[23], command=type_function, args=lower_letters[23]) B_button.bg = "light gray" B_button.text_size = 10 N_button = PushButton(Keyboard_box, grid=[6, 2, 2, 1], width=2, height=2, text=lower_letters[24], command=type_function, args=lower_letters[24]) N_button.bg = "light gray" N_button.text_size = 10 M_button = PushButton(Keyboard_box, grid=[7, 2, 2, 1], width=2, height=2, text=lower_letters[25], command=type_function, args=lower_letters[25]) M_button.bg = "light gray" M_button.text_size = 10 backspace_button = PushButton(Keyboard_box, grid=[8, 2, 2, 1], align="right", width=2, height=2, padx=15, pady=10, text="<-", command=type_function, args=lower_letters[27]) backspace_button.bg = "light gray" backspace_button.text_size = 10 #4th Row Space_button = PushButton(Keyboard_box, grid=[2, 3, 6, 1], width=28, height=2, padx=5, pady=1, text="Space", command=type_function, args=lower_letters[26]) Space_button.bg = "light gray" Space_button.text_size = 10 Hide_button = PushButton(Keyboard_box, grid=[8, 3, 6, 1], width=5, height=2, padx=5, pady=1, text="Hide", command=Destroy_keys) Hide_button.text_size = 10 Hide_button.bg = "light gray"
def servo_two_movement(slider_value): servo_two.angle = int(slider_value) def pwm_one(slider_value): en_1.value = int(slider_value) / 10 def pwm_two(slider_value): en_2.value = int(slider_value) / 10 # Define the buttons for movement # Forward button for Linus button1 = PushButton(app, text="f", grid=[0, 0]) button1.text_size = 20 button1.bg = "green" button1.when_left_button_pressed = direction_one button1.when_left_button_released = stop #Backward Button for Linus button2 = PushButton(app, text="b", grid=[1, 0]) button2.text_size = 20 button2.bg = "green" button2.when_left_button_pressed = direction_two button2.when_left_button_released = stop # Forward button for Torvalds button3 = PushButton(app, text="n", grid=[2, 0]) button3.text_size = 20 button3.bg = "red" button3.when_left_button_pressed = north button3.when_left_button_released = stop_two
def questiontwo(): global timelimit qt = Window(app, layout="grid", title="Question Two", width=800, height=400) qt.show() print("start question 2") f1 = Box(qt, width=100, height=400, grid=[0, 1]) f1.border = 1 f1.bg = "black" f2 = Box(qt, width=100, height=400, grid=[1, 1]) f2.border = 1 f2.bg = "black" f3 = Box(qt, width=100, height=400, grid=[3, 1]) f3.border = 1 f3.bg = "black" f4 = Box(qt, width=100, height=400, grid=[4, 1]) f4.border = 1 f4.bg = "black" f5 = Box(qt, width=100, height=400, grid=[5, 1]) f5.border = 1 f5.bg = "black" f6 = Box(qt, width=100, height=400, grid=[6, 1]) f6.border = 1 f6.bg = "black" f7 = Box(qt, width=100, height=400, grid=[7, 1]) f7.border = 1 f7.bg = "black" f8 = Box(qt, width=100, height=400, grid=[8, 1]) f8.border = 1 f8.bg = "black" bl = [f1, f3, f5, f7] x = 0 for i in range(1, randint(1, 4)): bl[i - 1].bg = "yellow" x = i print(x) qt.update() sleep(7.35478205493597) f1.visible = False f2.visible = False f3.visible = False f4.visible = False f5.visible = False f6.visible = False f7.visible = False f8.visible = False bo2 = Box(qt, width=800, height=80, grid=[0, 1], layout="grid") bo2.border = 1 b2pp = Box(qt, width=790, height=100, layout="grid", grid=[0, 2]) b2pp.border = 1 questiotwo = Text(qt, text="How many yellow lines were there?", grid=[0, 0]) questiotwo.text_size = 38 answer1 = PushButton(b2pp, grid=[0, 2], command=checknumber, height=2, width=9, text="One") answer1.text_size = 21 answer1.bg = 'red' answer1.update_command(checknumber, args=['1', x]) answer2 = PushButton(b2pp, grid=[1, 2], command=checknumber, height=2, width=9, text="Two") answer2.text_size = 21 answer2.bg = 'orange' answer2.update_command(checknumber, args=['2', x]) answer3 = PushButton(b2pp, grid=[2, 2], command=checknumber, height=2, width=9, text="Three") answer3.text_size = 21 answer3.bg = 'yellow' answer3.update_command(checknumber, args=['3', x]) answer4 = PushButton(b2pp, grid=[3, 2], command=checknumber, height=2, width=9, text="Four") answer4.text_size = 21 answer4.bg = 'green' answer4.update_command(checknumber, args=['4', x]) answer5 = PushButton(b2pp, grid=[0, 3], command=checknumber, height=2, width=9, text="Five") answer5.text_size = 21 answer5.bg = 'brown' answer5.update_command(checknumber, args=['5', x]) answer6 = PushButton(b2pp, grid=[1, 3], command=checknumber, height=2, width=9, text="Six") answer6.text_size = 21 answer6.bg = 'grey' answer6.update_command(checknumber, args=['6', x]) answer7 = PushButton(b2pp, grid=[2, 3], command=checknumber, height=2, width=9, text="Zero") answer7.text_size = 21 answer7.bg = 'purple' answer7.update_command(checknumber, args=['0', x]) answer8 = PushButton(b2pp, grid=[3, 3], command=checknumber, height=2, width=9, text="Dunno") answer8.text_size = 21 answer8.bg = 'blue' answer8.update_command(checknumber, args=['7', x]) timelimit = time()
def exitApp(): sys.exit() def toggleLED(): led.toggle() if led.is_lit: ledButton.text = "LED OFF" else: ledButton.text = "LED ON" app = App('First Gui', height=600, width=800) ledButton = PushButton(app, toggleLED, text="LED ON", align="top", width=15, height=3) ledButton.text_size = 36 exitButton = PushButton(app, exitApp, text="Exit", align="bottom", width=15, height=3) exitButton.text_size = 36 app.display()
player_sel.text_color = "white" player_sel.text_size=14 Box(app,width=10,height=5,grid=[0,0]) # second_message = Text(app, "Please select a drill: ", size=14, font="Calibri Bold", color="green",grid=[1,1,2,1]) # logo = Picture(app, image="include/images/logo.png", align="left", grid=[0,0]) # logo.resize(75, 75) # logoright = Picture(app, image="include/images/logo.png", align="left", grid=[3,0]) # logoright.resize(75, 75) button_width = 17 print('looping') drill_1 = PushButton(app, command=gui_app().staticDrill, args=[app] ,text="Basic Tracking", grid=[1,2],width=17) drill_1.width = button_width drill_1.font="Calibri Bold" drill_1.bg="#006868" drill_1.text_color="white" drill_1.text_size = 14 drill_2 = PushButton(app, command=gui_app().predictiveDrill,args=[app], text="Predictive Tracking",grid=[2,2],width=17) drill_2.width = button_width drill_2.font="Calibri Bold" drill_2.bg="#006868" drill_2.text_color="white" drill_2.text_size=14 drill_3 = PushButton(app, command=gui_app().manualDrill,args=[app], text="VC w/Basic Tracking",grid=[1,3],width=17) drill_3.width = button_width drill_3.font="Calibri Bold" drill_3.bg="#006868" drill_3.text_color="white" drill_3.text_size=14
'Pamala', 'Suzy', 'Albert', 'Joel', 'Thomas', 'Marie', 'Jennie', ] last_names = [ 'Stevenson', 'Hackenbush', 'WonderFred', 'TotallyARealName', 'Not Suspicious', 'F**k', 'Dixon', 'Packer', 'Jobs' ] spy_name = choice(first_names) + ' ' + choice(last_names) name.value = spy_name # App ------------------- app = App("TOP SECRET: DON'T BLAB") # Widgets --------------- title = Text(app, "Push the red button to find out your spy name") button = PushButton(app, choose_name, text='Your Destiny') button.bg = 'red' button.text_size = 20 name = Text(app, text='') # Display --------------- app.display()
camera.framerate = 25 devastator_eye = LED(25) # Define the functions def capture_camera(): devastator_eye.on() moment = datetime.now() camera.start_recording("/home/pi/video_%02d_%02d_%02d.mjpg" % (moment.hour, moment.minute, moment.second)) def stop_record(): devastator_eye.off() camera.stop_recording() # Define the app app = App("PiCamera Recording") app.bg = (45, 232, 225) camera_text = Text(app, text="Camera recording", size=20) # Create the buttons to record and stop recording record = PushButton(app, command=capture_camera, text="Record") record.bg = "green" record.text_size = 20 stop = PushButton(app, command=stop_record, text="Stop") stop.bg = "red" stop.text_size = 20 # Display the app app.display()
# LeftBox listBoxTitle = Text(left_box, "All Work Orders", grid=[0,0], size=16, color="Dark Blue",\ font="Quicksand Medium") instructions = Text(left_box, "click to add boat to Today's List", grid=[0,1], color="Dark Blue") fullList = ListBox(left_box, items = boatlist, command = write_wo, width = 500, height = 345, grid=[0,2],\ scrollbar=True) fullList.bg = (200, 230, 255) fullList.text_size = 16 fullList.tk.children["!scrollbar"].config(width=25) # access the tkinter object to resize the scrollbar fullList._listbox.resize(None, None) # to show scrollbar, reset internal listbox size fullList._listbox.resize("fill", "fill") # now fill available space # Missing Name Button infobutton = PushButton(left_box, text = "Missing Name?", padx=5, command = info_button, align="bottom", grid=[0,3]) infobutton.text_color = "Dark Blue" infobutton.text_size = 14 infobutton.bg = (110, 170, 255) # RightBox todaysList = Text(right_box, text="Today's List", size=16, color="Dark Blue", font="Quicksand Medium") listInstruct = Text(right_box, text="click to remove boat from Today's List", color="Dark Blue") display = ListBox(right_box, items = todays_boats, command = delete_name ,\ width = 350, height = 345, scrollbar=True) display.bg = (200, 230, 255) display.text_size=16 display.tk.children["!scrollbar"].config(width=25) # access the tkinter object to resize the scrollbar display._listbox.resize(None, None) # to show scrollbar, reset internal listbox size display._listbox.resize("fill", "fill") # now fill available space finished = PushButton(right_box, text = "Finished", padx=50, command = close_window, align="bottom") finished.text_color = "Dark Blue"
textbox = TextBox(b, text="or colours") bgroup = ButtonGroup(b, ["cheese", "ham", "salad"], 1) #a.bg = (255,255,0) text.text_color = "red" text.text_size = 30 text.font = "verdana" #text.bg = "green" check.bg = "#d41789" combo.bg = "blue" combo.text_color = None combo.text_size = 24 #button.bg = "black" button.text_color = (255, 0, 255) button.font = "arial" button.text_size = 18 slider.bg = (123, 234, 12) #textbox.bg = "cyan" textbox.font = "courier" textbox.text_color = "#FF0000" b.bg = "cyan" b.font = "wingdings" #bgroup.bg = "yellow" bgroup.text_color = "#e62112" bgroup.text_color = None bgroup.font = "book antiqua" #a.bg = (255,0,25) #a.font = "wingdings" a.text_color = (255, 253, 12) b.text_color = "purple"
startScr, text=" ", size=50, ) startBtn = PushButton( startScr, text="Start Game", command=gotoScreen0, padx=0, pady=0, ) startBtn.bg = "#e0e0e0" #light grey startBtn.width = 25 startBtn.height = 1 startBtn.text_size = 15 Text(startScr, text=" ", size=5) howToBtn = PushButton( startScr, text="How to Play", command=howTo, padx=0, pady=0, ) howToBtn.bg = "#e0e0e0" #light grey howToBtn.width = 25 howToBtn.height = 1 howToBtn.text_size = 15
from guizero import App, Text, PushButton from random import choice # Functions ------------------ def choose_name(): #print("Button was pressed") first_names = [ "Barbara", "Woody", "Tiberius", "Smokey", "Jennifer", "Ruby" ] last_names = [ "Spindleshanks", "Mysterioso", "Dungeon", "Catseye", "Darkmeyer", "Flamingobreath" ] spy_name = choice(first_names) + " " + choice(last_names) #print(spy_name) name.value = spy_name # App ------------------------ app = App("Top Secret") # Widgets -------------------- title = Text(app, "Push the red button to find out your spy name") button = PushButton(app, choose_name, text="Tell me!") button.bg = "red" button.text_size = 30 name = Text(app, text="") # Display -------------------- app.display()
def start(): print('start') global timelimit sleep(0.5) button.hide() box = Box(app, width=800, height=80, grid=[0, 1], layout="grid") box.border = 1 bapp = Box(app, width=790, height=100, layout="grid", grid=[0, 2]) bapp.border = 1 questionone = Text(app, text="What day is it today?", grid=[0, 0]) questionone.text_size = 40 monday = PushButton(bapp, grid=[0, 2], command=checkday, height=2, width=9, text="Monday") monday.text_size = 21 monday.bg = 'red' monday.update_command(checkday, args='0') tuesday = PushButton(bapp, grid=[1, 2], command=checkday, height=2, width=9, text="Tuesday") tuesday.text_size = 21 tuesday.bg = 'orange' tuesday.update_command(checkday, args='1') wednesday = PushButton(bapp, grid=[2, 2], command=checkday, height=2, width=9, text="Wednesday") wednesday.text_size = 21 wednesday.bg = 'yellow' wednesday.update_command(checkday, args='2') thursday = PushButton(bapp, grid=[3, 2], command=checkday, height=2, width=9, text="Thursday") thursday.text_size = 21 thursday.bg = 'green' thursday.update_command(checkday, args='3') friday = PushButton(bapp, grid=[0, 3], command=checkday, height=2, width=9, text="Friday") friday.text_size = 21 friday.bg = 'brown' friday.update_command(checkday, args='4') saturday = PushButton(bapp, grid=[1, 3], command=checkday, height=2, width=9, text="Saturday") saturday.text_size = 21 saturday.bg = 'grey' saturday.update_command(checkday, args='5') sunday = PushButton(bapp, grid=[2, 3], command=checkday, height=2, width=9, text="Sunday") sunday.text_size = 21 sunday.bg = 'purple' sunday.update_command(checkday, args='6') dunno = PushButton(bapp, grid=[3, 3], command=checkday, height=2, width=9, text='Dunno?') dunno.text_size = 21 dunno.bg = 'blue' dunno.update_command(checkday, args='7') app.update() timelimit = time()
from guizero import App, Text, Picture, PushButton, MenuBar, Slider, CheckBox, Combo app = App() text = Text(app, align="bottom", text="This is GUI", color="blue", font="Times New Roman", size="70") def do_somthing(): print("you have a button") picture = Picture(app, image="Image.gif") def do_something(): print("you did something else") menubar = MenuBar(app, toplevel=["file", "edit", "settings", "window"], options=[ [["File Option 1", do_something], ["file Option 2", do_something]], [["edit Option 1", do_somthing], ["edit Option 2", do_somthing]], [["settings Option 1", do_somthing], ["settings Option 2", do_somthing]], [["Window Option 1", do_somthing], ["Window Option 2", do_somthing]], ]) button = PushButton(app, text="Push me!", align="right", width="3", height="2", command=do_somthing) button.text_color = "blue" button.text_size = "50" slider = Slider(app, end="200") checkbox = CheckBox(app, text="tick box") combo = Combo(app, options=["first", "Second", "Third"]) app.display()
text=" Select Roast", grid=[0, 2], align="left", size=40, font="Helvetica") Text1 = Text(window1, text=" Operation", grid=[0, 3], align="left", size=40, font="Helvetica") space = Text(window1, text="", grid=[0, 4], size=15) box = Box(window1, layout="grid", grid=[0, 5]) space = Text(box, text=" ", grid=[0, 0], size=20) windowclose = PushButton(box, text="MANUAL", command=start_manual, grid=[1, 0], align="left") windowclose.bg = "yellow2" windowclose.height = 3 windowclose.width = 8 windowclose.text_size = 20 space = Text(box, text=" ", grid=[2, 0], size=20) windowclose = PushButton(box, text="AUTO", command=start_auto, grid=[3, 0]) windowclose.bg = "lawn green" windowclose.height = 3 windowclose.width = 8 windowclose.text_size = 20 app.display()
startScr, text=" ", size=50, ) startBtn = PushButton( startScr, text="Start Game", command=gotoScreen0, padx=0, pady=0, ) startBtn.bg = "#e0e0e0" #light grey startBtn.width = 25 startBtn.height = 1 startBtn.text_size = 15 endBtnSpacer = Text(startScr, text=" ", size=25, align="bottom") endBtn = PushButton( startScr, text="Quit", command=windowClose, align="bottom", padx=0, pady=0, ) endBtn.width = 10 endBtn.height = 1 endBtn.text_color = "#ffffff" #white
size=24, align="bottom", height="fill", width="fill", text="--:--") # Button box buttons_box = Box(app, width="fill", height="fill", align="top", border=True) manual_feed_toggle_button = PushButton(buttons_box, align="left", text="Toggle Feed", width="fill", height="fill") manual_feed_toggle_button.bg = BLUE manual_feed_toggle_button.text_color = WHITE manual_feed_toggle_button.text_size = BUTTON_TEXT_SIZE manual_feed_toggle_button.when_left_button_pressed = manual_feed_toggle manual_feed_toggle_button.when_left_button_released = manual_feed_toggle manual_single_feed_button = PushButton(buttons_box, align="right", text="Manual Feed", width="fill", height="fill", command=manual_single_feed) manual_single_feed_button.bg = BLUE manual_single_feed_button.text_color = WHITE manual_single_feed_button.text_size = BUTTON_TEXT_SIZE # Status box status_box = Box(app, width="fill", height="fill", align="bottom", border=True)
time_add_button = PushButton(app, command=time_add_button_clicked, text="+", grid=[3, 2], width=time_button_width, height=element_height) exit_button = PushButton(app, command=exit_button_clicked, text="X", grid=[3, 0], width=exit_button_size, height=exit_button_size, align="top") # Set buttons text size motor_button.text_size = font_size motor_button.text_color = text_color_default pump_button.text_size = font_size pump_button.text_color = text_color_default cancel_hold_button.text_size = font_size cancel_hold_button.text_color = text_color_default time_subs_button.text_size = font_size time_subs_button.text_color = text_color_default time_add_button.text_size = font_size time_add_button.text_color = text_color_default motor_text.text_color = text_color_inactive pump_text.text_color = text_color_inactive time_text.text_color = text_color_inactive parser = argparse.ArgumentParser()
#cumulative_counting =Text(app, text="0", size=14, grid=[4,7,1,1], align="left") #cumulative_counting.text_color= "black" #cumulative_counting.repeat (10,normalCounting) # Text Box # input_target = TextBox(app, text="", grid=[1, 3, 3, 1]) input_target.text_size = 30 input_target.bg = "white" # Keypad # button1 = PushButton(app, Keypad_1, text="1", grid=[1, 4, 1, 1]) button1.bg = "black" button1.text_color = "white" button1.width = 5 button1.height = 2 button1.text_size = 15 button2 = PushButton(app, Keypad_2, text="2", grid=[2, 4, 1, 1]) button2.bg = "black" button2.text_color = "white" button2.width = 5 button2.height = 2 button2.text_size = 15 button3 = PushButton(app, Keypad_3, text="3", grid=[3, 4, 1, 1]) button3.bg = "black" button3.text_color = "white" button3.width = 5 button3.height = 2 button3.text_size = 15 button4 = PushButton(app, Keypad_4, text="4", grid=[1, 5, 1, 1]) button4.bg = "black" button4.text_color = "white"