diff --git a/src/main.py b/src/main.py index 640fefc..b1b01da 100644 --- a/src/main.py +++ b/src/main.py @@ -1,19 +1,28 @@ 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 +from typing import Optional, Any +import functools class App(ctk.CTk): __window_width = 1280 - __window_height = 720 - __column_weight = [1, 5] + __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上位机") @@ -31,33 +40,241 @@ class App(ctk.CTk): 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}") - # seperate the column - self.columnconfigure(0, weight=self.__column_weight[0]) - self.columnconfigure(1, weight=self.__column_weight[1]) + # 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(self, text="串口:", font=self.font) - self.serial_label.grid(column=0, row=1, sticky=ctk.EW) + 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( - self, + top_frame, state="readonly", - command=self.updateSerial, + command=self.selectSerial, font=self.font, dropdown_font=self.font, ) - self.serial_combobox.bind() + self.serial_combobox.bind("