def new_thread(conn, chat_num): def ending(): app.destroy() def getinit(): data = conn.recv(4096) if not data: print_lock.release() app.destroy() if data.decode('ascii') == 'exit': print_lock.release() prompt.value = 'Patient has ended the chat session.\nPlease close this window.' app.disable() history4.value = "Patient: %s" % (data.decode('ascii')) prompt.value = "What is your message?" goahead.enable() def push(): def checknew(): data = conn.recv(4096) history1.value = history2.value history2.value = history3.value history3.value = history4.value history4.value = "Patient: %s" % (data.decode('ascii')) if data.decode('ascii') == 'exit': print_lock.release() prompt.value = "Patient has ended the chat session.\nPlease close this window." app.disable() conn.send(message.value.encode('ascii')) if message.value == 'exit': app.destroy() history1.value = history2.value history2.value = history3.value history3.value = history4.value history4.value = "You: %s" % (message.value) message.clear() checknew() app = App(title="Chat") nummessage = "Chat with patient number: %d" % (chat_num) chatnum = Text(app, text=nummessage) toptext = Text(app, text='Type "exit" at any time to leave this chat') history1 = Text(app, text="") history2 = Text(app, text="") history3 = Text(app, text="") history4 = Text(app, text="") prompt = Text(app, text="Waiting for message...") message = TextBox(app, width=25) goahead = PushButton(app, text="Send", command=push) goahead.disable() app.after(10, getinit) app.display() conn.close()
b_four = PushButton(box2, grid=[3,1], text="d", width=2, height=1) b_four.when_left_button_pressed = lambda:call(1,b_four,m1,textbox1,c_slider_val_1) b_four.when_left_button_released = lambda:call_stop(1, b_four) Text(box2, grid=[4,0], text=" ") b_five = PushButton(box2, grid=[5,0], text="e", width=2, height=1) b_five.when_left_button_pressed = lambda:call(1,b_five,m3,textbox3,c_slider_val_3) b_five.when_left_button_released = lambda:call_stop(1,b_five) b_six = PushButton(box2, grid=[5,2], text="f", width=2, height=1) b_six.when_left_button_pressed = lambda:call(2,b_six,m3,textbox3,c_slider_val_3) b_six.when_left_button_released = lambda:call_stop(2,b_six) Text(box2, grid=[5,3], text="") Text(box2, grid=[5,5], text="Step size") StepSize=TextBox(box2, grid=[5,4], text="1") StepSize.bg=(184,228,197) box_ss = Box(app, grid=[2,1]) Text(box_ss, text=" ") box_img = Box(app,grid=[0,2]) picture = Picture(box_img, image="dw.png") app.after(1,c_slider_val_1) app.after(1,c_slider_val_2) app.after(1,c_slider_val_3) app.display()
if selection.value == "1": info("well done", "you chose wisely") goodbye() else: warn("arrrgh", "next time, choose wisely!") app.after(2000, show_the_selection) def goodbye(): change_message("Thanks") logo.show() # create the app and the widgets app = App() message_text = Text(app, text="Welcome to guizero") button = PushButton(app, clicked_the_button, text="Click me") button.hide() selection = ButtonGroup(app, selected=0, command=selection_chosen, options=["choose me", "don't choose me"]) selection.hide() logo = Picture(app, "guizero.gif") logo.hide() # show the first message after 2 seconds app.after(2000, message1) app.display()
def hi(): print("Hi") def message(my_message): print(my_message) def whatever(): # say whatever using the message function, passing the text as an argument app.after(200, message, args=["Whatever"]) def cancel_hi(): app.cancel(hi) app = App() # create some buttons hi_button = PushButton(app, cancel_hi, text="Stop hi") what_button = PushButton(app, whatever, text="Whatever") # after a very short pause, say welcome app.after(10, welcome) # keep repeating hi, until it is cancelled app.repeat(1000, hi) app.display()
# This module is the main file used to initialize all the # other modules in this project and create the main app # that all other windows belong to. # If the card database does not exist or isn't completed, # then this app window displays the text output from this # process as the necessary data is downloaded. When the # database is completed or simply loaded from memory, then # the sorting window is opened and ready for the user to # operate it. #endregion #region Initialization app = App(title="Card Sorter Updater", height=50) text = Text(app, text="Downloading...") cd = None def start_program(): cd = card_database.CardDatabase(app, text) tw = test_window.TestWindow(app) scw = scanner_window.ScannerWindow(app, cd) sow = sorting_window.SortingWindow(app, text, cd, tw, scw) app.after(1000, start_program) app.display() #endregion
## Install GUIZero: sudo pip3 install guizero ## About GUIZero: https://lawsie.github.io/guizero/window/ ## Install MPG123: sudo apt-get install mpg123 ## About MPG123: https://www.mpg123.org/ from guizero import App, Text import subprocess, os # Function to Close the Window def closewindow(): app.destroy() # Play a sound file # Options [-q = quiet] [-f = scalefactor for volume control default(max): 32768 (0-32768)] playsound = os.popen( 'mpg123 -q -f 25000 /home/pi/pi-alarm/School-bell-sound-effect.mp3', 'w') # Display GUI window app = App(title="Pi-Alarm", bg="green", height=200, width=500) Alarm = Text(app, text="", size=40, font="Arial", color="black") Alarm = Text(app, text="Time for SCHOOL!", size=40, font="Arial", color="white") app.after(200000, closewindow) # Time in milliseconds to wait before closing window app.display()