From 0ab0dd28dceaf3f708d9c1c3bc34a786d1d2a1d4 Mon Sep 17 00:00:00 2001 From: SikongJueluo Date: Thu, 11 Jul 2024 17:51:10 +0800 Subject: [PATCH] finish switch video and DPI adjust --- ISPController.spec | 2 +- src/main.py | 43 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/ISPController.spec b/ISPController.spec index da451a9..53de54a 100644 --- a/ISPController.spec +++ b/ISPController.spec @@ -26,7 +26,7 @@ exe = EXE( bootloader_ignore_signals=False, strip=False, upx=True, - console=True, + console=False, disable_windowed_traceback=False, argv_emulation=False, target_arch=None, diff --git a/src/main.py b/src/main.py index f70eb7c..c2c5047 100644 --- a/src/main.py +++ b/src/main.py @@ -11,7 +11,7 @@ import functools class App(ctk.CTk): __window_width = 1280 - __window_height = 1350 + __window_height = 1450 __column_weight = [1, 9, 3] serial_status = False serial_baudrate = 9600 @@ -41,7 +41,8 @@ class App(ctk.CTk): ctk.set_widget_scaling(2.0) messagebox.isHighDIP = True else: - ctk.set_window_scaling(0.8) + ctk.set_window_scaling(0.5) + ctk.set_widget_scaling(0.8) # find the center point center_x = int(screen_width / 2 - width / 2) @@ -235,6 +236,27 @@ class App(ctk.CTk): ) gain_button[i].grid(column=1, row=i, sticky=ctk.NSEW, pady=10, padx=20) + button_frame = ctk.CTkFrame(data_frame) + button_frame.grid( + column=0, columnspan=2, row=5, sticky=ctk.NSEW, pady=10, padx=10, ipady=20 + ) + button_frame.columnconfigure(0, weight=1) + button_frame.columnconfigure(1, weight=1) + switch_day = ctk.CTkButton( + button_frame, + text="切换为白天", + font=self.font, + command=functools.partial(self.setvideo, 0), + ) + switch_day.grid(column=0, row=0, sticky=ctk.NSEW, padx=10, ipady=20) + switch_night = ctk.CTkButton( + button_frame, + text="切换为黑夜", + font=self.font, + command=functools.partial(self.setvideo, 1), + ) + switch_night.grid(column=1, row=0, sticky=ctk.NSEW, padx=10, ipady=20) + return None def updateSerial(self, event: Optional[Any] = None): @@ -330,6 +352,23 @@ class App(ctk.CTk): print("Please Connect to Serial") messagebox.showError("Please Connect Serial Port") + def setvideo(self, video: int) -> None: + try: + is_open = self.serial.is_open() + except AttributeError: + messagebox.showError("Please Connect to Serial") + else: + if is_open: + if video == 0: + self.serial.write("cmdd".encode()) + elif video == 1: + self.serial.write("cmdn".encode()) + else: + messagebox.showError("Set Video Error!") + else: + messagebox.showError("Please Open Serial") + return None + def run(self): self.mainloop()