def create_frm_right_clear(self): ''' 3、Label显示和十六进制显示和清除接收信息按钮 ''' self.receive_hex_cbtn_var = tk.IntVar() self.frm_right_clear_label = pytk.PyLabel( self.frm_right_clear, text="Data Received" + " " * size_dict["clear_label_width"], font=font) self.frm_right_threshold_label = pytk.PyLabel(self.frm_right_clear, text="Threshold:", font=font) self.thresholdStr = tk.StringVar() self.frm_right_threshold_entry = pytk.PyEntry( self.frm_right_clear, textvariable=self.thresholdStr, width=6, font=font) self.frm_right_hex_checkbtn = pytk.PyCheckbutton( self.frm_right_clear, text="Hex", variable=self.receive_hex_cbtn_var, relief="flat", font=font) self.frm_right_clear_btn = pytk.PyButton(self.frm_right_clear, text="Clear", width=10, font=font, command=self.Clear) self.frm_right_clear_label.grid(row=0, column=0, padx=5, pady=5, sticky="w") self.frm_right_threshold_label.grid(row=0, column=1, padx=5, pady=5, sticky="wesn") self.frm_right_threshold_entry.grid(row=0, column=2, padx=5, pady=5, sticky="wesn") self.frm_right_hex_checkbtn.grid(row=0, column=3, padx=5, pady=5, sticky="wesn") self.frm_right_clear_btn.grid(row=0, column=4, padx=5, pady=5, sticky="wesn") self.thresholdStr.set(1) self.thresholdStr.trace('w', self.GetThresholdValue)
def create_frm_right_clear(self): ''' 3、Label显示和清除接收信息按钮 ''' self.checkValue = tk.IntVar() self.frm_right_clear_label = pytk.PyLabel(self.frm_right_clear, text="Data Received", anchor="w", font=g_font) self.frm_right_threshold_label = pytk.PyLabel(self.frm_right_clear, text="Threshold:", font=g_font) self.threshold_str = tk.StringVar() self.frm_right_threshold_entry = pytk.PyEntry( self.frm_right_clear, textvariable=self.threshold_str, width=6, font=g_font) self.receive_hex_cbtn_var = tk.IntVar() self.frm_right_hex_checkbtn = pytk.PyCheckbutton( self.frm_right_clear, text="Hex", variable=self.receive_hex_cbtn_var, relief="flat", font=g_font) self.frm_right_clear_btn = pytk.PyButton(self.frm_right_clear, text="Clear", width=10, font=g_font) self.frm_right_clear_label.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_right_threshold_label.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT) self.frm_right_threshold_entry.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT) self.frm_right_hex_checkbtn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT) self.frm_right_clear_btn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.RIGHT)
def create_frm_left(self): ''' 上半部分左边窗口: Listbox显示可用的COM口 Button按钮点击连接设备 ''' self.frm_left_label = pytk.PyLabel(self.frm_left, text="Serial Ports", font=font) self.frm_left_listbox = pytk.PyListbox( self.frm_left, height=size_dict["list_box_height"], font=font) self.frm_left_serial_set = pytk.PyLabelFrame(self.frm_left) self.frm_left_btn = pytk.PyButton(self.frm_left, text="Open", font=font, command=self.Toggle) self.frm_left_label.grid(row=0, column=0, padx=5, pady=5, sticky="w") self.frm_left_listbox.grid(row=1, column=0, padx=5, pady=5, sticky="wesn") self.frm_left_serial_set.grid(row=2, column=0, padx=5, pady=5, sticky="wesn") self.frm_left_btn.grid(row=3, column=0, padx=5, pady=5, sticky="wesn") self.frm_left_listbox.bind("<Double-Button-1>", self.Open) self.create_frm_left_serial_set()
def create_frm_left_serial_set(self): ''' 串口配置,比如波特率,奇偶校验等 ''' setting_label_list = [ "BaudRate :", "Parity :", "DataBit :", "StopBit :" ] baudrate_list = [ "1200", "2400", "4800", "9600", "14400", "19200", "38400", "43000", "57600", "76800", "115200", "12800" ] # PARITY_NONE, PARITY_EVEN, PARITY_ODD PARITY_MARK, PARITY_SPACE parity_list = ["N", "E", "O", "M", "S"] bytesize_list = ["5", "6", "7", "8"] stopbits_list = ["1", "1.5", "2"] for index, item in enumerate(setting_label_list): frm_left_label_temp = pytk.PyLabel(self.frm_left_serial_set, text=item, font=('Monaco', 10)) frm_left_label_temp.grid(row=index, column=0, padx=1, pady=2, sticky="e") self.frm_left_combobox_baudrate = ttk.Combobox( self.frm_left_serial_set, width=15, values=baudrate_list) self.frm_left_combobox_parity = ttk.Combobox(self.frm_left_serial_set, width=15, values=parity_list) self.frm_left_combobox_databit = ttk.Combobox(self.frm_left_serial_set, width=15, values=bytesize_list) self.frm_left_combobox_stopbit = ttk.Combobox(self.frm_left_serial_set, width=15, values=stopbits_list) self.frm_left_combobox_baudrate.grid(row=0, column=1, padx=2, pady=2, sticky="e") self.frm_left_combobox_parity.grid(row=1, column=1, padx=2, pady=2, sticky="e") self.frm_left_combobox_databit.grid(row=2, column=1, padx=2, pady=2, sticky="e") self.frm_left_combobox_stopbit.grid(row=3, column=1, padx=2, pady=2, sticky="e") self.frm_left_combobox_baudrate.current(3) self.frm_left_combobox_parity.current(0) self.frm_left_combobox_databit.current(3) self.frm_left_combobox_stopbit.current(0)
def create_frm_right_reset(self): ''' 1、Label显示和重置按钮和发送按钮 ''' self.frm_right_reset_label = pytk.PyLabel(self.frm_right_reset, text="Hex Bytes", font=g_font, anchor="w") self.frm_right_reset_btn = pytk.PyButton(self.frm_right_reset, text="Reset", width=10, font=g_font, command=self.Reset) self.frm_right_send_btn = pytk.PyButton(self.frm_right_reset, text="Send", width=10, font=g_font, command=self.Send) self.frm_right_reset_label.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_right_reset_btn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT) self.frm_right_send_btn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.RIGHT)
def create_frm_mid_rbs(self): self.frm_up_rblabel = pytk.PyLabel(self.frm_mid, text="Output Name:", font=('Monaco', 12)) self.frm_up_rblabel.grid(row=3, column=0, padx=5, pady=5, sticky="wesn") self.savenames = ['stand', 'sit ', 'walk ', 'run ', 'test '] self.frm_up_rbs = [] self.frm_up_radio_intvar = tk.IntVar() for i in range(len(self.savenames)): self.frm_up_rbs.append( pytk.PyRadiobutton(self.frm_mid, text=self.savenames[i], variable=self.frm_up_radio_intvar, value=i, font=("Monaco", 12), command=self.ChangeSaveName())) for index, rbs in enumerate(self.frm_up_rbs): rbs.grid(row=index // 2 + 5, column=index % 2, padx=0, pady=0, sticky="w") self.frm_up_radio_intvar.set(0)
def creat_eeg_frame_left_top(self): self.eeg_frm_l_label = pytk.PyLabel(self.eeg_frame_left_top, text="Serial Ports", font=g_font, anchor="w") self.eeg_frm_l_listbox = pytk.PyListbox(self.eeg_frame_left_top, font=g_font) self.eeg_left_serial_set = pytk.PyLabelFrame(self.eeg_frame_left_top) self.eeg_left_btn = pytk.PyButton(self.eeg_frame_left_top, text="Open", font=g_font, command=self.Toggle) self.eeg_frm_l_label.pack(fill="both", expand=0, padx=5, pady=5) self.eeg_frm_l_listbox.pack(fill="both", expand=1, padx=5, pady=5) self.eeg_left_serial_set.pack(fill="both", expand=0, padx=5, pady=5) self.eeg_left_btn.pack(fill="both", expand=0, padx=5, pady=10) self.eeg_frm_l_listbox.bind("<Double-Button-1>", self.open) eeg_baudrate_list = ["9600", "38400", "57600", "115200"] self.eeg_frm_left_left = pytk.PyFrame( self.eeg_left_serial_set) #左边区域显示标签 self.eeg_frm_left_right = pytk.PyFrame( self.eeg_left_serial_set) #右边区域显示波特率 self.eeg_frm_left_left.pack(fill="both", expand=1, side=tk.LEFT) self.eeg_frm_left_right.pack(fill="both", expand=1, side=tk.RIGHT) self.eeg_frm_left_label_temp = pytk.PyLabel(self.eeg_frm_left_left, text="Baudrate:", font=g_font) self.eeg_frm_left_label_temp.pack(fill="both", expand=1, padx=5, pady=5) self.eeg_frm_left_combobox_baudrate = ttk.Combobox( self.eeg_frm_left_right, width=10, font=g_font, values=eeg_baudrate_list) self.eeg_frm_left_combobox_baudrate.pack(fill="both", expand=1, padx=5, pady=5) self.eeg_frm_left_combobox_baudrate.current(2)
def create_frm_right_reset(self): ''' 1、Label显示和重置按钮和发送按钮 ''' self.frm_right_reset_label = pytk.PyLabel(self.frm_right_reset, text="Hex Bytes", font=g_font, anchor="w") self.frm_right_reset_btn = pytk.PyButton(self.frm_right_reset, text="Reset", width=10, font=g_font, command=self.Reset) self.frm_right_send_btn = pytk.PyButton(self.frm_right_reset, text="Send", width=10, font=g_font, command=self.Send) self.new_line_cbtn_var = tk.IntVar() self.send_hex_cbtn_var = tk.IntVar() self.frm_right_reset_newLine_checkbtn = pytk.PyCheckbutton( self.frm_right_reset, text="New Line", variable=self.new_line_cbtn_var, font=g_font) self.frm_right_reset_hex_checkbtn = pytk.PyCheckbutton( self.frm_right_reset, text="Hex", variable=self.send_hex_cbtn_var, font=g_font) self.frm_right_reset_label.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_right_reset_newLine_checkbtn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT) self.frm_right_reset_hex_checkbtn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT) self.frm_right_reset_btn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT) self.frm_right_send_btn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.RIGHT)
def creat_gsr_frame_left_under(self): self.gsr_status_label = pytk.PyLabel(self.gsr_frame_left_under, text="Ready", font=g_font, wraplength=240, justify='left') self.gsr_status_label.grid(row=0, column=0, padx=5, pady=5, sticky="wesn")
def create_frm_setting(self): self.setting_width_label = pytk.PyLabel(self.frm_setting, font=g_font, text="宽度:") self.setting_width_label.grid(column=0, row=0, padx=5, pady=5) self.setting_width_label = pytk.PyLabel(self.frm_setting, font=g_font, width=5, text="880") self.setting_width_label.grid(column=1, row=0, padx=5, pady=5) self.setting_height_label = pytk.PyLabel(self.frm_setting, font=g_font, text="高度:") self.setting_height_label.grid(column=0, row=1, padx=5, pady=5) self.setting_height_entry = pytk.PyEntry(self.frm_setting, font=g_font, width=5) self.setting_height_entry.grid(column=1, row=1, padx=5, pady=5) self.setting_height_entry.insert(0, '1000') pass
def create_frm_status(self): ''' 下半部分状态栏窗口 ''' self.frm_status_label = pytk.PyLabel(self.frm_status, text="Ready", font=g_font) self.frm_status_label.grid(row=0, column=0, padx=5, pady=5, sticky="wesn")
def create_frm_down_entry(self): self.frm_down_entrylabel = pytk.PyLabel(self.frm_down, text="One time(ms)", font=('Monaco', 12)) self.frm_down_entrylabel.pack(expand="yes", fill="both", padx=5, pady=5) default_val = tk.StringVar() default_val.set("5000") self.frm_down_entry = pytk.PyEntry(self.frm_down, textvariable=default_val) self.frm_down_entry.pack(expand="yes", fill="both", padx=5, pady=5)
def create_frm_up(self): self.frm_up_label = pytk.PyLabel(self.frm_up,\ text=" Serial Ports ",\ font=font) self.frm_up_label.grid(row=0, column=0, padx=5, pady=5, sticky="wesn") self.frm_up_setport = pytk.PyLabelFrame(self.frm_up) self.frm_up_setport.grid(row=1, column=0, padx=5, pady=5, sticky="wesn") self.frm_up_btn = pytk.PyButton(self.frm_up,text="Open",font=font,\ command=self.Open) self.frm_up_btn.grid(row=2, column=0, padx=5, pady=5, sticky="wesn") self.create_frm_up_setport()
def create_frm_right_reset(self): ''' 1、Label显示和重置按钮和发送按钮 ''' self.frm_right_reset_label = pytk.PyLabel( self.frm_right_reset, text="Data Send" + " " * size_dict["reset_label_width"], font=font) self.new_line_cbtn_var = tk.IntVar() self.send_hex_cbtn_var = tk.IntVar() self.frm_right_reset_newLine_checkbtn = pytk.PyCheckbutton( self.frm_right_reset, text="New Line", variable=self.new_line_cbtn_var, font=font) self.frm_right_reset_hex_checkbtn = pytk.PyCheckbutton( self.frm_right_reset, text="Hex", variable=self.send_hex_cbtn_var, font=font) self.frm_right_reset_btn = pytk.PyButton(self.frm_right_reset, text="Reset", width=10, font=font, command=self.Reset) self.frm_right_send_btn = pytk.PyButton(self.frm_right_reset, text="Send", width=10, font=font, command=self.Send) self.frm_right_reset_label.grid(row=0, column=0, sticky="w") self.frm_right_reset_newLine_checkbtn.grid(row=0, column=1, sticky="wesn") self.frm_right_reset_hex_checkbtn.grid(row=0, column=2, sticky="wesn") self.frm_right_reset_btn.grid(row=0, column=3, padx=5, pady=5, sticky="wesn") self.frm_right_send_btn.grid(row=0, column=4, padx=5, pady=5, sticky="wesn")
def create_frm_up_setport(self): port_name_list = [ ' ###1:', ' ###2:', ' ###3:', ' ###4:', " ###5:" ] for index, item in enumerate(port_name_list): frm_up_label_temp = pytk.PyLabel(self.frm_up_setport,\ text=item,\ font=('Monaco', 10)) frm_up_label_temp.grid(row=index + 1, column=0,\ padx=1, pady=2, sticky="wesn") com_id = list(range(-1, 100, 1)) self.frm_up_setport_combobox = [] for i in range(len(port_name_list)): self.frm_up_setport_combobox.append(ttk.Combobox(self.frm_up_setport,\ width=10,\ values=com_id)) for index, item in enumerate(self.frm_up_setport_combobox): item.grid(row=index + 1, column=1,\ padx=1, pady=2, sticky="wesn") item.current(0)
def create_frm_left(self): ''' 上半部分左边窗口: Listbox显示连接的USB设备 Button按钮点击连接设备 ''' self.frm_left_label = pytk.PyLabel(self.frm_left, text="HID Devices", font=g_font, anchor="w") self.frm_left_listbox = pytk.PyListbox(self.frm_left, font=g_font) self.frm_left_btn = pytk.PyButton(self.frm_left, text="Open", font=g_font, command=self.Toggle) self.frm_left_label.pack(fill="both", expand=0, padx=5, pady=5) self.frm_left_listbox.pack(fill="both", expand=1, padx=5, pady=5) self.frm_left_btn.pack(fill="both", expand=0, padx=5, pady=5) self.frm_left_listbox.bind("<Double-Button-1>", self.Open)
def create_frm_right_clear(self): ''' 3、Label显示和清除接收信息按钮 ''' self.checkValue = tk.IntVar() self.frm_right_clear_label = pytk.PyLabel(self.frm_right_clear, text="Data Received", anchor="w", font=g_font) self.frm_right_decimal_checkbtn = pytk.PyCheckbutton( self.frm_right_clear, text="Decimal", variable=self.checkValue, relief="flat", font=g_font) self.frm_right_clear_btn = pytk.PyButton(self.frm_right_clear, text="Clear", width=10, font=g_font, command=self.Clear) self.frm_right_clear_label.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_right_decimal_checkbtn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT) self.frm_right_clear_btn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.RIGHT)
def create_frm_left_serial_set(self): ''' 串口配置,比如波特率,奇偶校验等 ''' setting_label_list = [ "BaudRate :", "Parity :", "DataBit :", "StopBit :" ] baudrate_list = [ "1200", "2400", "4800", "9600", "14400", "19200", "38400", "43000", "57600", "76800", "115200" ] # PARITY_NONE, PARITY_EVEN, PARITY_ODD PARITY_MARK, PARITY_SPACE parity_list = ["N", "E", "O", "M", "S"] bytesize_list = ["5", "6", "7", "8"] stopbits_list = ["1", "1.5", "2"] self.frm_left_left = pytk.PyFrame(self.frm_left_serial_set) self.frm_left_right = pytk.PyFrame(self.frm_left_serial_set) self.frm_left_left.pack(fill="both", expand=1, side=tk.LEFT) self.frm_left_right.pack(fill="both", expand=1, side=tk.RIGHT) for item in setting_label_list: frm_left_label_temp = pytk.PyLabel(self.frm_left_left, text=item, font=g_font) frm_left_label_temp.pack(fill="both", expand=1, padx=5, pady=5) self.frm_left_combobox_baudrate = ttk.Combobox(self.frm_left_right, width=15, font=g_font, values=baudrate_list) self.frm_left_combobox_parity = ttk.Combobox(self.frm_left_right, width=15, font=g_font, values=parity_list) self.frm_left_combobox_databit = ttk.Combobox(self.frm_left_right, width=15, font=g_font, values=bytesize_list) self.frm_left_combobox_stopbit = ttk.Combobox(self.frm_left_right, width=15, font=g_font, values=stopbits_list) self.frm_left_combobox_baudrate.pack(fill="both", expand=1, padx=5, pady=5) self.frm_left_combobox_parity.pack(fill="both", expand=1, padx=5, pady=5) self.frm_left_combobox_databit.pack(fill="both", expand=1, padx=5, pady=5) self.frm_left_combobox_stopbit.pack(fill="both", expand=1, padx=5, pady=5) self.frm_left_combobox_baudrate.current(10) self.frm_left_combobox_parity.current(0) self.frm_left_combobox_databit.current(3) self.frm_left_combobox_stopbit.current(0)