diff --git a/.gitignore b/.gitignore index fb6f3e7..c464545 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -.venv/ +.venv/ src/__pycache__/ \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 447bace..37ccc94 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,4 @@ -pip==24.1.1 -setuptools==65.5.0 +customtkinter==5.2.2 +darkdetect==0.8.0 +packaging==24.1 +pyserial==3.5 diff --git a/src/main.py b/src/main.py index b1b01da..6767f11 100644 --- a/src/main.py +++ b/src/main.py @@ -1,284 +1,300 @@ -import customtkinter as ctk - -import serial -import serial.tools -import serial.tools.list_ports as ls_ports -import serial.tools.list_ports - -from typing import Optional, Any -import functools - - -class App(ctk.CTk): - __window_width = 1280 - __window_height = 1350 - __column_weight = [1, 9, 3] - serial_status = False - serial_baudrate = 115200 - gain_values = [0.0 for i in range(5)] - gain_default = [1.3, 0.7, 1.1, 2.2, 0.5] - gain_enable = [True for i in range(5)] - - def __init__(self) -> None: - super().__init__() - self.__windowInit(self.__window_width, self.__window_height) - self.__data_frame() - - def __windowInit(self, width: int, height: int) -> None: - self.title("ISP上位机") - # appearance and font - ctk.set_appearance_mode("dark") - ctk.set_default_color_theme("dark-blue") - ctk.set_widget_scaling(2.0) - self.font = ctk.CTkFont(family="", size=17) - - # get the screen dimension - screen_width = self.winfo_screenwidth() - screen_height = self.winfo_screenheight() - # find the center point - center_x = int(screen_width / 2 - width / 2) - center_y = int(screen_height / 2 - height / 2) - # set the position of the self to the center of the screen - self.geometry(f"{width}x{height}+{center_x}+{center_y}") - - # create gain_frame - top_frame = ctk.CTkFrame(self) - top_frame.pack(side="top", fill=ctk.X, padx=10) - top_frame.columnconfigure(0, weight=self.__column_weight[0]) - top_frame.columnconfigure(1, weight=self.__column_weight[1]) - top_frame.columnconfigure(2, weight=self.__column_weight[2]) - - # Serial Port - # create label - self.serial_label = ctk.CTkLabel(top_frame, text="串口:", font=self.font) - self.serial_label.grid(column=0, row=0, sticky=ctk.EW, pady=10, padx=10) - # create combobox - self.serial_combobox = ctk.CTkComboBox( - top_frame, - state="readonly", - command=self.selectSerial, - font=self.font, - dropdown_font=self.font, - ) - self.serial_combobox.bind("