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 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_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_rr(self): ''' Listbox显示可选路线 Button分别为设定路线和启动 ''' self.frm_rr_road = pytk.PyLabelFrame(self.frm_rr) self.frm_rr_btn = pytk.PyLabelFrame(self.frm_rr) self.frm_rr_set = pytk.PyLabelFrame(self.frm_rr) self.frm_rr_road.pack(fill="both", expand=1, padx=2, pady=5, side=tk.TOP) self.frm_rr_btn.pack(fill="both", expand=0, padx=2, pady=5, side=tk.TOP) self.frm_rr_set.pack(fill="both", expand=0, padx=2, pady=5, side=tk.TOP) self.frm_rr_roadfile_list = pytk.PyListbox(self.frm_rr_road, font=g_font) self.frm_rr_road_addBtn = pytk.PyButton(self.frm_rr_road, text=">>", font=g_font, command=self.AddRoad) self.frm_rr_road_delBtn = pytk.PyButton(self.frm_rr_road, text="<<", font=g_font, command=self.DelRoad) self.frm_rr_road_list = pytk.PyListbox(self.frm_rr_road, font=g_font) self.frm_rr_roadfile_list.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_rr_road_addBtn.pack(fill="none", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_rr_road_delBtn.pack(fill="none", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_rr_road_list.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_rr_sendroad_btn = pytk.PyButton(self.frm_rr_btn, text="发送路线", font=g_font, command=self.SendRoadInfo) self.frm_rr_start_btn = pytk.PyButton(self.frm_rr_btn, text=" 启动 ", font=g_font, command=self.SendStart) self.frm_rr_sendroad_btn.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_rr_start_btn.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_rr_entry = pytk.PyEntry(self.frm_rr_set, font=g_font) self.frm_rr_entry.insert(0, '0') self.frm_rr_set_btn = pytk.PyButton(self.frm_rr_set, text="设定起始点", font=g_font, command=self.set_start_point) self.frm_rr_entry.pack(fill="both", expand=1, padx=5, pady=5, side=tk.LEFT) self.frm_rr_set_btn.pack(fill="both", expand=0, padx=5, pady=5, side=tk.LEFT)
def create_frame(self): ''' 创建窗体 ''' self.frm = pytk.PyFrame(self.root) self.frm.pack(fill="both", expand=1) self.import_listbox = pytk.PyListbox(self.frm, font=g_font, selectmode='extended', width=30) self.import_listbox.grid(column=0, row=0, rowspan=2, sticky=tk.N + tk.S, padx=5, pady=5) #self.import_listbox.insert(0,'text') self.add_btn = pytk.PyButton(self.frm, font=g_font, text='>>', command=self.add_codes) self.add_btn.grid(column=1, row=0, sticky=tk.S, padx=5, pady=5) self.del_btn = pytk.PyButton(self.frm, font=g_font, text='<<', command=self.del_codes) self.del_btn.grid(column=1, row=1, sticky=tk.N, padx=5, pady=5) self.code_listbox = pytk.PyListbox(self.frm, font=g_font, selectmode='extended', width=30, fg="red") self.code_listbox.grid(column=2, row=0, rowspan=2, sticky=tk.N + tk.S, padx=5, pady=5) self.preview_canvas = pytk.PyCanvas(self.frm, width=200, height=200) self.preview_canvas.grid(column=3, row=0, rowspan=2, padx=5, pady=5) self.gen_codes_btn = pytk.PyButton(self.frm, text='生成CODE128', command=self.gen_codes) self.gen_codes_btn.grid(column=2, row=2, padx=5, pady=5, sticky=tk.N + tk.S + tk.E + tk.W) self.frm_file = pytk.PyLabelFrame(self.frm) self.frm_file.grid(column=0, row=2, columnspan=2, padx=5, pady=5, sticky=tk.N + tk.S + tk.E + tk.W) self.create_frm_file() self.frm_setting = pytk.PyLabelFrame(self.frm) self.frm_setting.grid(column=3, row=2, padx=5, pady=5, sticky=tk.N + tk.S + tk.E + tk.W) self.create_frm_setting() self.progressbar = ttk.Progressbar(self.frm, value=0) self.progressbar.grid(column=0, row=3, columnspan=4, padx=5, pady=5, sticky=tk.N + tk.S + tk.E + tk.W)