def staticDrill(self,appname): from guizero import Box appname = appname # second_message.value = "Static Passing Selected" self.drillType = "Static" self.window1 = Window(app, bg="#424242",height=280, width=480, layout="grid") # logo = Picture(self.window1, image="include/logo.gif", align="left", grid=[0, 0]) # logo.resize(40, 40) Heading = Text(self.window1, "Basic Tracking", size=18, font="Calibri Bold", color="white",grid=[1,0,3,1]) Slide1 = Text(self.window1, "Ball Speed:", size=14, font="Calibri Bold", color="white", grid=[1, 1]) # , 2, 1]) speed = Slider(self.window1, command=self.ball_speed_slider, start=1, end=5, grid=[1, 2]) speed.width = 150 speed.text_color = "black" speed.bg = "white" speed.text_size=14 Slide2 = Text(self.window1, "Pass Difficulty:", size=14, font="Calibri Bold", color="white", grid=[3, 1]) difficulty = Slider(self.window1, command=self.difficulty_slider, start=1, end=5, grid=[3, 2]) difficulty.width = 150 difficulty.text_color = "black" difficulty.bg = "white" difficulty.text_size=14 start = PushButton(self.window1, command=self.start_command, args=[self.ballSpeed, self.difficulty, self.drillType, appname], image="include/images/startbut.png", grid=[1, 5]) start.bg = "#37f100" start.text_color = "white" stop = PushButton(self.window1, command=self.pause_command, args=[self.window1], image="include/images/pausebut.png", grid=[3, 5]) stop.bg = "#ffb000" stop.text_color = "white" exit_win = PushButton(self.window1, command=self.exit_command, args=[appname, self.window1], image="include/images/stopbut.png", grid=[1, 6]) exit_win.bg = "#e9002a" exit_win.text_color = "white" camera = PushButton(self.window1, command=self.show_cam, args=[], image="include/images/camerabut.png", grid=[3, 6]) camera.bg = "#002ff5" camera.text_color = "white" Center = Box(self.window1, width=50, height=165, grid=[2, 1, 1, 7]) Left = Box(self.window1, width=60, height=200, grid=[0, 0, 1, 7]) Right = Box(self.window1, width=20, height=200, grid=[4, 0, 1, 7]) VC = PushButton(Center, command=self.enable_voice, args=[], image="include/images/micbut.png", align="bottom")
def manualDrill(self,appname): # if self.player != "None": from guizero import Box appname = appname # second_message.value = "Entering Manual Mode" self.drillType = "Manual" self.window3 = Window(app, bg="#424242",height=280, width=480, layout="grid") # logo = Picture(self.window3, image="include/logo.gif", align="left", grid=[0, 0]) # logo.resize(75, 75) Heading = Text(self.window3, "Voice Activated Launch", size=18, font="Calibri Bold", color="white",grid=[1,0,3,1]) Slide1 = Text(self.window3, "Ball Speed:", size=14, font="Calibri Bold", color="white", grid=[1, 1]) # , 2, 1]) speed = Slider(self.window3, command=self.ball_speed_slider, start=1, end=5, grid=[1, 2]) speed.width = 150 speed.text_color = "black" speed.bg = "white" speed.text_size=14 Slide2 = Text(self.window3, "Pass Difficulty:", size=14, font="Calibri Bold", color="white", grid=[3, 1]) difficulty = Slider(self.window3, command=self.difficulty_slider, start=1, end=5, grid=[3, 2]) # , 2, 1]) difficulty.width = 150 difficulty.text_color = "black" difficulty.bg = "white" difficulty.text_size=14 start = PushButton(self.window3, command=self.start_command, args=[self.ballSpeed, self.difficulty, self.drillType, appname], image="include/images/startbut.png", grid=[1, 5]) start.bg = "#37f100" start.text_color = "white" stop = PushButton(self.window3, command=self.pause_command, args=[self.window3], image="include/images/pausebut.png", grid=[3, 5]) stop.bg = "#ffb000" stop.text_color = "white" exit_win = PushButton(self.window3, command=self.exit_command, args=[appname, self.window3], image="include/images/stopbut.png", grid=[1, 6]) exit_win.bg = "#e9002a" exit_win.text_color = "white" camera = PushButton(self.window3, command=self.show_cam, args=[], image="include/images/camerabut.png", grid=[3, 6]) camera.bg = "#002ff5" camera.text_color = "white" Center = Box(self.window3, width=50, height=200, grid=[2, 1, 1, 7]) Left = Box(self.window3, width=60, height=200, grid=[0, 0, 1, 7]) Right = Box(self.window3, width=20, height=200, grid=[4, 0, 1, 7])
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 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()
min_pulse_width=minPWM, max_pulse_width=maxPWM) servo_Vertical.angle = n sleep(2) correction1 = 0.45 correction2 = -0.35 maxPWM = ((2 + correction1) / 1000) minPWM = ((1 + correction2) / 1000) app = App(title="servo control", width=800, height=150) app.bg = "blue" slider_Horizontal = Slider(app, height=40, width=750, start=-90, end=90, command=Turn_Horizontal) slider_Horizontal.bg = "red" slider_Vertical = Slider(app, height=40, width=750, start=-90, end=90, command=Turn_Vertical) slider_Vertical.bg = "red" app.display()
pantilthat.pan(0) pantilthat.tilt(-20) exit() # GUI Setings app = App(bg ="lightgrey", title="Pimoroni Interactive Cam V1.5", width=1050, height=400, layout="grid") pan_txt = Text(app, text="R Pan L", width=17, grid=[1,0], align="left") pan_txt.text_color="blue" position_txt = Text(app, text="Postition", width=10, color="blue", grid=[0,1], align="left") pan_set = Slider(app, command=set_pan_tilt, start=-90, end=90, width=150, height=15, grid=[1,1], align="left") # sets pan value pan_set.value = 0 pan_set.bg="yellow" reset_position = PushButton(app, command=position_reset, text="Position Reset", width=14, grid=[2,1], align="left") reset_position.text_color="blue" tilt_txt = Text(app, text="U Tilt D", width=17, grid=[3,0], align="left") tilt_txt.text_color="blue" tilt_set = Slider(app, command=set_pan_tilt, start=-90, end=90, width=150, height=15, grid=[3,1], align="left") # sets tilt value tilt_set.value = -20 tilt_set.bg="yellow" lights_txt = Text(app, text="Lighting", width=10, color="blue", grid=[0,4], align="left") red_txt = Text(app, text=" RED", width=10, grid=[1,3], align="left") # red_txt.bg="lightgrey"
button6 = PushButton(app, text="r", grid=[1, 1]) button6.text_size = 20 button6.bg = "green" button6.when_left_button_pressed = direction_four button6.when_left_button_released = stop # Right button for torvalds button7 = PushButton(app, text="e", grid=[2, 1]) button7.text_size = 20 button7.bg = "red" button7.when_left_button_pressed = east button7.when_left_button_released = stop_two # Left button for torvalds button8 = PushButton(app, text="w", grid=[3, 1]) button8.text_size = 20 button8.bg = "red" button8.when_left_button_pressed = west button8.when_left_button_released = stop_two # Sliders to control the servos and pwm servo_slider1 = Slider(servo_window, start=-90, end=90, command=servo_movement) servo_slider1.bg = "magenta" servo_slider2 = Slider(servo_window, start=-90, end=90, command=servo_two_movement) servo_slider2.bg = "magenta" slider_three = Slider(servo_window, start=0, end=10, command=pwm_one) slider_three.bg = "aqua" slider_four = Slider(servo_window, start=0, end=10, command=pwm_two) slider_four.bg = "aqua" # display the App app.display()
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" b.text_size = 18
def h(): app = App(width=800, height=800, title="my first GUI") app.bg = (156, 153, 153) init_control() # menu bar menubar = MenuBar(app, toplevel=["File", "view"], options=[[["music", music_window], ["Exit", exit_app]], [["full-screen", full_screen], ["normal screen", normal_screen]]]) name_box = Box(app, border=1, width="fill") Text(name_box, font="Times New Roman", text="Hosni RPi-GUI-App", width="fill", color=(0, 0, 128)) # win of music Text(app, font="Times New Roman", text="Music", width="fill", color=(145, 15, 15)) music_box1 = Box(app, border=1, width="fill") music_window_button = PushButton( music_box1, align="left", text="Music", command=music_window ) #, image = "/home/pi/Desktop/music/download.png") music_volume_slider = Slider(music_box1, start=100, end=0, command=music_volume, height="fill", width=20, horizontal=False, align="left") music_box2 = Box(music_box1, align="left", width="fill") music_play_button = PushButton(music_box2, text="Play", command=start_music, width="fill") music_pause_button = PushButton(music_box2, text="Pause", command=pause_music, width="fill") music_continue_button = PushButton(music_box2, text="Continue", command=continue_music, width="fill") music_next_button = PushButton(music_box2, text="next", command=next_music, width="fill") music_previous_button = PushButton(music_box2, text="previous", command=previous_music, width="fill") #box3 = Box(box1,align = "left", width = "fill") #music_volume = Slider(box3,start = 100, end = 0 ,command = volume, height = 200, horizontal = False, align = "left") # led intensity text_ledpwm = Text(app, font="Times New Roman", text="LED intensity", width="fill", color=(145, 15, 15)) box4 = Box(app, border=1, width="fill") LEDPwm = Slider(box4, command=LED_intensity_control, width="fill", align="left") LEDPwm.bg = (255, 255, 255) text2 = Text(box4, text="D of LED = 0 %", align="left") text2.text_color = (0, 0, 128) # Fan speed fan_speed_text = Text(app, font="Times New Roman", text="Fan speed", width="fill", color=(145, 15, 15)) fan_speed_box = Box(app, border=1, width="fill") fan_speed_slider = Slider(fan_speed_box, command=fan_speed_control, width="fill", align="left") fan_speed_slider.bg = (255, 255, 255) fan_speed_display = Text(fan_speed_box, text="D of fan= 0 %", align="left") fan_speed_display.text_color = (0, 0, 128) # Ddisplay on lcd lcd_text = Text(app, font="Times New Roman", text="LCD", color=(145, 15, 15)) lcd_box = Box(app, border=1, width="fill") lcd_text_box = TextBox(lcd_box, width="fill", align="left") disply_lcd = PushButton(lcd_box, text="Display", command=display_on_lcd, align="left") lcd_text_box.bg = (255, 255, 255) lcd_text_box.text_size = 15 # Servo motor servo_text = Text(app, font="Times New Roman", text="Servo angle", width="fill", color=(145, 15, 15)) servo_box1 = Box(app, border=1, width="fill") servo_angle = TextBox(servo_box1, width="fill", align="left") rotate = PushButton(servo_box1, text="Rotate", align="left", command=servo_rotate) servo_box2 = Box(app, border=1, width="fill") rotate_0 = PushButton(servo_box2, text="Rotate 0 ", align="left", width="fill", command=servo_rotate_zero) rotate_90 = PushButton(servo_box2, text="Rotate 90", align="left", width="fill", command=servo_rotate_90) rotate_180 = PushButton(servo_box2, text="Rotate180", align="left", width="fill", command=servo_rotate_180) servo_angle.bg = (255, 255, 255) servo_angle.text_size = 15 # Control room light room_text = Text(app, font="Times New Roman", text="Room Light", width="fill", color=(145, 15, 15)) room_box = Box(app, border=1, width="fill") room_turnon = PushButton(room_box, text="Turn on", width="fill", command=turn_on, align="left") room_turnoff = PushButton(room_box, text="Turn off", width="fill", command=turn_off, align="left") room_state = Text(room_box, align="left") room_state.value = "OFF" room_state.text_color = (102, 0, 51) Text(app) # Box which group the four boxes sensors_box = Box(app, width="fill") # display ultrasonic reading ultrasonic_box = Box(sensors_box, border=1, width="fill", align="left") ultrasonic_text = Text(ultrasonic_box, font="Times New Roman", text="Ultrasonic Reading", width="fill", color=(145, 15, 15)) ultrasonic_reading_text = Text(ultrasonic_box, text="the Distance = 0 CM") ultrasonic_reading_text.repeat(200, ultrasonic_measure) # PIR object Detection PIR_box = Box(sensors_box, border=1, width="fill", align="left") PIR_text = Text(PIR_box, font="Times New Roman", text="Object Detection", width="fill", color=(145, 15, 15)) PIR_reading_text = Text(PIR_box) PIR_reading_text.repeat(150, PIR_detect) # Sound sensor sound_box = Box(sensors_box, border=1, width="fill", align="left") sound_text = Text(sound_box, font="Times New Roman", text="Sound Detection", width="fill", color=(145, 15, 15)) sound_reading_text = Text(sound_box) sound_reading_text.repeat(200, sound_detect) # flame sensor flame_box = Box(sensors_box, border=1, width="fill", align="left") flame_text = Text(flame_box, font="Times New Roman", text="Flame Detection", width="fill", color=(145, 15, 15)) falme_reading_text = Text(flame_box) falme_reading_text.repeat(200, flame_detect) app.display()
servo_two.angle = int(slider_value) # This is the title text robot_text = Text(robot_movement, text="Linus Movement", size=20) # Button to make the robot move forward forward_button = PushButton(robot_movement, text="forward", width=10) forward_button.when_left_button_pressed = direction_one forward_button.when_left_button_released = stop forward_button.bg = "blue" forward_button.text_size = 20 #Define the servo sliders servo_text = Text(servo_window, text="Servo Angular Movement", size=20) slider_one_text = Text(servo_window, text="servo one") slider = Slider(servo_window, start=-90, end=90, command=servo_movement) slider.bg = "aqua" slider_two_text = Text(servo_window, text="servo two") slider_two = Slider(servo_window, start=-90, end=90, command=servo_two_movement) slider_two.bg = "aqua" # Button to make the robot move backward backward_button = PushButton(robot_movement, text="backward", width=10, align="bottom") backward_button.when_left_button_pressed = direction_two backward_button.when_left_button_released = stop backward_button.bg = "blue" backward_button.text_size = 20
from guizero import App, ButtonGroup, CheckBox, Combo, PushButton, Slider, Text, TextBox a = App(title="colors") text = Text(a, text="colors") check = CheckBox(a, "check me") combo = Combo(a, ["red", "blue"]) button = PushButton(a) slider = Slider(a) textbox = TextBox(a, text="or colours") a.bg = "pink" text.text_size = 30 text.font = "verdana" check.bg = "red" combo.bg = "blue" combo.text_color = "green" combo.text_size = 24 button.bg = "black" button.text_color = "white" button.font = "arial" button.text_size = 18 slider.bg = "yellow" textbox.bg = "cyan" textbox.font = "courier" textbox.text_color = "purple" a.display()
from guizero import App, Text, TextBox, PushButton, Slider, Picture def say_my_name(): welcome_message.value = my_name.get() def change_text_size(slider_value): welcome_message.size = slider_value app = App(title="Hello World", width=1000, bg="#33bbbb") welcome_message = Text(app, "welcome to my app", size="40", font="Helvetica", color="green", bg="#33bbbb") my_name = TextBox(app, width="200") update_text = PushButton(app, command=say_my_name, text="Display My Name") update_text.bg = "#33bbbb" text_size = Slider(app, command=change_text_size, start=10, end=80) text_size.bg = "#33bbbb" my_image = Picture(app, image="flower.gif") app.display
button6.when_left_button_released = stop # Right button for torvalds button7 = PushButton(app, text="e", grid=[2, 1]) button7.text_size = 20 button7.bg = "red" button7.when_left_button_pressed = east button7.when_left_button_released = stop_two # Left button for torvalds button8 = PushButton(app, text="w", grid=[3, 1]) button8.text_size = 20 button8.bg = "red" button8.when_left_button_pressed = west button8.when_left_button_released = stop_two # Text box to input PWM between 0 and 10 pwm_text = TextBox(app, grid=[4, 1]) # Sliders to control the servos servo_slider1 = Slider(servo_window, start=-90, end=90, command=servo_movement, grid=[1, 4]) servo_slider1.bg = "magenta" servo_slider2 = Slider(servo_window, start=-90, end=90, command=servo_two_movement, grid=[1, 5]) servo_slider2.bg = "magenta" # display the App app.display()
tool_box = Box(a, height="fill", border=True, align="left") paint_box = Box(a, width="fill", height="fill", border=True, align="right") tool = Combo(tool_box, options=["line", "rectangle", "oval"], selected="line", align="top", width="fill", command=select_tool) color_label = Text(tool_box, text="color", align="top", width="fill") color_label.bg = "black" color_label.text_color = "white" red = Slider(tool_box, end=255, command=update_color) red.bg = (255, 0, 0) green = Slider(tool_box, end=255, command=update_color) green.bg = (0, 255, 0) blue = Slider(tool_box, end=255, command=update_color) blue.bg = (0, 0, 255) line_width_box = Box(tool_box, align="top") Text(line_width_box, text="width", align="top") line_width = Slider(line_width_box, start=1, end=10, align="top") painting = Drawing(paint_box, width="fill", height="fill") painting.last_event = None painting.last_shape = None painting.when_left_button_pressed = start_paint
color="white", ) """ Aggregator """ slid_a = 0 a1 = Text( controller_box, text="Aggregator", grid=[1, 3], ) sliderA = Slider(controller_box, command=lambda: menuFunctions.move_aggregator(slid_a), start=0, end=1, grid=[2, 3]) slid_a = sliderA.value sliderA.bg = theme[0] """ movement features """ Text(controller_box, text="distance", grid=[3, 4], color="white") sliderXY = Slider( controller_box, start=-200, end=200, grid=[4, 4], ) sliderXY.bg = theme[0] a2 = PushButton( controller_box, command=lambda: menuFunctions.move_x_button(sliderXY), text=" Move X ", grid=[1, 4], )
9600) #This line sets up the serial port so data can be sent through it ser.flush( ) #this line cleans out the serial port so there is no garbage in the serial port sleep( 3 ) #this line just gives the arduino time to understand the monitor is being turned on app = App( title="servo control with arduino", width=800, height=400 ) #This line sets up the app window with a specific tital and dimensions app.bg = "blue" #This line sets the app background to be blue slider_Horizontal = Slider( app, height=40, width=750, start=-90, end=90, command=Turn_Servo1) #This line sets up the slider specs and command line slider_Horizontal.bg = "red" #This line sets the slider background to red slider_Vertical = Slider( app, height=40, width=750, start=-90, end=90, command=Turn_Servo2) #This line sets up the slider specs and command line slider_Vertical.bg = "red" #This line sets the slider background to red Save_Position = PushButton( app, text="Save Angular Position", command=Save_Servos ) #This line sets up the save button specs and command line Save_Position.bg = "green" #This line sets the button colour to green Recall_Position = PushButton( app, text="View Saved Positions", command=Recall_Servos ) #This line sets up the recall button specs and command line Recall_Position.bg = "green" #This line sets the button colour to green