def drill_1_selection(): second_message.value = "Target Drill Selected" window1 = Window(app, bg="darkgreen") welcome_message1 = Text(window1, "Target Drill Parameters", size=25, font="Times New Roman", color="black") start_1 = PushButton(window1, command=drill_1_selection, text="Start") pause_1 = PushButton(window1, command=drill_2_selection, text="Pause") start_1.width = 30 start_1.bg = "gray" pause_1.width = 30 pause_1.bg = "gray" second_message1 = Text(window1, "How many targets would you like to use?", size=15, font="Times New Roman", color="black") targets = Slider(window1, command=print("Okay"), start=1, end=4) third_message1 = Text(window1, "Please select a passing speed:", size=15, font="Times New Roman", color="black") ball_speed = Slider(window1, command=print("Okay"), start=1, end=10) ball_speed.width = 300
def secondfunc(): app.bg = "#00cc99" app.width = 550 app.height = 200 wanted_text = Text(app, "") wanted_text.text_size = 12 wanted_text.font = "Times New Roman" wanted_text.text_color = "#000000" slider1 = Slider(app, start=0, end=180, command=slider_top_changed) slider2 = Slider(app, start=0, end=180, command=slider_bottom_changed) button_capture_top = PushButton(app, text="Top slider value", align="left", command=top_value_capture) button_capture_bottom = PushButton(app, text="Bottom slider value", align="left", command=bottom_value_capture) button_set_top = PushButton(app, text="Set top slider", align="right", command=set_top_slider) button_set_bottom = PushButton(app, text="Set bottom slider", align="right", command=set_bottom_slider) return app
def __init__(self): # Variables definition self.volume = 0.1 self.silence_frame = 50 self.noise_value = 0 self.db_value = 0 self.state = False # 0 = Pause; 1 = play # ========== GUI ============= # Create the GUI app self.app = App(title="Lombard effect on speech in Parkinson's disease App") # Energy detection option self.message = Text(self.app, text="Select threshold for voice detection") self.slider = Slider(self.app,start=0,end=6, command=self.slider_noise) # Noise characteristic option self.message2 = Text(self.app,text="Select noise in dB") self.slider2 = Slider(self.app,start=0,end=10,command=self.slider_db) # Play/pause button self.button = PushButton(self.app,text="Start/Stop", command=self.play_pause) self.state_text = Text(self.app, text="Off") logo1 = Picture(self.app, "./img/UZA.png") logo2 = Picture(self.app, "./img/inesc.png") # ========== Audio =============== # Initialization PyAudio Object pA = pyaudio.PyAudio() # Open microphine and heaset stream self.mic = pA.open(format=FORMAT, channels=CHANNELS, rate=SAMPLE_RATE, input=True, frames_per_buffer=PERIOD_SIZE_IN_FRAME) self.speak = pA.open(format=FORMAT, channels=CHANNELS, rate=SAMPLE_RATE, output=True) # Event loop self.app.repeat(10,self.loop_func) #here we made the loop function every 10ms # Display the app self.app.display()
def user_input(self, appname): from guizero import Box appname = appname # second_message.value = "User Input Selected" self.window4 = Window(app, bg="#424242", height=280, width=480,layout="grid") Text(self.window4, "User Input Mode", size=18, font="Calibri Bold", color="white",grid=[1,0]) Text(self.window4, "Please select a distance:", size=14, font="Calibri Bold", color="white",grid=[1,1]) distance = Slider(self.window4, command=self.distance_slider, start=5, end=25,grid=[1,2]) distance.text_size=14 Box(self.window4,width=100,height=10,grid=[1,3]) distance.bg="white" self.textbox = TextBox(self.window4,grid=[0,4,3,1]) self.textbox.width = 40 self.textbox.bg = "white" self.textbox.text_size=14 Box(self.window4,width=100,height=10,grid=[1,5]) send = PushButton(self.window4, command=self.send_data, args=[], image="include/images/startbut.png",grid=[1,6]) # send.width = 30 send.bg="#37f100" left = PushButton(self.window4,command=self.left_curve,args=[],text="Left",grid=[0,6]) right = PushButton(self.window4,command=self.right_curve,args=[],text="Right",grid=[2,6]) exit = PushButton(self.window4, command=self.close_test, args=[self.window4], image="include/images/stopbut.png",grid=[1,7]) exit.bg = "#e9002a"
def drill_4_selection(): second_message.value = "Predictive Passing Selected" window4 = Window(app, bg="darkgreen") welcome_message4 = Text(window4, "Predictive Passing Parameters", size=25, font="Times New Roman", color="black") start_4 = PushButton(window4, command=powerON, text="Start") pause_4 = PushButton(window4, command=powerON, text="Pause") start_4.width = 30 start_4.bg = "gray" pause_4.width = 30 pause_4.bg = "gray" #second_message4 = Text(window4, "How many targets would you like to use?", size=15, font="Times New Roman", color="black") #targets = Slider(window4, command=print("Okay"), start=1, end=4) third_message4 = Text(window4, "Please select a passing speed:", size=15, font="Times New Roman", color="black") ball_speed4 = Slider(window4, command=print("Okay"), start=1, end=10) ball_speed4.width = 300
def gui_main(): """ The main function for GUI mode. This function sets up the GUI elements and launches the GUI event loop. """ app = App(title="Nikola", bg="black") text = Text(app, color="light sky blue") text.text_size = 36 keybox = Box(app, layout="grid", border=3) keybox.text_color = "white" keybox.bg = "gray" for row in range(4): keys.append([]) for col in range(4): key = Text(keybox, grid=[col, row], text=keypad.names[row][col], size=24) keys[row].append(key) slider = Slider(app, height=36, width="fill", end=100) slider.bg = "blue" slider.text_color = "white" app.repeat(100, gui_loop, args=[text, slider]) keypad.init() rotary_encoder.init() app.set_full_screen() app.display()
def __init__(self, app): Window.__init__(self, app, title="Test") self.tk.attributes("-fullscreen", True) self.hide() # Components Text(self, text="Test") Text(self, text="Horizontal") self.s1 = Slider(self, start=0, end=1736) self.s1.width = 500 Text(self, text="Vertical") self.cb1 = CheckBox(self, text="Servo On") self.s2 = Slider(self, start=1200, end=1950) self.s2.width = 500 self.s2.value = 1950 self.cb2 = CheckBox(self, text="Vacuum On") def close_window(): self.hide() self.cancel(update) self.s1.value = 0 self.s2.value = 1950 self.cb1.value = 0 self.cb2.value = 0 arm.set_vacuum(0) arm.reset() arm.set_servo(0) PushButton(self, command=close_window, text="Exit") global w w = self
def test_getters_setters(): a = App() s = Slider(a) assert s.value == 0 s.value = 10 assert s.value == 10 a.destroy()
def test_grid_layout(): a = App(layout="grid") w = Slider(a, grid=[1, 2]) grid_layout_test(w, 1, 2, 1, 1, None) ws = Slider(a, grid=[1, 2, 3, 4]) grid_layout_test(ws, 1, 2, 3, 4, None) wa = Slider(a, grid=[1, 2], align="top") grid_layout_test(wa, 1, 2, 1, 1, "top") a.destroy()
def __init__(self, master, visible=True): super().__init__(master=master, visible=visible) self.roundTimerLabel = Text(self, text="Set the seconds of each round") self.roundTimerSlider = Slider(self) self.twoPlayerLabel = Text(self, text="Two Player Game?") self.twoPlayerCheckBox = CheckBox(self) self.boardSizeLabel = Text(self, text="Set the board Size") self.boardSizeSlider = Slider(self, end=30) self.backToMainMenuButton = PushButton(self, text="Back")
def test_command(): a = App() callback_event = Event() def callback(): callback_event.set() s = Slider(a, command = callback) assert not callback_event.is_set() # you cant invoke a tk scale - this is better than no tests! s._command_callback(s.value) assert callback_event.is_set() a.destroy()
def test_command_with_parameter(): a = App() callback_event = Event() def callback(value): assert value == 0 callback_event.set() s = Slider(a, command = callback) assert not callback_event.is_set() s._command_callback(s.value) assert callback_event.is_set() a.destroy()
def threaded_function2(): global app app = App(title="MSHD - Metereologic Sense Hat Device", height=900, width=1440) global welcome_message welcome_message = Text(app, text="Know the weather", size=25, font="Times New Roman", color="blue") text_size = Slider(app, command=change_text_size, start=30, end=100) weather = Picture(app, image="screen.gif") global weather_options weather_options = Combo(app, options=[ "Air pressure", "Ambient Temperature", "Ground Temperature", "Humidity", "Rainfall", "Room Temperature", "Wind Speed" ], grid=[0, 1], align="left") Run_app = PushButton(app, show_weather, text="select", grid=[3, 1], align="left") app.display()
def __init__(self): """ - create all necessary elements - configure them with self.configure() method """ self.app = App(title="JIRA log work", width=Application.WIDTH, height=Application.HEIGHT, bg="white", layout="grid") self.jira = JiraConnector() self.username = get_login_from_filename() self.issues = get_issues_from_file() self.input_login = TextBox(self.app, self.username, width=20, grid=[1, 1]) self.input_password = tkinter.Entry(show="*", width=20) self.calendar = tkcalendar.Calendar(background="#034DA4", selectbackground="#034DA4") self.issues = Combo(self.app, options=self.issues, grid=[1, 9]) self.slider = Slider(self.app, start=1, end=8, grid=[1, 4]) self.comment = TextBox(self.app, "<comment>", width=30, height=4, grid=[0, 10], multiline=True) self.ok = self._create_send_button() self.how_to = PushButton(self.app, text="How to?", command=self._generate_info, grid=[1, 10], align="left") self.configure()
def GUI(): app = App(title="Distance", width=230, height=70, layout="grid") Text(app, text="Rate (ms) :", grid=[0, 0], align="left") slider = Slider(app, command=RepeatMeasure, start=50, end=2000, grid=[1, 0], align="left") slider.value = "100" Text(app, text="Distance (cm) : ", grid=[0, 1], align="left") global txt txt = Text(app, text="Dist", grid=[1, 1], align="left") RepeatMeasure(100) app.display()
def manualDrill(): second_message.value = "Entering Manual Mode" STARS_aPP.drillType = "manual" window3 = Window(app, bg="darkgreen") welcome_message3 = Text(window3, "Manual Mode Controls", size=25, font="Times New Roman", color="black") third_message3 = Text(window3, "Please select a ball speed:", size=15, font="Times New Roman", color="black") speed = Slider(window3, command=STARS_aPP.ball_speed_slider, start=1, end=5) speed.width = 300 start_3 = PushButton(window3, command=STARS_aPP.start_command, args = [STARS_aPP.ballSpeed , STARS_aPP.difficulty, STARS_aPP.drillType], text="Begin") stop_3 = PushButton(window3, command=STARS_aPP.stop_command, text="stop") start_3.width = 30 start_3.bg = "gray" stop_3.width = 30 stop_3.bg = "gray"
def music_window(): window = Window(app, title="Music setting") window.bg = (156, 153, 153) Play = PushButton(window, text = "Play",command=self.start_music, width = "fill") Pause = PushButton(window, text = "Pause", command=self.pause_music, width = "fill") Continue = PushButton(window, text = "Continue", command=self.continue_music, width = "fill") next_ = PushButton(window, text = "next", command=self.next_music, width = "fill") previous = PushButton(window, text = "previous", command=self.previous_music, width = "fill") text_slider = Text(window, text="volume", width = "fill") music_volume = Slider(window, command = volume, width = "fill")
def main(): global txt_answer window = App(title="Square Root Calculator", height=100) Slider(window, horizontal=True, end=256, command=slider_moved) txt_answer = Text(window, size=16, text_color="blue") window.display()
def test_default_values(): a = App() s = Slider(a) assert s.tk.cget("from") == 0 assert s.tk.cget("to") == 100 assert s.tk.cget("orient") == "horizontal" assert s.master == a assert s.grid == None assert s.align == None a.destroy()
def test_alt_values(): a = App(layout="grid") s = Slider(a, start=10, end=20, horizontal=False, grid=[0, 1], align="top") assert s.tk.cget("from") == 10 assert s.tk.cget("to") == 20 assert s.tk.cget("orient") == "vertical" assert s.grid[0] == 0 assert s.grid[1] == 1 assert s.align == "top" a.destroy()
def create_ui(): # RED text = Text(app, text="Red Value:", align="right", color="red", grid=[0, 0]) slider = Slider(app, grid=[1, 0], width="250", align="bottom", command=on_red_slider_changed) # GREEN text = Text(app, text="Green Value:", align="right", color="green", grid=[0, 1]) slider = Slider(app, grid=[1, 1], width="250", align="bottom", command=on_green_slider_changed) # BLUE text = Text(app, text="Blue Value:", align="right", color="blue", grid=[0, 2]) slider = Slider(app, grid=[1, 2], width="250", align="bottom", command=on_blue_slider_changed) app.display()
def __init__(self, password=''): self.app = MyApp() self.settings = Settings() self.title = Text(self.app, text='Password Generator') self.password_field = TextBox(self.app, text=password, height=4, width='fill', multiline=True) self.input_container = Box(self.app, border=1, align='bottom') self.password_length_slider = Slider(self.input_container, width='fill') self.button = MyButton(self.input_container, command=self.get_password) self.has_lowers_checkbox = MyCheckBox(self.input_container, text='lowercase', value=1) self.has_uppers_checkbox = MyCheckBox(self.input_container, text='uppercase') self.has_numbers_checkbox = MyCheckBox(self.input_container, text='numbers') self.has_specials_checkbox = MyCheckBox(self.input_container, text='special') self.password_length_slider.bg = self.settings.secondary self.password_length_slider.text_color = self.settings.button_text self.input_container.width = 'fill'
def openToggle(): app.hide() toggleWindow = Window(app, title="Toggle", width=125, height=225, layout="auto") def brightness(value): for light in lights: light.set_brightness(value) print("BRIGHTNESS UPDATED: " + str(info()["BRIGHTNESS"])) def toggle(): state = lights[0].get_power() if state > 0: for light in lights: light.set_power("off") print("STATE UPDATED: OFF") toggleButton.text = "ON" else: for light in lights: light.set_power("on") light.set_brightness(float(slider.value)) print("STATE UPDATED: ON") toggleButton.text = "OFF" def openMenu(): toggleWindow.hide() app.show() slider = Slider(toggleWindow, start=65535, end=0, command=brightness, horizontal=False, width="20", height="fill", align="left") toggleButton = PushButton(toggleWindow, text="POWER", width="50", height="fill", align="right", command=toggle)
def test(): app = App(title='Robo', height=300, width=400, layout='grid') box = Box(app, layout='grid', grid=[0,0]) PushButton(box, command=drive, args=[r.forwardLeft], text='Forward Left', grid=[0,0]) PushButton(box, command=drive, args=[r.forward], text='Forward', grid=[1,0]) PushButton(box, command=drive, args=[r.forwardRight], text='Forward Right', grid=[2,0]) PushButton(box, command=drive, args=[r.pivotLeft], text='Pivot Left', grid=[0,1]) PushButton(box, command=r.stop, text='Stop', grid=[1,1]) PushButton(box, command=drive, args=[r.pivotRight], text='Pivot Right', grid=[2,1]) PushButton(box, command=drive, args=[r.backwardLeft], text='Backward Left', grid=[0,2]) PushButton(box, command=drive, args=[r.backward], text='Backward', grid=[1,2]) PushButton(box, command=drive, args=[r.backwardRight], text='Backward Right', grid=[2,2]) slider = Slider(app, command=timeChanged, grid=[0,1], start=0, end=10) app.display()
def test_update_command_with_parameter(): a = App() callback_event = Event() def callback(value): assert s.value == 0 callback_event.set() s = Slider(a) s.update_command(callback) s._command_callback(s.value) assert callback_event.is_set() a.destroy()
def predictiveDrill(): second_message.value = "Entering Predictive Passing Mode" STARS_aPP.drillType = "dynamic" window2 = Window(app, bg="darkgreen") welcome_message2 = Text(window2, "Predictive Passing Controls", size=25, font="Times New Roman", color="black") third_message2 = Text(window2, "Please select a ball speed:", size=15, font="Times New Roman", color="black") speed = Slider(window2, command=STARS_aPP.ball_speed_slider, start=1, end=5) speed.width = 300 final_message1 = Text(window2, "Please select a difficulty:", size=15, font="Times New Roman", color="black") difficulty = Slider(window2, command=STARS_aPP.difficulty_slider, start=1, end=5) difficulty.width = 300 args = 1 start_2 = PushButton(window2, command=STARS_aPP.start_command, args = [STARS_aPP.ballSpeed , STARS_aPP.difficulty, STARS_aPP.drillType], text="Begin") stop_2 = PushButton(window2, command=STARS_aPP.stop_command, text="stop") start_2.width = 30 start_2.bg = "gray" stop_2.width = 30 stop_2.bg = "gray"
def staticDrill(): second_message.value = "Static Passing Selected" STARS_aPP.drillType = "static" window1 = Window(app, bg="darkgreen") welcome_message2 = Text(window1, "Static Passing Parameters", size=25, font="Times New Roman", color="black") third_message1 = Text(window1, "Please select a passing speed:", size=15, font="Times New Roman", color="black") speed = Slider(window1, command=STARS_aPP.ball_speed_slider, start=1, end=5) speed.width = 300 final_message1 = Text(window1, "Please select a difficulty:", size=15, font="Times New Roman", color="black") difficulty = Slider(window1, command=STARS_aPP.difficulty_slider, start=1, end=5) difficulty.width = 300 start_1 = PushButton(window1, command=STARS_aPP.start_command, args = [STARS_aPP.ballSpeed , STARS_aPP.difficulty, STARS_aPP.drillType], text="Begin") stop_1 = PushButton(window1, command=STARS_aPP.stop_command, text="stop") start_1.width = 30 start_1.bg = "gray" stop_1.width = 30 stop_1.bg = "gray"
from gpiozero import MCP3008 from guizero import App, Slider from threading import Thread app = App("ADC GUI") adc = [MCP3008(i) for i in range(8)] sliders = [Slider(app, 0, 100) for pot in adc] def update(): while True: for slider, pot in zip(sliders, adc): slider.set(pot.value * 100) thread = Thread(target=update) thread.start() app.display()
addressText2 = TextBox(app, width=25, grid=[1, 4]) addressText3 = TextBox(app, width=25, grid=[1, 5]) addressText4 = TextBox(app, width=25, grid=[1, 6]) addressText5 = TextBox(app, width=25, grid=[1, 7]) addressText6 = TextBox(app, width=25, grid=[1, 8]) jobTitleLabel = Text(app, text="TBA", grid=[1, 9], size=10) salaryLabel = Text(app, text="Salary : ", grid=[2, 0, 2, 1], align="left", size=10) salaryScale = Slider(app, start=10000, end=100000, grid=[2, 1, 2, 1], command=do_salaryScale, align="left") fullTimeCheckBox = CheckBox(app, text="Full-time?", grid=[2, 2, 2, 1], command=do_fullTimeCheckBox, align="left") jobButtonGroup = ButtonGroup( app, options=["Programmer", "Developer", "Web Developer", "Designer"], selected=0, grid=[2, 3, 2, 4], command=do_jobButtonGroup, align="left")
def setup_gui(): """ Create the GUI for controlling the STS-Pi Rover. """ global app, statusWaffle, roverChoice, connectButton, exitButton global forwardButton, stopButton, backwardButton, spdSlider, durationSlider global spinRightButton, spinLeftButton, photoButton, videoButton global buttonWaffle # Declare the GUI application app = App("STS Controller", layout="grid") # Bluetooth connection status waffle. Single cell, blue=connected, red=not. statusWaffle = Waffle(app, 1, 4, 10, 10, grid=[0, 0]) if connected: statusWaffle.set_pixel(0, 0, "blue") statusWaffle.set_pixel(1, 0, "white") statusWaffle.set_pixel(2, 0, "white") statusWaffle.set_pixel(3, 0, "white") # Choice of STS-PI Rover roverChoice = ButtonGroup(app, options=["STS-Pi 2", "STS-Pi 3"], selected="STS-Pi 2", grid=[1, 0]) # Reconnect button for when the Bluetooth connection has been lost or reset connectButton = PushButton(app, connect, text="Connect", grid=[2, 0]) #Create forwards and backwards buttons forwardButton = PushButton(app, forwards, text="Forwards", grid=[1, 1]) #Create spin left and right buttons spinLeftButton = PushButton(app, spinAntiClockwise, text="Spin Left", grid=[0, 2]) #Button to stop the STS-PI in an emergency stopButton = PushButton(app, stop, text="STOP", grid=[1, 2]) spinRightButton = PushButton(app, spinClockwise, text="Spin Right", grid=[2, 2]) backwardButton = PushButton(app, backwards, text="Backwards", grid=[1, 3]) #Create a slider to set the speed. speedTitle = Text(app, "Speed %", grid=[0, 4]) spdSlider = Slider(app, command=changeSpeed, grid=[1, 4, 3, 1]) spdSlider.value = 15 #Create a slider to set the duration of the next movement durationTitle = Text( app, "Duration (secs)", grid=[0, 5], ) durationSlider = Slider(app, command=changeDuration, start=1, end=10, grid=[1, 5, 3, 1]) durationSlider.value = 1 #Buttons to take videos and photos. photoButton = PushButton(app, takePhoto, text="Photo", grid=[0, 6]) videoButton = PushButton(app, takeVideo, text="Video", grid=[2, 6]) #Waffle to display button presses buttonWaffle = Waffle(app, 1, 8, grid=[0, 7, 3, 2]) # Ids for the buttons on the STS-PI rover buttonIds = Text(app, "1 2 3 4 5 6 7 8 ", grid=[0, 9, 3, 1]) # This spacer text increases the gap below the controls and the exit button. spacer = Text(app, "", grid=[0, 10]) # Button to quit the application exitButton = PushButton(app, closeDown, text="Exit", grid=[1, 11])