finish switch video and DPI adjust

This commit is contained in:
SikongJueluo 2024-07-11 17:51:10 +08:00
parent d397c7bbe2
commit 0ab0dd28dc
No known key found for this signature in database
GPG Key ID: D2D3D29A993716EA
2 changed files with 42 additions and 3 deletions

View File

@ -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,

View File

@ -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()