def loadGUI(app, camera): # SETTING UP THE GUI app.set_full_screen() ################### # Nuclear options btn_closeApp = PushButton( app, command=closeApp, grid=[0, 0, 1, 3], image="/home/pi/hqcamera/assets/icons/home.png").tk.config( width=194, height=234, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#d4351c") btn_turnOffDevice = PushButton( app, command=turnOffDevice, grid=[1, 0], image="/home/pi/hqcamera/assets/icons/shutdown.png").tk.config( width=194, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#d4351c") btn_rebootDevice = PushButton( app, command=rebootDevice, grid=[1, 1], image="/home/pi/hqcamera/assets/icons/reboot.png").tk.config( width=194, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#f47738") # btn_deactivateCamera = PushButton(app, command=deactivateCamera, grid=[0,2], image="/home/pi/hqcamera/assets/icons/stopCamera.png").tk.config(width=194, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#d4351c") ################### # Battery icon icon_battery = Picture( app, grid=[1, 4, 1, 2], image="/home/pi/hqcamera/assets/icons/batteryunknown.png") icon_battery.after(3000, checkBatteryLevel, args=[icon_battery]) icon_battery.repeat(30000, checkBatteryLevel, args=[icon_battery]) icon_battery.tk.config(width=194, height=154, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#000000") ################### # Shutter button btn_takeAPicture = PushButton( app, command=takeAPicture, grid=[0, 3, 1, 3], image="/home/pi/hqcamera/assets/icons/capture.png").tk.config( width=194, height=234, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#0BD318") ################### # Preview toggles btn_startCameraPreview = PushButton( app, command=startCameraPreview, grid=[1, 2], image="/home/pi/hqcamera/assets/icons/startPreview.png").tk.config( width=194, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#00703c") btn_stopCameraPreview = PushButton( app, command=stopCameraPreview, grid=[1, 3], image="/home/pi/hqcamera/assets/icons/stopPreview.png").tk.config( width=194, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#d4351c") ###################### # Brightness toggles icon_brightness = Picture( app, grid=[2, 0], image="/home/pi/hqcamera/assets/icons/brightness.png").tk.config( width=158, height=74, bd=0, highlightthickness=0, bg="#000000") btn_brightnessReset = PushButton( app, command=changeBrightness, args=["reset"], grid=[3, 0], image="/home/pi/hqcamera/assets/icons/reset.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_brightnessUp = PushButton( app, command=changeBrightness, args=["up"], grid=[4, 0], image="/home/pi/hqcamera/assets/icons/plus.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_brightnessDown = PushButton( app, command=changeBrightness, args=["down"], grid=[5, 0], image="/home/pi/hqcamera/assets/icons/minus.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") ###################### # Contrast toggles icon_contrast = Picture( app, grid=[2, 1], image="/home/pi/hqcamera/assets/icons/contrast.png").tk.config( width=158, height=74, bd=0, highlightthickness=0, bg="#000000") btn_contrastReset = PushButton( app, command=changeContrast, args=["reset"], grid=[3, 1], image="/home/pi/hqcamera/assets/icons/reset.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_contrastUp = PushButton( app, command=changeContrast, args=["up"], grid=[4, 1], image="/home/pi/hqcamera/assets/icons/plus.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_contrastDown = PushButton( app, command=changeContrast, args=["down"], grid=[5, 1], image="/home/pi/hqcamera/assets/icons/minus.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") ###################### # ISO toggles icon_iso = Picture( app, grid=[2, 2], image="/home/pi/hqcamera/assets/icons/iso.png").tk.config( width=158, height=74, bd=0, highlightthickness=0, bg="#000000") btn_isoAuto = PushButton( app, command=changeISO, args=["auto"], grid=[3, 2], image="/home/pi/hqcamera/assets/icons/auto.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_isoUp = PushButton( app, command=changeISO, args=["up"], grid=[4, 2], image="/home/pi/hqcamera/assets/icons/plus.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_isoDown = PushButton( app, command=changeISO, args=["down"], grid=[5, 2], image="/home/pi/hqcamera/assets/icons/minus.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") ###################### # Filters toggles icon_iso = Picture( app, grid=[2, 3], image="/home/pi/hqcamera/assets/icons/filter.png").tk.config( width=158, height=74, bd=0, highlightthickness=0, bg="#000000") btn_filterReset = PushButton( app, command=changeFilter, args=["reset"], grid=[3, 3], image="/home/pi/hqcamera/assets/icons/reset.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_filterPrevious = PushButton( app, command=changeFilter, args=["previous"], grid=[4, 3], image="/home/pi/hqcamera/assets/icons/previous.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_filterNext = PushButton( app, command=changeFilter, args=["next"], grid=[5, 3], image="/home/pi/hqcamera/assets/icons/next.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") # btn_changeFilter = PushButton(app, command=changeFilter, grid=[3,4], image="/home/pi/hqcamera/assets/icons/btn_Camera_FiltersToggle.png").tk.config(width=198, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") ###################### # Timer toggles icon_timer = Picture( app, grid=[2, 4], image="/home/pi/hqcamera/assets/icons/timer.png").tk.config( width=158, height=74, bd=0, highlightthickness=0, bg="#000000") btn_timer3s = PushButton( app, command=changeTimer, args=[3], grid=[3, 4], image="/home/pi/hqcamera/assets/icons/3s.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_timer5s = PushButton( app, command=changeTimer, args=[5], grid=[4, 4], image="/home/pi/hqcamera/assets/icons/5s.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_timer10s = PushButton( app, command=changeTimer, args=[10], grid=[5, 4], image="/home/pi/hqcamera/assets/icons/10s.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") ###################### # Orientation toggles icon_orientation = Picture( app, grid=[2, 5], image="/home/pi/hqcamera/assets/icons/orientation.png").tk.config( width=158, height=74, bd=0, highlightthickness=0, bg="#000000") btn_orientation = PushButton( app, command=changeOrientation, args=["minus"], grid=[3, 5], image="/home/pi/hqcamera/assets/icons/orientminus90.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_orientation = PushButton( app, command=changeOrientation, args=["reset"], grid=[4, 5], image="/home/pi/hqcamera/assets/icons/orient0.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") btn_orientations = PushButton( app, command=changeOrientation, args=["plus"], grid=[5, 5], image="/home/pi/hqcamera/assets/icons/orientplus90.png").tk.config( width=74, height=74, bd=0, highlightthickness=2, highlightbackground="black", activebackground="#ffdd00", bg="#666666") app.display()
class Client: def __init__(self): self.app = App(title="LORD OF THE RINGS - THE CARD GAME", layout="grid", bg='black') self.app.tk.attributes("-fullscreen", True) self.background_menu = Picture(self.app, image=PATH_RESSOURCES + "background_menu.png", grid=[0, 0, 20, 20]) self.button_play = PushButton(self.app, image=PATH_RESSOURCES + "button_play.png", command=self.run, grid=[10, 12]) self.button_exit = PushButton(self.app, command=self.quit, text="QUIT", grid=[10, 14]) self.button_exit.text_color = "white" self.app.display() def run(self): ''' ''' response = str(requests.get(BASE_URL + '/access').content)[2:-1] self.token = json.loads(response)["id"] self.wait_player() #self.window_faction.run() def wait_player(self): ''' ''' Cleaner.clean_menu(self) self.background_wait_player = Picture(self.app, image=PATH_RESSOURCES + "background_waiting.png", grid=[0, 0, 20, 20]) self.img_waiting = Picture(self.app, image=PATH_RESSOURCES + "waiting_img.gif", grid=[10, 12]) self.button_exit = PushButton(self.app, command=self.quit, text="QUIT", grid=[10, 14]) self.button_exit.text_color = "white" self.background_wait_player.repeat(1000, self.check_players) def check_players(self): ''' ''' response = str( requests.get(BASE_URL + '/enter_room/' + self.token).content)[2:-1] status = json.loads(response)["status"] if status == 'ok': self.faction() def faction(self): ''' ''' Cleaner.clean_wait_player(self, self.check_players) self.background_faction = Picture(self.app, image=PATH_RESSOURCES + "background_faction.png", grid=[0, 0, 20, 20]) self.button_faction_1 = PushButton(self.app, image=PATH_RESSOURCES + "faction1.png", command=self.choose_faction, args=[1], grid=[7, 12]) self.button_faction_2 = PushButton(self.app, image=PATH_RESSOURCES + "faction2.png", command=self.choose_faction, args=[2], grid=[8, 12]) self.button_faction_3 = PushButton(self.app, image=PATH_RESSOURCES + "faction3.png", command=self.choose_faction, args=[3], grid=[9, 12]) self.button_faction_4 = PushButton(self.app, image=PATH_RESSOURCES + "faction4.png", command=self.choose_faction, args=[4], grid=[10, 12]) def choose_faction(self, faction_id): ''' ''' response = str( requests.get(BASE_URL + '/choose_faction/' + self.token + "/" + str(faction_id)).content)[2:-1] status = json.loads(response)["status"] print(status) self.wait_begin() def wait_begin(self): ''' ''' Cleaner.clean_choose_faction(self) #change the picture self.background_wait_begin = Picture(self.app, image=PATH_RESSOURCES + "background_waiting.png", grid=[0, 0, 20, 20]) self.background_wait_begin.repeat(1000, self.check_begin) def check_begin(self): ''' ''' response = str( requests.get(BASE_URL + '/begin/' + self.token).content)[2:-1] status = json.loads(response)["status"] if status == 'ok': self.play() def play(self): ''' ''' Cleaner.clean_wait_begin(self, self.check_begin) self.init_slot_descriptions() #change the picture self.background_wait_begin = Picture(self.app, image=PATH_RESSOURCES + "background_play.jpg", grid=[0, 0, 40, 40]) response = str( requests.get(BASE_URL + '/play/round/1/hand/' + self.token).content)[2:-1] datas = json.loads(response) self.cards = [] idx_pos = 1 for data in datas: self.cards.append( PushButton(self.app, image=PATH_RESSOURCES + "cards_min/card_" + data["image"] + "_min.png", command=self.show_card, args=[data], grid=[idx_pos, 35])) idx_pos += 1 def init_slot_descriptions(self): ''' ''' self.card_img_big = None self.name_card = None self.description_card = None self.description_power_card = None def show_card(self, card): ''' ''' if self.card_img_big is not None: Cleaner.clean_slot_descriptions(self) self.card_img_big = Picture(self.app, image=PATH_RESSOURCES + "cards/card_" + card["image"] + ".png", grid=[30, 5, 7, 19]) self.name_card = Text(self.app, text=card["name"], font="Impact", color="white", size=20, align="left", grid=[30, 25, 10, 1]) self.description_card = Text(self.app, text="\"" + self.cut_line(card["description"]) + "\"", font="Impact", color="white", size=18, align="left", grid=[30, 27, 10, 3]) self.description_power_card = Text(self.app, text=self.cut_line( card["description_power"]), font="Impact", color="white", size=18, align="left", grid=[30, 31, 10, 3]) def cut_line(self, line): ''' ''' new_line = "" while len(line) > 30: new_line += line[:30] + "\n" line = line[30:] if len(line) > 30 and new_line[-1] != " " and line[0] != " ": new_line += "-" new_line += line return new_line def quit(self): ''' exit the program ''' exit()
from guizero import App, Picture import boto3 bucket_name = 'love-letter-imgs' time_to_check = 15 * 60 * 1000 # Pull newest image from s3 # Note to use versioning here ot reduce download calls later def aws_check(): s3 = boto3.client('s3') s3.download_file(bucket_name, 'i_love_you.png', 'love_letter.png') pic.image = "love_letter.png" pic.show() # pull initial file, could check if file exists s3 = boto3.client('s3') s3.download_file(bucket_name, 'i_love_you.png', 'love_letter.png') # init app app = App(title='', width=480, height=320) pic = Picture(app, image="love_letter.png", width=480, height=320) pic.repeat(time_to_check, aws_check) # every 15 min pull newest image app.display()
x = [] y = [] #io.setmode(io.BCM) #io.setup(17, io.OUT) #io.output(17, True) start_time = time() def graph(): global start_time temp = cpu.temperature y.append(temp) x.append(time() - start_time) plt.xlabel('Time (in seconds)') plt.ylabel('Temperature') plt.title('CPU Temperature') plt.grid(True) plt.scatter(x, y) plt.plot(x, y) plt.savefig('/home/pi/Documents/2.png') plt.close('all') picture.set('/home/pi/Documents/2.png') app = App() picture = Picture(app, align="top", width=500, height=300) picture.repeat(250, graph) app.display()
# This examples requires guizero # windows - pip install guizero # macos - pip3 install guizero # linux/raspberry pi - sudo pip3 install guizero from guizero import App, Text, Combo, Picture from quickdraw import QuickDrawData def display_drawing(): display.image = qd.get_drawing(drawing_name.value).image qd = QuickDrawData() app = App(title="Quick, Draw! Viewer") Text(app, text="Pick a drawing") drawing_name = Combo(app, options=qd.drawing_names, selected=qd.drawing_names[0], command=display_drawing) display = Picture(app) status = Text(app) display_drawing() display.repeat(1000, display_drawing) app.display()