def clicked_open_file(): file = filedialog.askopenfilename() open_file_entry.delete(0, 'end') open_file_entry.insert("insert", file) queue = Queue() window = tk.Tk() window.title("UDP Packet Sender") window.geometry('700x450') f_nw = tk.LabelFrame(text='Лог') f_nw.pack(expand="no", fill='x') txt = scrolledtext.ScrolledText(f_nw, width=80, height=12) txt.pack(side='left', expand="yes", fill='x') f_south = tk.LabelFrame(text='Управление') f_south.pack(expand="yes", fill='both') f_net_param = tk.LabelFrame(f_south, text='Параметры сетевого соединения') f_net_param.pack(expand="no") f_IP = tk.LabelFrame(f_net_param, text='IP адрес', labelanchor='n') f_IP.pack(side='left', anchor='n') IP_entry = tk.Entry(f_IP, width=14) IP_entry.insert('end', '127.0.0.1') IP_entry.pack(side='bottom', padx=5, pady=5)
tab1 = ttk.Frame(tabs, width=50, height=50) tab2 = ttk.Frame(tabs) tabs.add(tab1, text="Line") tabs.add(tab2, text="Scatter", compound=tk.LEFT) # radio button method = tk.StringVar() tk.Radiobutton(frame2, text="m1: ", value="m1", variable=method).place(x=580, y=100) tk.Radiobutton(frame2, text="m2: ", value="m2", variable=method).place(x=580, y=125) # label frame: result label_frame = tk.LabelFrame(frame2, text="Result", width=100, height=150) label_frame.place(x=580, y=25) tk.Label(label_frame, text="Buy: ", bd=3).grid(row=0, column=0) tk.Label(label_frame, text="Sell: ", bd=3).grid(row=1, column=0) # buy sell labels buy_value = tk.Label(label_frame, text="1", bd=3) buy_value.grid(row=0, column=1) sell_value = tk.Label(label_frame, text="0", bd=3) sell_value.grid(row=1, column=1) def moving_average(a, n=50): ret = np.cumsum(a, dtype=float) ret[n:] = ret[n:] - ret[:-n] return ret[n - 1:] / n
def __init__(self, master): self.relayTaskHandle = [None for i in range(NUMBER_OF_CHANNELS)] self.timerTaskHandle = [None for i in range(NUMBER_OF_CHANNELS)] self.stopEventHandle = [1 for i in range(NUMBER_OF_CHANNELS)] self.master = master self.master.title("Power Cycling Test UI") self.master.geometry("740x420") # set up the options pane self.testOptionFrame = tkinter.LabelFrame(self.master, text="Test Options").place( x=OPTIONS_FRAME_OFFSET_X, y=OPTIONS_FRAME_OFFSET_Y, width=420, height=380) # set up enable label self.enableLabel = tkinter.StringVar() tkinter.Label(self.testOptionFrame, textvariable=self.enableLabel).place( x=OPTIONS_FRAME_OFFSET_X + 15, y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y) self.enableLabel.set("Enable") # set up period label self.periodLabel = tkinter.StringVar() tkinter.Label(self.testOptionFrame, textvariable=self.periodLabel).place( x=OPTIONS_FRAME_OFFSET_X + 75, y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y) self.periodLabel.set("Period(s)") # set up duty cycle label self.dutyCycleLabel = tkinter.StringVar() tkinter.Label(self.testOptionFrame, textvariable=self.dutyCycleLabel).place( x=OPTIONS_FRAME_OFFSET_X + 133, y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y) self.dutyCycleLabel.set("Duty Cycle(%)") # set up number of cycles label self.noOfCyclesLabel = tkinter.StringVar() tkinter.Label(self.testOptionFrame, textvariable=self.noOfCyclesLabel).place( x=OPTIONS_FRAME_OFFSET_X + 220, y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y) self.noOfCyclesLabel.set("No. of Cycles") # set up the status pane self.statusFrame = tkinter.LabelFrame( self.master, text="Test Status").place( x=OPTIONS_FRAME_OFFSET_X + OPTIONS_TO_STATUS_FRAME_OFFSET, y=OPTIONS_FRAME_OFFSET_Y, width=290, height=380) # set up on/off label self.onOffLabel = tkinter.StringVar() tkinter.Label(self.statusFrame, textvariable=self.onOffLabel).place( x=OPTIONS_FRAME_OFFSET_X + OPTIONS_TO_STATUS_FRAME_OFFSET + 15, y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y) self.onOffLabel.set("On/Off") # set up cycle count label self.cycleCountLabel = tkinter.StringVar() tkinter.Label( self.statusFrame, textvariable=self.cycleCountLabel).place( x=OPTIONS_FRAME_OFFSET_X + OPTIONS_TO_STATUS_FRAME_OFFSET + 70, y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y) self.cycleCountLabel.set("Cycle Count") # set up test time label self.testTimeLabel = tkinter.StringVar() tkinter.Label(self.statusFrame, textvariable=self.testTimeLabel).place( x=OPTIONS_FRAME_OFFSET_X + OPTIONS_TO_STATUS_FRAME_OFFSET + 150, y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y) self.testTimeLabel.set("Test Time(HH:MM:SS)") self.enableChButtonVars = [] self.periodEntries = [] self.dutyCycleEntries = [] self.numOfCycleEntries = [] self.chStartButtons = [] self.chStopButtons = [] self.chStateEntries = [] self.chCycleCountEntries = [] self.chTestTimeEntries = [] for i in range(0, NUMBER_OF_CHANNELS): # set up enable checkboxes with labels self.enableChButtonVars.append(tkinter.IntVar()) self.enableChButtonVars[i].set(i + 1) tkinter.Label(self.testOptionFrame, text="Ch " + str(i)).place( y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + 15) tkinter.Checkbutton( self.testOptionFrame, variable=self.enableChButtonVars[i], onvalue=i + 1, offvalue=-(i + 1), command=(lambda j=self.enableChButtonVars[ i]: self.enable_ch_button_press(j))).place( y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y + 25 + i * 30, x=OPTIONS_FRAME_OFFSET_X + 45) # set up period entry boxes self.periodEntries.append(tkinter.StringVar()) tkinter.Entry(self.testOptionFrame, textvariable=self.periodEntries[i]).place( y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + 80, width=45) # set up duty cycle entry boxes self.dutyCycleEntries.append(tkinter.StringVar()) tkinter.Entry(self.testOptionFrame, textvariable=self.dutyCycleEntries[i]).place( y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + 150, width=45) # set up number of cycles entry boxes self.numOfCycleEntries.append(tkinter.StringVar()) tkinter.Entry(self.testOptionFrame, textvariable=self.numOfCycleEntries[i]).place( y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + 220, width=45) # set up the channel start buttons self.chStartButtons.append( tkinter.Button( self.testOptionFrame, text="start", command=( lambda j=self.enableChButtonVars[i]: self.start(j)))) self.chStartButtons[i].place(y=OPTIONS_FRAME_OFFSET_Y + LABEL_OFFSET + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + 290) # set up the channel start buttons self.chStopButtons.append( tkinter.Button( self.testOptionFrame, text="stop", command=( lambda j=self.enableChButtonVars[i]: self.stop(j)))) self.chStopButtons[i].place(y=OPTIONS_FRAME_OFFSET_Y + LABEL_OFFSET + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + 350) # set up on/off entry boxes self.chStateEntries.append(tkinter.StringVar()) tkinter.Entry( self.statusFrame, textvariable=self.chStateEntries[i], bg="gray90").place(y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + OPTIONS_TO_STATUS_FRAME_OFFSET + 15, width=45) self.chStateEntries[i].set("Off") # set cycle count entry boxes self.chCycleCountEntries.append(tkinter.StringVar()) tkinter.Entry( self.statusFrame, textvariable=self.chCycleCountEntries[i], bg="gray90").place(y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + OPTIONS_TO_STATUS_FRAME_OFFSET + 85, width=45) self.chCycleCountEntries[i].set("0") # set test time entry boxes self.chTestTimeEntries.append(tkinter.StringVar()) tkinter.Entry( self.statusFrame, textvariable=self.chTestTimeEntries[i], bg="gray90").place(y=LABEL_OFFSET + OPTIONS_FRAME_OFFSET_Y + LABEL_TO_ELEMENT_OFFSET + i * 30, x=OPTIONS_FRAME_OFFSET_X + OPTIONS_TO_STATUS_FRAME_OFFSET + 155, width=115) self.chTestTimeEntries[i].set("0") self.allStartButton = tkinter.Button(self.testOptionFrame, text="Start All Channels", command=lambda: self.start_all()) self.allStartButton.place(y=OPTIONS_FRAME_OFFSET_Y + LABEL_OFFSET + LABEL_TO_ELEMENT_OFFSET + NUMBER_OF_CHANNELS * 30, x=OPTIONS_FRAME_OFFSET_X + 15, width=390) self.allStopButton = tkinter.Button(self.testOptionFrame, text="Stop All Channels", command=lambda: self.stop_all()) self.allStopButton.place(y=OPTIONS_FRAME_OFFSET_Y + LABEL_OFFSET + LABEL_TO_ELEMENT_OFFSET + NUMBER_OF_CHANNELS * 30 + 30, x=OPTIONS_FRAME_OFFSET_X + 15, width=390)
def create_hook_settings(self): # Frame for config elements self.mainframe = tk.LabelFrame(self.parent, background='#ededed') self.mainframe.grid(column=0, row=5, sticky='we', padx=10) self.mainframe.visible = False self.mainframe.row = 5 # Creating Failure hook label and textbox self.failurelabel = tk.Label(self.mainframe, text='Failure Hook') self.failureentry = tk.Entry(self.mainframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.failureentry.insert(0, self.config["FailureHook"]) self.failurelabel.grid(column=0, row=0, sticky='w', padx=(10, 10), pady=(10, 5)) self.failureentry.grid(column=1, row=0, sticky='e', padx=(0, 10), pady=(10, 5)) # Creating Warning hook label and textbox self.warninglabel = tk.Label(self.mainframe, text='Warning Hook') self.warningentry = tk.Entry(self.mainframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.warningentry.insert(0, self.config["WarningHook"]) self.warninglabel.grid(column=0, row=1, sticky='w', padx=(10, 10), pady=5) self.warningentry.grid(column=1, row=1, sticky='e', padx=(0, 10), pady=5) # Creating Weekly Reports hook label and textbox self.weeklylabel = tk.Label(self.mainframe, text='Weekly Reports Hook') self.weeklyentry = tk.Entry(self.mainframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.weeklyentry.insert(0, self.config["WeeklyReportHook"]) self.weeklylabel.grid(column=0, row=2, sticky='w', padx=(10, 10), pady=5) self.weeklyentry.grid(column=1, row=2, sticky='e', padx=(0, 10), pady=5) # Creating Daily reports hook label and textbox self.dailylabel = tk.Label(self.mainframe, text='Daily Reports Hook') self.dailyentry = tk.Entry(self.mainframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.dailyentry.insert(0, self.config["DailyReportHook"]) self.dailylabel.grid(column=0, row=3, sticky='w', padx=(10, 10), pady=(5, 10)) self.dailyentry.grid(column=1, row=3, sticky='e', padx=(0, 10), pady=(5, 10)) # Mainframe grid weight setup self.mainframe.grid_columnconfigure(0, weight=1) self.mainframe.grid_columnconfigure(1, weight=1) self.mainframe.grid_rowconfigure(0, weight=1) self.mainframe.grid_rowconfigure(1, weight=1) self.mainframe.grid_rowconfigure(2, weight=1) self.mainframe.grid_rowconfigure(3, weight=1)
def __init__(self, parent, *args, **kwargs): tk.Frame.__init__(self, parent, *args, **kwargs) self.parent = parent self.parent.title('CK Raporty') self.prices = {'full_set': 200, 'fum': 50, 'leak': 70 } self.day_info = {'date':'', 'worker_name': '', 'no_full_set': 0, 'no_fum': 0, 'no_leak': 0, 'random_sets': {}, 'money_earned': 0 } # Label and entry for inserting date of raport self.date_label = tk.Label(parent, text='Wprowadź datę') self.date_entry = tk.Entry(parent) # Label and entry for inserting name of the worker self.name_label = tk.Label(parent, text='Wprowadź imię i nazwisko') self.name_entry = tk.Entry(parent) # Labels and buttons for normal full_set self.full_set_label = tk.Label(parent, text='Komplet (200 zł)') self.full_set_fr = tk.Frame(parent) self.full_set_minus = tk.Button(self.full_set_fr, text='-', command=lambda: self.decrease_sum(kind='full_set')) self.full_set_amount = tk.Label(self.full_set_fr, text='0') self.full_set_plus = tk.Button(self.full_set_fr, text='+', command=lambda: self.increase_sum(kind='full_set')) # Labels and buttons for normal full_set self.leakiness_label = tk.Label(parent, text='Nieszczelność') self.leakiness_fr = tk.Frame(parent) self.leakiness_minus = tk.Button(self.leakiness_fr, text='-', command= lambda: self.decrease_sum('leak')) self.leakiness_amount = tk.Label(self.leakiness_fr, text='0') self.leakiness_plus = tk.Button(self.leakiness_fr, text='+', command= lambda: self.increase_sum(kind='leak')) # Labels and buttons for normal full_set self.ac_fumigation_label = tk.Label(parent, text='Odgrzybianie') self.ac_fumigation_fr = tk.Frame(parent) self.ac_fumigation_minus = tk.Button(self.ac_fumigation_fr, text='-', command= lambda: self.decrease_sum(kind='fum')) self.ac_fumigation_amount = tk.Label(self.ac_fumigation_fr, text='0') self.ac_fumigation_plus = tk.Button(self.ac_fumigation_fr, text='+', command= lambda: self.increase_sum(kind='fum')) self.rand_price_label = tk.Label(parent, text='Komplet (Ponad 200 zł)') self.rand_price_fr = tk.Frame(parent) self.rand_price_entry = tk.Entry(self.rand_price_fr, width=12) self.rand_price_increase_sum = tk.Button(self.rand_price_fr, text='Dodaj', command=self.increase_sum_random_money) # Labels that show how much money were earned during that day self.sum_frame = tk.LabelFrame(parent, text='Suma') # self.sum_label = tk.Label(self.sum_frame, text='Suma=').grid(row=3,column=0, sticky=tk.E) self.sum_value_label = tk.Label(self.sum_frame, text=str(self.day_info['money_earned']), borderwidth=2, relief='solid', width=12, anchor='e', padx=5) # Button that triggers confirmation and sending of a raport self.confirm_btn = tk.Button(parent, text='Zatwierdź i wyślij raport', command= lambda: self.confirm_raport(self.day_info)) self.setup_grid()
def __init__(self, parent, root): super().__init__(parent) self.tool = interTool() self.label = tk.Label(self, text="谁是幸运儿!!!", font=LARGE_FONT, bg='green', fg='white') # self.label.pack(pady=10, padx=10) self.label.place(x=WIDTH / 2 - 100, y=10, width=200, height=25) # -------------------------------------------- 选组 self.LabelsFrame1 = tk.LabelFrame(self, text="哪组会中奖?", padx=35, pady=35) # self.LabelsFrame1.pack() self.LabelsFrame1.place(x=20, y=50, width=WIDTH / 2 - 30, height=HEIGHT - 200) self.first = tk.Label(self.LabelsFrame1, text='???', font=("宋体", 20, "normal"), pady=15) self.first.pack() self.second = tk.Label(self.LabelsFrame1, text='???', font=("宋体", 30, "normal"), pady=25) self.second['fg'] = 'red' self.second.pack() self.third = tk.Label(self.LabelsFrame1, text='???', font=("宋体", 20, "normal"), pady=15) self.third.pack() self.frame1 = tk.Frame(self.LabelsFrame1, width=120, height=50, pady=10, padx=10) self.frame1.pack() self.btnStart = tk.Button(self.frame1, text='开始', bg='green', fg='white', command=self.butStartClick) self.btnStart.place(x=0, y=5, width=45, height=25) self.butStop = tk.Button(self.frame1, text='停止', bg='green', fg='white', command=self.btnStopClick) self.butStop.place(x=50, y=5, width=45, height=25) # -------------------------------------------- 选人 self.LabelsFrame2 = tk.LabelFrame(self, text="哪位同学展示?", padx=35, pady=35) # self.LabelsFrame2.pack() self.LabelsFrame2.place(x=WIDTH / 2 + 20, y=50, width=WIDTH / 2 - 30, height=HEIGHT - 200) self.first2 = tk.Label(self.LabelsFrame2, text='???', font=("宋体", 20, "normal"), pady=15) self.first2.pack() self.second2 = tk.Label(self.LabelsFrame2, text='???', font=("宋体", 30, "normal"), pady=25) self.second2['fg'] = 'red' self.second2.pack() self.third2 = tk.Label(self.LabelsFrame2, text='???', font=("宋体", 20, "normal"), pady=15) self.third2.pack() self.frame2 = tk.Frame(self.LabelsFrame2, width=120, height=50, pady=10, padx=10) self.frame2.pack() self.btnStart2 = tk.Button(self.frame2, text='开始', bg='green', fg='white', command=self.butStartClick2) self.btnStart2.place(x=0, y=5, width=45, height=25) self.butStop2 = tk.Button(self.frame2, text='停止', bg='green', fg='white', command=self.btnStopClick2) self.butStop2.place(x=50, y=5, width=45, height=25) # LabelFrame self.speed = 0.02 # 滚动速度 self.Groupflag = True self.Memberflag = True self.LuckyGroup = 0 self.LuckyMember = '' self.GroupInfo, self.Groups, self.Finished, self.group_single = self.tool.PageSign_init( ) self.differenceGroup = list( set(self.Groups).difference(set(self.Finished))) self.Members = []
def create_email_settings(self): # Frame for email elements self.emailframe = tk.LabelFrame(self.parent, background='#ededed') self.emailframe.grid(column=0, row=1, sticky='we', padx=10, pady=(0, 5)) self.emailframe.visible = False self.emailframe.row = 1 # Creating email name label and textbox self.emaillabel = tk.Label(self.emailframe, text='Email') self.emailentry = tk.Entry(self.emailframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.emailentry.insert(0, self.config["Email"]) self.emaillabel.grid(column=0, row=0, sticky='w', padx=(10, 0), pady=(10, 5)) self.emailentry.grid(column=1, row=0, sticky='e', padx=(0, 10), pady=(10, 5)) # Creating email password label and textbox self.passlabel = tk.Label(self.emailframe, text='Password') self.passentry = tk.Entry(self.emailframe, show="*", width=35, justify=tk.LEFT, highlightbackground='#ededed') self.passentry.insert(0, encryption.get_password()) self.passlabel.grid(column=0, row=1, sticky='w', padx=(10, 0), pady=5) self.passentry.grid(column=1, row=1, sticky='e', padx=(0, 10), pady=5) # Creating email type dropdown self.servertypechoices = {"SMTP", "Exchange"} self.servertypevar = tk.StringVar(self.emailframe) if self.config["EmailServerType"] == "": self.servertypevar.set("SMTP") else: self.servertypevar.set(self.config["EmailServerType"]) self.servertype = tk.OptionMenu(self.emailframe, self.servertypevar, *self.servertypechoices) self.servertypelabel = tk.Label(self.emailframe, text='Email Server Type') self.servertypelabel.grid(column=0, row=2, sticky='w', padx=(10, 0), pady=0) self.servertype.grid(column=1, row=2, sticky='w', padx=(15, 10), pady=0) # Creating email server label and textbox self.serverlabel = tk.Label(self.emailframe, text='Email Server') self.serverentry = tk.Entry(self.emailframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') if not self.config["EmailServer"] == "": self.serverentry.insert(0, self.config["EmailServer"]) self.serverlabel.grid(column=0, row=3, sticky='w', padx=(10, 0), pady=5) self.serverentry.grid(column=1, row=3, sticky='e', padx=(0, 10), pady=5) # Creating email server label and textbox self.portlabel = tk.Label(self.emailframe, text='Email Server Port') self.portentry = tk.Entry(self.emailframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') if not self.config["EmailServerPort"] == "": self.portentry.insert(0, self.config["EmailServerPort"]) self.portlabel.grid(column=0, row=4, sticky='w', padx=(10, 0), pady=5) self.portentry.grid(column=1, row=4, sticky='e', padx=(0, 10), pady=5) self.checkemailbutton = tk.Button(self.emailframe, pady=5, padx=5, text="Test Connection to Email", command=self.test_email) self.checkemailbutton.grid(column=1, row=5, padx=10, pady=(0, 10), sticky="e") # Emailframe grid weight setup self.emailframe.grid_columnconfigure(0, weight=1) self.emailframe.grid_columnconfigure(1, weight=1) self.emailframe.grid_rowconfigure(0, weight=1) self.emailframe.grid_rowconfigure(1, weight=1) self.emailframe.grid_rowconfigure(2, weight=1) self.emailframe.grid_rowconfigure(3, weight=1) self.emailframe.grid_rowconfigure(4, weight=1) self.emailframe.grid_rowconfigure(5, weight=1)
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) control_btn = tk.Button( controller.tabBar, text='Data', bg=tabBar_color, activebackground=tabBarActive_color, bd=0, command=lambda: controller.show_frame(DataPage)) control_btn.pack(side='left', expand=True, fill='both') self.graph = AutoLiveGraph(self, timeVector, dataVector) self.graph.place(relx=0, rely=0, relheight=0.9, relwidth=0.8) self.status = tk.StringVar() self.status.set('Ready for Breath Sample') self.progressTitle = tk.Label(self, textvariable=self.status, anchor='w') self.progressTitle.place(relx=0, rely=0.9, relheight=0.07, relwidth=0.8) self.progressbar = ttk.Progressbar(self, orient='horizontal', mode='determinate', maximum=100) self.progressbar.place(relx=0, rely=0.97, relheight=0.03, relwidth=0.8) self.run_and_stop = tk.Frame(self) self.run_and_stop.place(relx=0.8, rely=0.9, relheight=0.1, relwidth=0.2) self.run_and_stop.grid_rowconfigure( 0, weight=1) #DO NOT ADJUST. Forces buttons to overlap. self.run_and_stop.grid_columnconfigure(0, weight=1) #DO NOT ADJUST. self.stopBtn = tk.Button(self.run_and_stop, text='STOP', bg=stopBtn_color, activebackground=stopBtn_color, command=lambda: end_testing()) self.stopBtn.grid(row=0, column=0, sticky="nsew") # self.contFill = tk.Button(self.run_and_stop, text='CONTINUE', bg=runBtn_color, activebackground=runBtn_color, command=lambda:start_fill_thread()) # self.contFill.grid(row=0, column=0, sticky="nsew") self.runBtn = tk.Button(self.run_and_stop, text='RUN', bg=runBtn_color, activebackground=runBtn_color, command=lambda: start_purge_thread()) self.runBtn.grid(row=0, column=0, sticky="nsew") statusFrame = tk.LabelFrame(self, text='Status') statusFrame.place(relx=0.8, rely=0.3, relheight=0.6, relwidth=0.2) stat_pump_lbl = tk.Label(statusFrame, text='PUMP: ', anchor='w') stat_pump_lbl.place(relx=0, rely=0, relheight=0.1, relwidth=(1 - 0.4)) # stat_Valve1_lbl = tk.Label(statusFrame, text= 'Valve 1: ', anchor='w') # stat_Valve1_lbl.place(relx=0,rely=0.1,relheight=0.1,relwidth=(1-0.4)) # stat_Valve2_lbl = tk.Label(statusFrame, text='Valve 2: ', anchor='w') # stat_Valve2_lbl.place(relx=0,rely=0.2,relheight=0.1,relwidth=(1-0.4)) stat_LA_lbl = tk.Label(statusFrame, text='LA: ', anchor='w') stat_LA_lbl.place(relx=0, rely=0.1, relheight=0.1, relwidth=(1 - 0.4)) stat_pump = tk.Label(statusFrame, text=pump.state, anchor='w') stat_pump.place(relx=.4, rely=0, relheight=0.1, relwidth=(1 - 0.4)) # stat_Valve1 = tk.Label(statusFrame, text=inValve.state, anchor='w') # stat_Valve1.place(relx=.4,rely=0.1,relheight=0.1,relwidth=(1-0.4)) # stat_Valve2 = tk.Label(statusFrame, text=outValve.state, anchor='w') # stat_Valve2.place(relx=.4,rely=0.2,relheight=0.1,relwidth=(1-0.4)) stat_LA = tk.Label(statusFrame, text=linearActuator.state, anchor='w') stat_LA.place(relx=.2, rely=0.1, relheight=0.1, relwidth=(1 - 0.4)) responseFrame = tk.Frame(self) responseFrame.place(relx=0.8, rely=0, relheight=0.3, relwidth=0.2) self.naturalGasLabel = tk.Label(responseFrame, text='THC\n Detected', relief='groove', borderwidth=2, anchor='center') self.naturalGasLabel.place(relx=0, rely=0, relheight=0.7, relwidth=1) self.orig_color = self.naturalGasLabel.cget( "background") # Store the original color of the label.
def __init__(self, parent, controller): tk.Frame.__init__(self, parent) control_btn = tk.Button( controller.tabBar, text='Manual Controls', bg=tabBar_color, activebackground=tabBarActive_color, bd=0, command=lambda: controller.show_frame(ManualControlPage)) control_btn.pack(side='left', expand=True, fill='both') #Create a termial within a parent frame. terminal = tk.Frame(self) CoreGUI(terminal) terminal.place(relx=0.7, rely=0, relheight=1, relwidth=0.3) controlFrame = tk.LabelFrame(self, text='System') controlFrame.place(relx=0, rely=0, relheight=1, relwidth=0.7) leftControlFrame = tk.Frame(controlFrame) leftControlFrame.place(relx=0, rely=0, relheight=1, relwidth=0.5) rightControlFrame = tk.Frame(controlFrame) rightControlFrame.place(relx=0.5, rely=0, relheight=1, relwidth=0.5) buttonWidth = 0.4 #Relative width of buttons within the frame self.btn_1 = tk.Button( controlFrame, text='Extend Linear Actuator', command=lambda: linearActuator.extend( )) #,app.frames[DataPage].stat_LA.set(linearActuator.state)]) self.btn_1.place(relx=0, rely=0, relheight=0.1, relwidth=buttonWidth) self.btn_2 = tk.Button( controlFrame, text='Retract Linear Actuator', command=lambda: linearActuator.retract( )) #,app.frames[DataPage].stat_LA.set(linearActuator.state)]) self.btn_2.place(relx=0, rely=0.1, relheight=0.1, relwidth=buttonWidth) # self.btn_3 = tk.Button(controlFrame, text='Default Linear Actuator', command=lambda:linearActuator.default())#,app.frames[DataPage].stat_LA.set(linearActuator.state)]) # self.btn_3.place(relx=0,rely=0.2,relheight=0.1,relwidth=buttonWidth) self.btn_4 = tk.Button(controlFrame, text='Read Sensors', command=lambda: all_sensors.print()) self.btn_4.place(relx=0, rely=0.3, relheight=0.1, relwidth=buttonWidth) self.btn_5 = tk.Button(controlFrame, text='Read Temperature Sensor', command=lambda: temperatureSensor.print()) self.btn_5.place(relx=0, rely=0.4, relheight=0.1, relwidth=buttonWidth) # self.btn_6 = tk.Button(controlFrame, text='Switch Valve 1', command=lambda:valve1.switch())#,app.frames[DataPage].stat_valve1.set(inValve.state)]) # self.btn_6.place(relx=0,rely=0.5,relheight=0.1,relwidth=buttonWidth) # self.btn_7 = tk.Button(controlFrame, text='Switch Valve 2', command=lambda:valve2.switch())#,app.frames[DataPage].stat_valve2.set(outValve.state)]) # self.btn_7.place(relx=0,rely=0.6,relheight=0.1,relwidth=buttonWidth) self.btn_8 = tk.Button( controlFrame, text='Switch Pump', command=lambda: pump.switch( )) #,app.frames[DataPage].stat_pump.set(pump.state)]) self.btn_8.place(relx=0, rely=0.5, relheight=0.1, relwidth=buttonWidth) # self.btn_9 = tk.Button(controlFrame, text='Read Pressure', command=lambda:pressureSensor.print()) # self.btn_9.place(relx=0,rely=0.8,relheight=0.1,relwidth=buttonWidth) lbl_1 = tk.Label( controlFrame, text=' Extend the linear actuator to the sensing chamber.', anchor='w') lbl_1.place(relx=buttonWidth, rely=0, relheight=0.1, relwidth=(1 - buttonWidth)) lbl_2 = tk.Label( controlFrame, text=' Retract the linear actuator to the clean chamber.', anchor='w') lbl_2.place(relx=buttonWidth, rely=0.1, relheight=0.1, relwidth=(1 - buttonWidth)) # lbl_3 = tk.Label(controlFrame, text=' Reset the linear to the default (center) position.', anchor='w') # lbl_3.place(relx=buttonWidth,rely=0.2,relheight=0.1,relwidth=(1-buttonWidth)) lbl_4 = tk.Label( controlFrame, text=' Read the current value of the MOS (gas) sensors.', anchor='w') lbl_4.place(relx=buttonWidth, rely=0.3, relheight=0.1, relwidth=(1 - buttonWidth)) lbl_5 = tk.Label( controlFrame, text=' Read the current internal temperature of the device.', anchor='w') lbl_5.place(relx=buttonWidth, rely=0.4, relheight=0.1, relwidth=(1 - buttonWidth)) # lbl_6 = tk.Label(controlFrame, text=' Toggle the inlet valve.', anchor='w') # lbl_6.place(relx=buttonWidth,rely=0.5,relheight=0.1,relwidth=(1-buttonWidth)) # lbl_7 = tk.Label(controlFrame, text=' Toggle the outlet valve.', anchor='w') # lbl_7.place(relx=buttonWidth,rely=0.6,relheight=0.1,relwidth=(1-buttonWidth)) lbl_8 = tk.Label(controlFrame, text=' Toggle the pump.', anchor='w') lbl_8.place(relx=buttonWidth, rely=0.5, relheight=0.1, relwidth=(1 - buttonWidth))
# add Listbox Class Widget to frame_2 tk.Label(frame_2, text='Below is an example of listbox widget:').pack() listbox = tk.Listbox(frame_2, height=4) for line in ['Listbox Choice 1', 'Choice 2', 'Choice 3', 'Choice 4']: listbox.insert(tk.END, line) listbox.pack() # spinbox widget tk.Label(frame_2, text='Below is an example of spinbox:').pack() tk.Spinbox(frame_2, values=(1, 2, 4, 8, 10)).pack() # scale widget tk.Scale(frame_2, from_=0.0, to=100.0, label='Scale Widget', orient=tk.HORIZONTAL).pack() # LabelFrame label_frame = tk.LabelFrame(frame_2, text='LabelFrame', padx=10, pady=10) label_frame.pack(padx=10, pady=10) tk.Entry(label_frame).pack() tk.Message(frame_2, text='I am a Message widget').pack() # # # Frame 3 # frame_3 = tk.Frame(root, bd=2, relief=tk.SUNKEN) # text widget and associated Scrollbar widget text = tk.Text(frame_3, height=10, width=40) file_object = open('textcontent.txt')
def __init__(self): super().__init__() self.title("Shield Tester v{}".format(VERSION)) self._runtime = 0 self._shield_tester = st.ShieldTester() self._test_case = None # type: st.TestCase self._lockable_ui_elements = list() # tab_name used as key for tabs self._active_tab_name = "" self._tabs = dict() # type: Dict[str, TabData] self.bind(ShieldTesterUi.EVENT_COMPUTE_OUTPUT, lambda e: self._event_process_output(e)) self.bind(ShieldTesterUi.EVENT_COMPUTE_COMPLETE, lambda e: self._event_compute_complete(e)) self.bind(ShieldTesterUi.EVENT_COMPUTE_CANCELLED, lambda e: self._event_compute_cancelled(e)) self.bind(ShieldTesterUi.EVENT_PROGRESS_BAR_STEP, lambda e: self._event_progress_bar_step(e)) self.bind(ShieldTesterUi.EVENT_WARNING_WRITE_LOGFILE, lambda e: self._event_show_warning_logfile(e)) self._message_queue = queue.SimpleQueue() # add some padding tk.Frame(self, width=10, height=10).grid(row=0, column=0, sticky=tk.N) tk.Frame(self, width=10, height=10).grid(row=2, column=3, sticky=tk.N) # --------------------------------------------------------------------------------------------------- # menu menu_bar = tk.Menu(self, tearoff=False) self.config(menu=menu_bar) ship_menu = tk.Menu(self, tearoff=False) ship_menu.add_command(label="Import...", command=self._open_import_window) ship_menu.add_command(label="Load journal...", command=self._load_journal_log) menu_bar.add_cascade(label="Ship", menu=ship_menu) def headline(frame, title, h_row): # headline, use this instead of LabelFrame to keep using the same grid ttk.Separator(frame, orient=tk.HORIZONTAL).grid( row=h_row, columnspan=2, sticky=tk.EW, pady=(3 * ShieldTesterUi.PADDING, 0)) h_row += 1 tk.Label(frame, text=title, justify=tk.CENTER).grid(row=h_row, columnspan=2, sticky=tk.EW) h_row += 1 ttk.Separator(frame, orient=tk.HORIZONTAL).grid(row=h_row, columnspan=2, sticky=tk.EW) return h_row # --------------------------------------------------------------------------------------------------- # left frame left_frame = tk.LabelFrame(self, borderwidth=1, text="Config") left_frame.grid(row=1, column=1, sticky=tk.NSEW) row = 0 tk.Label(left_frame, text="Name of test (optional)").grid( row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._test_name = TextEntry(left_frame) self._test_name.grid(row=row, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._test_name) row += 1 row = headline(left_frame, "[Defender]", row) row += 1 tk.Label(left_frame, text="Choose a ship").grid(row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._ship_select_var = tk.StringVar(self) self._ship_select_var.set("no data yet") self._ship_select = tk.OptionMenu(left_frame, self._ship_select_var, "", command=self._ship_select_command) self._ship_select.grid(row=row, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) row += 1 tk.Label(left_frame, text="Class of shield generator").grid( row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._sg_class_slider = tk.Scale( left_frame, from_=1, to=8, orient=tk.HORIZONTAL, length=175, takefocus=True, command=self._set_shield_class_command) self._sg_class_slider.config(state=tk.DISABLED) self._sg_class_slider.grid(row=row, column=1, sticky=tk.E, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._sg_class_slider) row += 1 tk.Label(left_frame, text="Number of boosters").grid(row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._booster_slider = tk.Scale( left_frame, from_=0, to=8, orient=tk.HORIZONTAL, length=175, takefocus=True, command=self._set_number_of_boosters_command) self._booster_slider.set(7) self._booster_slider.grid(row=row, column=1, sticky=tk.E, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._booster_slider) row += 1 tk.Label(left_frame, text="Shield cell bank hit point pool").grid( row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._scb_hitpoints = IntegerEntry(left_frame) self._scb_hitpoints.grid(row=row, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._scb_hitpoints) row += 1 tk.Label(left_frame, text="Guardian shield reinforcement hit point pool").grid( row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._guardian_hitpoints = IntegerEntry(left_frame) self._guardian_hitpoints.grid(row=row, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._guardian_hitpoints) row += 1 tk.Label(left_frame, text="Access to prismatic shields").grid( row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._usePrismatic = tk.IntVar(self) self._usePrismatic.set(1) self._prismatic_check_button = tk.Checkbutton( left_frame, variable=self._usePrismatic, command=self._set_prismatic_shields_command) self._prismatic_check_button.grid(row=row, column=1, sticky=tk.W, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._prismatic_check_button) row += 1 row = headline(left_frame, "[Attacker]", row) row += 1 tk.Label(left_frame, text="Explosive DPS").grid(row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._explosive_dps_entry = IntegerEntry(left_frame) self._explosive_dps_entry.grid(row=row, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._explosive_dps_entry) row += 1 tk.Label(left_frame, text="Kinetic DPS").grid(row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._kinetic_dps_entry = IntegerEntry(left_frame) self._kinetic_dps_entry.insert(0, 50) self._kinetic_dps_entry.grid(row=row, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._kinetic_dps_entry) row += 1 tk.Label(left_frame, text="Thermal DPS").grid(row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._thermal_dps_entry = IntegerEntry(left_frame) self._thermal_dps_entry.insert(0, 50) self._thermal_dps_entry.grid(row=row, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._thermal_dps_entry) row += 1 tk.Label(left_frame, text="Absolute DPS (Thargoids)").grid( row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._absolute_dps_entry = IntegerEntry(left_frame) self._absolute_dps_entry.insert(0, 10) self._absolute_dps_entry.grid(row=row, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._absolute_dps_entry) row += 1 tk.Label(left_frame, text="Damage effectiveness in %").grid( row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._effectiveness_slider = tk.Scale(left_frame, from_=1, to=100, orient=tk.HORIZONTAL, length=175, takefocus=True) self._effectiveness_slider.set(65) self._effectiveness_slider.grid(row=row, column=1, sticky=tk.E, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._effectiveness_slider) row += 1 row = headline(left_frame, "[Misc]", row) row += 1 tk.Label(left_frame, text="Use short list").grid(row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._use_short_list = tk.IntVar(self) self._use_short_list.set(1) self._use_short_list_check_button = tk.Checkbutton( left_frame, variable=self._use_short_list, command=self._set_short_list_command) self._use_short_list_check_button.grid(row=row, column=1, sticky=tk.W, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._use_short_list_check_button) row += 1 tk.Label(left_frame, text="Preliminary filtering of shield generators\n" "(might not find the best loadout)", justify="left").grid(row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._use_filtering = tk.IntVar(self) self._use_filtering.set(0) self._use_filtering_check_button = tk.Checkbutton( left_frame, variable=self._use_filtering, command=self._set_filtering_command) self._use_filtering_check_button.grid(row=row, column=1, sticky=tk.W, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._use_filtering_check_button) row += 1 tk.Label(left_frame, text="CPU cores to use").grid(row=row, column=0, sticky=tk.SW, padx=ShieldTesterUi.PADDING) self._cores_slider = tk.Scale(left_frame, from_=1, to=os.cpu_count(), orient=tk.HORIZONTAL, length=175, takefocus=True) self._cores_slider.set(os.cpu_count()) self._cores_slider.grid(row=row, column=1, sticky=tk.E, padx=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._cores_slider) row += 1 tk.Label(left_frame, text="Shield loadouts to be tested", justify="left").grid(row=row, column=0, sticky=tk.NW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._number_of_tests_label = tk.Label(left_frame, text="") self._number_of_tests_label.grid(row=row, column=1, sticky=tk.NW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) left_frame.rowconfigure(row, weight=1) row += 1 left_frame.rowconfigure(row, weight=0) button_frame = tk.Frame(left_frame) button_frame.grid(row=row, columnspan=2, sticky=tk.NSEW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) button_frame.columnconfigure(0, weight=1) button_frame.columnconfigure(1, weight=1) self._compute_button = tk.Button(button_frame, text="Compute best loadout", command=self._compute) self._compute_button.grid(row=0, column=0, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._lockable_ui_elements.append(self._compute_button) self._cancel_button = tk.Button(button_frame, text="Cancel", command=self._cancel_command) self._cancel_button.grid(row=0, column=1, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._cancel_button.config(state=tk.DISABLED) #self._lockable_ui_elements.append(self._cancel_button) # --------------------------------------------------------------------------------------------------- # right frame right_frame = tk.LabelFrame(self, borderwidth=1, text="Output") right_frame.grid(row=1, column=2, sticky=tk.NSEW) self._tab_parent = ttk.Notebook(right_frame) self._tab_parent.grid(row=0, column=0, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING, sticky=tk.NSEW) self._tab_parent.rowconfigure(0, weight=1) self._tab_parent.columnconfigure(0, weight=1) self._tab_parent.bind(ShieldTesterUi.EVENT_TAB_CHANGED, self._event_tab_changed) # self._tab_parent.bind("<Button-3>", self._event_close_tab) # do this when lock and unlocking UI quick_guide = scrolledtext.ScrolledText(self._tab_parent, height=27, width=85) quick_guide.insert( tk.END, f"\u2191 You can close this tab by {'pressing the middle mouse button' if sys.platform == 'darwin' else 'right clicking'}." ) quick_guide.config(state=tk.DISABLED) self._tabs.setdefault(ShieldTesterUi.KEY_QUICK_GUIDE, TabData(tab=quick_guide)) self._tab_parent.add(quick_guide, text=ShieldTesterUi.KEY_QUICK_GUIDE) export_frame = tk.Frame(right_frame) export_frame.grid(row=1, column=0, sticky=tk.NSEW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) export_frame.columnconfigure(0, weight=1) self._progress_bar = ttk.Progressbar(export_frame, orient="horizontal", mode="determinate") self._progress_bar.grid(row=0, column=0, sticky=tk.NSEW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._progress_bar.config(value=0) self._export_button = tk.Button(export_frame, text="Export to", command=self._export_command, width=10) self._export_button.grid(row=0, column=1, sticky=tk.E, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) self._export_button.config(state=tk.DISABLED) self._export_select_var = tk.StringVar(self) self._export_select_var.set( list(st.ShieldTester.EXPORT_SERVICES.keys())[0]) self._export_select = tk.OptionMenu( export_frame, self._export_select_var, *st.ShieldTester.EXPORT_SERVICES.keys()) self._export_select.config(width=10) self._export_select.grid(row=0, column=2, sticky=tk.EW, padx=ShieldTesterUi.PADDING, pady=ShieldTesterUi.PADDING) # set behaviour for resizing self.rowconfigure(1, weight=1) self.columnconfigure(2, weight=1) right_frame.rowconfigure(0, weight=1) right_frame.columnconfigure(0, weight=1) self._lock_ui_elements() self.after(100, self._load_data) self.after(120, self._load_quick_guide) def set_window_size(): self.minsize(self.winfo_reqwidth(), self.winfo_reqheight() + 40) # TODO remove hack self.after(100, set_window_size)
encoded_text = original_text.encode("utf-16be") print("encoded_text: ", encoded_text) print(type(encoded_text)) data = [] for each in encoded_text: data.append(hex(each)) print(hex(each)) print(data) ### root_window = tk.Tk() root_window.wm_title("VEK TP Test Tool") # root_window.geometry("640x400+100+100") # # geometry("Width x Height + Initial location x coordinate + Initial location y coordinate") root_window.resizable(False, False) # resizable(Height, Width) p1_f1 = tk.LabelFrame(root_window, text='DBC Setting', bg='#6495ed', bd=5, padx=5, pady=5, width=100) p1_f1.grid(row=0, column=0, sticky='nsew') entry_tp_data = tk.Entry(p1_f1, width=20) entry_tp_data.grid(row=0, column=0, sticky='nsew') btn_dbc_channel_1 = tk.Button(p1_f1, text="Print TP Data", width=15, command=lambda: print_tp_data()) btn_dbc_channel_1.grid(row=0, column=1, sticky='nsew') ################ root_window.pack_propagate(0)
height=3, text='decrease volume', command=decrease) button7 = tkr.Button(player, width=5, height=3, text='select a file ', command=file) button8 = tkr.Button(player, width=5, height=3, text='download songs', command=downloads) playlist = tkr.Listbox(player, highlightcolor="blue", selectmode=tkr.SINGLE) label1 = tkr.LabelFrame(player, text="Song Name") label1.pack(fill='both', expand='yes') var = tkr.StringVar() songtitle = tkr.Label(player, textvariable=var) button7.pack(fill='x') button1.pack(fill='x') button3.pack(fill='x') button4.pack(fill='x') button2.pack(fill='x') button5.pack(fill='x') button6.pack(fill='x') button8.pack(fill='x') songtitle.pack() playlist.pack(fill='both', expand="yes") player.mainloop()
def __init__(self, root_window, semester, aff, preset_sheet=None, callback_func=None, startup_date=None): """ Constructor """ if startup_date is None: startup_date = [] if aff in "ประถมศึกษา": self.is_mid = False else: self.is_mid = True self.root = root_window self.selected_date = [] self.excel_date = [] self.dateframe_list = [] self.enable_classnum = BooleanVar() self.callback_func = callback_func self.startup_date = startup_date self.semester = semester self.full_dateframe = None self.preset_sheet = preset_sheet # ==================================================================== # =============================== GUI ================================ # ==================================================================== # ==================== Main Box ==================== self.main = tk.Toplevel(self.root) self.main.title("Date Picker") # ==================== Calendar ==================== top_wrapper = tk.Frame(self.main) top_wrapper.pack() self.calendar = tkcalendar.Calendar(top_wrapper, firstweekday='sunday') self.calendar.pack(side=LEFT, padx=10, ipadx=50, pady=20, expand=True, fill='both') # ==================== Side Box ==================== side_box = tk.Frame(top_wrapper) side_box.pack(side=LEFT, padx=10) # --------------- Top-Side --------------- top_text = tk.Frame(side_box) top_text.pack(pady=10) tk.Label(top_text, text="จำนวนวันที่เลือกแล้ว:", font=self.easy_read, justify=CENTER). \ pack(side=LEFT, padx=5) self.num_of_days = tk.Label(top_text, text=str(0) + " / 22", relief=SUNKEN, font=self.easy_read, justify=CENTER) self.num_of_days.pack(side=LEFT, ipadx=10, padx=5) # --------------- Selection Box --------------- sel_box = tk.Frame(side_box) sel_box.pack(padx=25) # - Selection List & Scroll Bar - self.sel_list = tk.Listbox(sel_box, height=7, width=40, highlightthickness=0, selectmode=BROWSE, font=self.input_font) scrb = tk.Scrollbar(sel_box, orient=VERTICAL, command=self.sel_list.yview) self.sel_list.configure(yscrollcommand=scrb.set) self.sel_list.pack(side=LEFT) scrb.pack(anchor="e", side=LEFT, expand=True, fill="y") self.sel_list.bind("<<ListboxSelect>>", lambda e: self.enable_remove()) # - Buttons - sel_btn_frame = tk.Frame(side_box) sel_btn_frame.pack(pady=10, expand=True, fill='x') self.confirm_btn = ttk.Button(sel_btn_frame, text="Confirm", command=self.confirm_date, state=DISABLED) self.confirm_btn.pack(side=LEFT, expand=True) self.remove_btn = ttk.Button(sel_btn_frame, text="Remove", state=DISABLED) self.remove_btn.pack(side=LEFT, expand=True, padx=5) ttk.Button(sel_btn_frame, text="Clear", command=self.remove_all_date) \ .pack(side=LEFT, expand=True, padx=5) ttk.Button(sel_btn_frame, text="Cancel").pack(side=LEFT, expand=True) # ==================== Class Number by date ==================== # --------------- Toggle Checkbox --------------- bottom_box = tk.LabelFrame(self.main, text="กำหนดชั่วโมงเรียนของแต่ละวัน", font=self.easy_read) bottom_box.pack(padx=50, ipadx=10, pady=10, ipady=15) checkbox_left = tk.Frame(bottom_box) checkbox_left.pack(side=LEFT, expand=True, fill='y', padx=20) self.check_enable_classnum = tk.Checkbutton( checkbox_left, text="เปิดใช้การกำหนดชั่วโมงเรียนต่อวัน", variable=self.enable_classnum, command=self.toggle_days_assignment, onvalue=True, offvalue=False) self.check_enable_classnum.pack() tk.Label(checkbox_left, text="ด้วยการเปิดการใช้งานคณสมบัตินี้ ในแต่ละวัน\n" "จะมีเลขคายกำกับไว้ในแผ่นงานด้วย\n " "(ใช้เฉพาะกับแผ่นงานระดับมัฐยมเท่านั้น)", font=self.small_para, relief=RIDGE, justify=LEFT).pack() # --------------- Days Assignment --------------- checkbox_right = tk.Frame(bottom_box) checkbox_right.pack(side=LEFT, expand=True, fill=BOTH, ipadx=10, padx=5) self.day_list = ["จันทร์", "อังคาร", "พุธ", "พฤหัสบดี", "ศุกร์"] self.day_assignment = [] for day in self.day_list: new_box = tk.Frame(checkbox_right) new_box.pack(side=LEFT, padx=5, ipadx=5) tk.Label(new_box, text=day).pack(side=LEFT, padx=1) new_day = ttk.Spinbox(new_box, from_=1, to=12, width=3, state=DISABLED) new_day.pack(side=LEFT) self.day_assignment.append(new_day) # ==================================================================== # =========================== END GUI ================================ # ==================================================================== self.calendar.bind("<<CalendarSelected>>", lambda event: self.calendar_select_callback())
def __init__(self, app): self.parent = app.root self.dialog = Pmw.Dialog(self.parent, buttons=('Run DSSP', 'Run Stride', 'Update Color', 'Update ss', 'Exit'), title='DSSP and Stride Plugin for PyMOL', command=self.execute) Pmw.setbusycursorattributes(self.dialog.component('hull')) # parameters used by DSSP self.pymol_sel = Tkinter.StringVar() self.dssp_bin = Tkinter.StringVar() self.stride_bin = Tkinter.StringVar() self.dssp_rlt_dict = {} self.stride_rlt_dict = {} self.ss_asgn_prog = None # which program is used to assign ss self.sel_obj_list = [] # there may be more than one seletion or object # defined by self.pymol_sel # treat each selection and object separately if 'DSSP_BIN' not in os.environ and 'PYMOL_GIT_MOD' in os.environ: if sys.platform.startswith( 'linux') and platform.machine() == 'x86_32': initialdir_dssp = os.path.join(os.environ['PYMOL_GIT_MOD'], "DSSP", "i86Linux2", "dssp-2") os.environ['DSSP_BIN'] = initialdir_dssp elif sys.platform.startswith( 'linux') and platform.machine() == 'x86_64': initialdir_dssp = os.path.join(os.environ['PYMOL_GIT_MOD'], "DSSP", "ia64Linux2", "dssp-2") os.environ['DSSP_BIN'] = initialdir_dssp elif sys.platform.startswith('win'): initialdir_dssp = os.path.join(os.environ['PYMOL_GIT_MOD'], "DSSP", "win32", "dssp.exe") os.environ['DSSP_BIN'] = initialdir_dssp else: pass if 'DSSP_BIN' in os.environ: if VERBOSE: print('Found DSSP_BIN in environmental variables', os.environ['DSSP_BIN']) self.dssp_bin.set(os.environ['DSSP_BIN']) else: if VERBOSE: print('DSSP_BIN not found in environmental variables.') self.dssp_bin.set('') if 'STRIDE_BIN' not in os.environ and 'PYMOL_GIT_MOD' in os.environ: if sys.platform.startswith( 'linux') and platform.machine() == 'x86_32': initialdir_stride = os.path.join(os.environ['PYMOL_GIT_MOD'], "Stride", "i86Linux2", "stride") os.environ['STRIDE_BIN'] = initialdir_stride elif sys.platform.startswith( 'linux') and platform.machine() == 'x86_64': initialdir_stride = os.path.join(os.environ['PYMOL_GIT_MOD'], "Stride", "ia64Linux2", "stride") os.environ['STRIDE_BIN'] = initialdir_stride elif sys.platform.startswith('win'): initialdir_stride = os.path.join(os.environ['PYMOL_GIT_MOD'], "Stride", "win32", "stride.exe") os.environ['STRIDE_BIN'] = initialdir_stride else: pass if 'STRIDE_BIN' in os.environ: if VERBOSE: print('Found STRIDE_BIN in environmental variables', os.environ['STRIDE_BIN']) self.stride_bin.set(os.environ['STRIDE_BIN']) else: if VERBOSE: print('STRIDE_BIN not found in environmental variables.') self.stride_bin.set('') # DSSP visualization color # - H Alpha helix (4-12) # - G 3-10 helix # - I pi helix # # - E Extended strand # - B Isolated beta-bridge residue # # - T Turn # - S Bend # - - None # STRIDE does not have S and None, but it has two more # codes: 'b' same as 'B' and 'C' for coil self.DSSP_SSE_list = ['H', 'G', 'I', 'E', 'B', 'T', 'S', '-'] # for the record of the order self.STRIDE_SSE_list = ['H', 'G', 'I', 'E', 'B', 'b', 'T', 'C'] # for the record of the order self.SSE_map = { 'H': 'H', 'G': 'H', 'I': 'H', 'E': 'S', 'B': 'S', 'T': 'L', 'S': 'L', '-': 'L', 'b': 'S', 'C': 'L' } self.SSE_name = { 'H': 'Alpha helix', 'G': '3-10 helix', 'I': 'Pi helix', 'E': 'Extended strand', 'B': 'Isolated beta-bridge', 'T': 'Turn', 'S': 'Bend', '-': 'None', 'b': 'Isolated beta-bridge', 'C': 'Coil' } self.SSE_col_RGB = { 'H': (255, 0, 0), 'G': (255, 0, 128), 'I': (255, 170, 170), 'E': (255, 255, 0), 'B': (153, 119, 85), 'T': (0, 255, 255), 'S': (153, 255, 119), '-': (179, 179, 179), 'b': (153, 119, 85), # same as 'B' 'C': (0, 0, 255) } self.SSE_col = {} for sse in self.SSE_col_RGB.keys(): self.SSE_col[sse] = '#%s%s%s' % ( hex(self.SSE_col_RGB[sse][0])[2:].zfill(2), hex(self.SSE_col_RGB[sse][1])[2:].zfill(2), hex(self.SSE_col_RGB[sse][2])[2:].zfill(2)) self.SSE_res_dict = {} self.SSE_sel_dict = {} w = Tkinter.Label( self.dialog.interior(), # text = '\nDSSP Plugin for PyMOL\nHongbo Zhu, 2011.\n\nColor proteins according to the secondary structure determined by DSSP.', text='\nDSSP and Stride Plugin for PyMOL\nby Hongbo Zhu, 2011\n', background='black', foreground='green') w.pack(expand=1, fill='both', padx=10, pady=5) # make a few tabs within the dialog self.notebook = Pmw.NoteBook(self.dialog.interior()) self.notebook.pack(fill='both', expand=1, padx=10, pady=10) ###################### # Tab : Structure Tab ###################### page = self.notebook.add('Structure') self.notebook.tab('Structure').focus_set() group_struc = Tkinter.LabelFrame(page, text='Structure') group_struc.pack(fill='both', expand=True, padx=10, pady=5) pymol_sel_ent = Pmw.EntryField(group_struc, label_text='PyMOL selection/object:', labelpos='wn', entry_textvariable=self.pymol_sel) dssp_bin_ent = Pmw.EntryField(group_struc, label_text='DSSP binary:', labelpos='wn', entry_textvariable=self.dssp_bin, entry_width=20) dssp_bin_but = Tkinter.Button(group_struc, text='Browse...', command=self.getDSSPBin) stride_bin_ent = Pmw.EntryField(group_struc, label_text='Stride binary:', labelpos='wn', entry_textvariable=self.stride_bin, entry_width=20) stride_bin_but = Tkinter.Button(group_struc, text='Browse...', command=self.getStrideBin) # arrange widgets using grid pymol_sel_ent.grid(sticky='we', row=0, column=0, columnspan=2, padx=5, pady=5) dssp_bin_ent.grid(sticky='we', row=1, column=0, padx=5, pady=1) dssp_bin_but.grid(sticky='we', row=1, column=1, padx=5, pady=1) stride_bin_ent.grid(sticky='we', row=2, column=0, padx=5, pady=1) stride_bin_but.grid(sticky='we', row=2, column=1, padx=5, pady=1) group_struc.columnconfigure(0, weight=9) group_struc.columnconfigure(1, weight=1) ###################### # Tab : Color Tab ###################### # H = alpha helix # G = 3-helix (3/10 helix) # I = 5 helix (pi helix) # E = extended strand, participates in beta ladder # B = residue in isolated beta-bridge # T = hydrogen bonded turn # S = bend # # H Alpha helix (4-12) # G 3-10 helix # I pi helix # E Strand # B Isolated beta-bridge residue # T Turn # S Bend # - None page = self.notebook.add('Color') group_sse_color = Tkinter.LabelFrame( page, text='Secondary Structure Element Color') group_sse_color.grid(sticky='eswn', row=0, column=0, padx=10, pady=5) # colors for DSSP surface H_col_lab = Tkinter.Label(group_sse_color, text='Alpha helix (H):') self.H_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['H'], activebackground=self.SSE_col['H'], command=self.custermizeHColor) G_col_lab = Tkinter.Label(group_sse_color, text='3-10 helix (G):') self.G_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['G'], activebackground=self.SSE_col['G'], command=self.custermizeGColor) I_col_lab = Tkinter.Label(group_sse_color, text='PI helix (I):') self.I_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['I'], activebackground=self.SSE_col['G'], command=self.custermizeIColor) E_col_lab = Tkinter.Label(group_sse_color, text='Extended strand (E):') self.E_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['E'], activebackground=self.SSE_col['E'], command=self.custermizeEColor) B_col_lab = Tkinter.Label(group_sse_color, text='Isolated beta-bridge (B):') self.B_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['B'], activebackground=self.SSE_col['B'], command=self.custermizeBColor) T_col_lab = Tkinter.Label(group_sse_color, text='Turn (T):') self.T_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['T'], activebackground=self.SSE_col['T'], command=self.custermizeTColor) S_col_lab = Tkinter.Label(group_sse_color, text='Bend (DSSP S):') self.S_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['S'], activebackground=self.SSE_col['S'], command=self.custermizeSColor) N_col_lab = Tkinter.Label(group_sse_color, text='None (DSSP NA):') self.N_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['-'], activebackground=self.SSE_col['-'], command=self.custermizeNColor) b_col_lab = Tkinter.Label(group_sse_color, text='Isolated beta-bridge (Stride b):') self.b_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['b'], activebackground=self.SSE_col['b'], command=self.custermizebColor) C_col_lab = Tkinter.Label(group_sse_color, text='Coil (Stride C):') self.C_col_but = Tkinter.Button(group_sse_color, bg=self.SSE_col['C'], activebackground=self.SSE_col['C'], command=self.custermizeCColor) H_col_lab.grid(sticky='e', row=0, column=0, padx=5, pady=3) self.H_col_but.grid(sticky='we', row=0, column=1, padx=5, pady=3) G_col_lab.grid(sticky='e', row=1, column=0, padx=5, pady=3) self.G_col_but.grid(sticky='we', row=1, column=1, padx=5, pady=3) I_col_lab.grid(sticky='e', row=2, column=0, padx=5, pady=3) self.I_col_but.grid(sticky='we', row=2, column=1, padx=5, pady=3) E_col_lab.grid(sticky='e', row=0, column=2, padx=5, pady=3) self.E_col_but.grid(sticky='we', row=0, column=3, padx=5, pady=3) B_col_lab.grid(sticky='e', row=1, column=2, padx=5, pady=3) self.B_col_but.grid(sticky='we', row=1, column=3, padx=5, pady=3) T_col_lab.grid(sticky='e', row=0, column=4, padx=5, pady=3) self.T_col_but.grid(sticky='we', row=0, column=5, padx=5, pady=3) S_col_lab.grid(sticky='e', row=1, column=4, padx=5, pady=3) self.S_col_but.grid(sticky='we', row=1, column=5, padx=5, pady=3) N_col_lab.grid(sticky='e', row=2, column=4, padx=5, pady=3) self.N_col_but.grid(sticky='we', row=2, column=5, padx=5, pady=3) b_col_lab.grid(sticky='e', row=2, column=2, padx=5, pady=3) self.b_col_but.grid(sticky='we', row=2, column=3, padx=5, pady=3) C_col_lab.grid(sticky='e', row=3, column=4, padx=5, pady=3) self.C_col_but.grid(sticky='we', row=3, column=5, padx=5, pady=3) ###################### # Tab : About Tab ###################### page = self.notebook.add('About') group_about = Tkinter.LabelFrame( page, text='About DSSP and Stride Plugin for PyMOL') group_about.grid(sticky='we', row=0, column=0, padx=5, pady=3) about_plugin = """ Assign and color secondary structures using DSSP or Stride. by Hongbo Zhu <hongbo.zhu.cn .at. googlemail.com> Please cite this plugin if you use it in a publication. Hongbo Zhu. DSSP and Stride plugin for PyMOL, 2011, BIOTEC, TU Dresden. """ label_about = Tkinter.Label(group_about, text=about_plugin) label_about.grid(sticky='we', row=0, column=0, padx=5, pady=10) self.notebook.setnaturalsize() return
def MathTypeChose(): master = tk.Tk() master.title('Maths Type') sw = master.winfo_screenwidth() sh = master.winfo_screenheight() ww = 475 hh = 300 x = (sw - ww) / 2 y = (sh - hh) / 2 master.geometry("%dx%d+%d+%d" % (ww, hh, x, y)) tk.Label(master, text="请选择题型", font=("华文行楷", 16), fg="Purple", justify="center").grid(row=0, column=0, columnspan=6, rowspan=3) group_ft = ("宋体", 13, "bold") group_fg = "blue" item_ft = ("宋体", 13) item_fg = "black" ############################ group 1 ########################################## group1 = tk.LabelFrame(master, text="计算大小", font=group_ft, fg=group_fg, labelanchor='n') group1.grid(row=3, column=0, padx=5, pady=5) num_range = tk.IntVar() tk.Radiobutton(group1, text="30", font=item_ft, fg=item_fg, variable=num_range, value=30).grid(row=4, column=0, sticky="w") tk.Radiobutton(group1, text="50", font=item_ft, fg=item_fg, variable=num_range, value=50).grid(row=5, column=0, sticky="w") tk.Radiobutton(group1, text="100", font=item_ft, fg=item_fg, variable=num_range, value=100).grid(row=6, column=0, sticky="w") tk.Radiobutton(group1, text="200", font=item_ft, fg=item_fg, variable=num_range, value=200).grid(row=7, column=0, sticky="w") ent0 = tk.Label(group1, text="自定义:", font=("华文行楷", 12), fg=item_fg) ent0.grid(row=8, column=0, sticky="E") en0 = tk.Entry(group1, width=4, font=("华文行楷", 12)) en0.grid(row=8, column=1, sticky="w", padx=5) ## 得到数学题的运算范围 #Ret_math_range = num_range.get() if en0.get()=="" else int(en0.get()) ############################ group 2 ########################################## group2 = tk.LabelFrame(master, text="计算类型", font=group_ft, fg=group_fg, labelanchor='n') group2.grid(row=3, column=1, padx=5, pady=5) strs = tk.IntVar() tk.Radiobutton(group2, text="加", font=item_ft, fg=item_fg, variable=strs, value=1).grid(row=4, column=3, columnspan=2, sticky="w") tk.Radiobutton(group2, text="减", font=item_ft, fg=item_fg, variable=strs, value=2).grid(row=5, column=3, sticky="w") tk.Radiobutton(group2, text="乘", font=item_ft, fg=item_fg, variable=strs, value=3).grid(row=6, column=3, sticky="w") tk.Radiobutton(group2, text="除", font=item_ft, fg=item_fg, variable=strs, value=4).grid(row=7, column=3, sticky="w") tk.Radiobutton(group2, text="混合", font=item_ft, fg=item_fg, variable=strs, value=5).grid(row=8, column=3, sticky="w") ############################ group 3 ########################################## group3 = tk.LabelFrame(master, text="多项运算", font=group_ft, fg=group_fg, labelanchor='n') group3.grid(row=3, column=2, padx=5, pady=5) yun_num = tk.IntVar() tk.Radiobutton(group3, text="两项", font=item_ft, fg=item_fg, variable=yun_num, value=2).grid(row=4, column=4, sticky="w") tk.Radiobutton(group3, text="三项", font=item_ft, fg=item_fg, variable=yun_num, value=3).grid(row=5, column=4, sticky="w") tk.Label(group3, text=" ", font=item_ft, fg=item_fg).grid(row=6, column=4, sticky="w") tk.Label(group3, text=" ", font=item_ft, fg=item_fg).grid(row=7, column=4, sticky="w") tk.Label(group3, text=" ", font=item_ft, fg=item_fg).grid(row=8, column=4, sticky="w") ############################ group 4 ########################################## group4 = tk.LabelFrame(master, text="题目数量", font=group_ft, fg=group_fg, labelanchor='n') group4.grid(row=3, column=3, padx=5, pady=5) math_num = tk.IntVar() tk.Radiobutton(group4, text="200", font=item_ft, fg=item_fg, variable=math_num, value=200).grid(row=4, column=0, sticky="w") tk.Radiobutton(group4, text="100", font=item_ft, fg=item_fg, variable=math_num, value=100).grid(row=5, column=0, sticky="w") tk.Radiobutton(group4, text="50", font=item_ft, fg=item_fg, variable=math_num, value=50).grid(row=6, column=0, sticky="w") tk.Radiobutton(group4, text="30", font=item_ft, fg=item_fg, variable=math_num, value=30).grid(row=7, column=0, sticky="w") ent1 = tk.Label(group4, text="自定义:", font=("华文行楷", 12), fg=item_fg) ent1.grid(row=8, column=0, sticky="E") en1 = tk.Entry(group4, font=("华文行楷", 12), width=4) en1.grid(row=8, column=1, padx=5, sticky="w") def SubmitType(): global Ret_math_range global Ret_math_type global Ret_opera_num global Ret_math_num ## 得到数学题的运算范围 if en0.get() != "": try: Ret_math_range = int(en0.get()) except: txt = "计算大小: 自定义\"" + en0.get() + "\"不是有效的数字!" #tk.Message(master, text=txt).pack() tm.showwarning("注意", txt) return 0 else: if num_range.get() == 0: txt = "请设置计算大小" tm.showwarning("注意", txt) return 0 Ret_math_range = num_range.get() #print(Ret_math_range) ## 得到数学提的运算类型 Ret_math_type = strs.get() if Ret_math_type == 0: txt = "请设置运算类型" tm.showwarning("注意:", txt) return 0 #print(Ret_math_type) ## 一道题有几个数参与运算 Ret_opera_num = yun_num.get() if Ret_opera_num == 0: txt = "请设置多项运算" tm.showwarning("注意:", txt) return 0 #print(Ret_opera_num) ## 得到需要计算的题目的数量 if en1.get() != "": try: Ret_math_num = int(en1.get()) except: txt = "题目数量: 自定义\"" + en1.get() + "\"不是有效的数字!" #tk.Message(master, text=txt).pack() tm.showwarning("注意", txt) return 0 else: Ret_math_num = math_num.get() if math_num.get() == 0: txt = "请设置题目数量" tm.showwarning("注意", txt) return 0 master.destroy() def ExitGui(): master.destroy() sys.exit(0) tk.Button(master, text="选好", command=SubmitType, font=("华文行楷", 12), fg="blue", bg="yellow", width=6).grid(row=9, column=1, sticky="w") tk.Button(master, text="退出", command=ExitGui, font=("华文行楷", 12), fg="blue", bg="yellow", width=6).grid(row=9, column=2, sticky="E") master.protocol("WM_DELETE_WINDOW", ExitGui) ## 点击GUI右上角的x,会退出程序,不再往下执行 master.mainloop()
def __init__(self, parent): tk.Frame.__init__(self, parent) self.screenscanner = OCRDevice() self.translator = Translator() self.bboxLabelFrame = tk.LabelFrame(self, text="Capture area") self.bboxLeftLabelFrame = tk.LabelFrame(self.bboxLabelFrame, text="Top Left") self.bboxRightLabelFrame = tk.LabelFrame(self.bboxLabelFrame, text="Bottom Right") self.startX = tk.StringVar(root, value='10') self.startXEntry = tk.Entry(self.bboxLeftLabelFrame, textvariable=self.startX, width=4) self.startY = tk.StringVar(root, value='110') self.startYEntry = tk.Entry(self.bboxLeftLabelFrame, textvariable=self.startY, width=4) self.endX = tk.StringVar(root, value='650') self.endXEntry = tk.Entry(self.bboxRightLabelFrame, textvariable=self.endX, width=4) self.endY = tk.StringVar(root, value='580') self.endYEntry = tk.Entry(self.bboxRightLabelFrame, textvariable=self.endY, width=4) self.showCapButton = tk.Button(self.bboxLabelFrame, text="Preview", command=self.showCapToggle) self.langLabelFrame = tk.LabelFrame(self, text="Input and output languages") self.fromPrompt = tk.Label(self.langLabelFrame, text="from") self.fromItem = tk.StringVar(self, value='ja') self.fromOptionMenu = tk.OptionMenu(self.langLabelFrame, self.fromItem, 'en', 'zh-tw', 'ja') self.toPrompt = tk.Label(self.langLabelFrame, text="to") self.toItem = tk.StringVar(self, value='en') self.toOptionMenu = tk.OptionMenu(self.langLabelFrame, self.toItem, 'en', 'zh-tw', 'ja') self.actionLabelFrame = tk.LabelFrame(self, text="Actions") self.onetimeTransButton = tk.Button(self.actionLabelFrame, text="One-time translate", command=self.translate) self.startAutoTransButton = tk.Button( self.actionLabelFrame, text="Start auto-translate", command=self.startAutoTransToggle) self.translationLabelFrame = tk.LabelFrame(self, text="Output") self.origTextLabelFrame = tk.LabelFrame(self.translationLabelFrame, text="OCR input") self.translatedTextLabelFrame = tk.LabelFrame( self.translationLabelFrame, text="Translation") self.origText = tkst.ScrolledText(master=self.origTextLabelFrame, wrap=tk.WORD, width=28, height=12) self.translatedText = tkst.ScrolledText( master=self.translatedTextLabelFrame, wrap=tk.WORD, width=28, height=12) self.statusStr = tk.StringVar() self.statusLabel = tk.Label(self, textvariable=self.statusStr, bd=1, relief=tk.SUNKEN, anchor=tk.W) # lay the widgets out on the screen. self.startXEntry.pack(side="left", padx=10, pady=10) self.startYEntry.pack(side="right", padx=10, pady=10) self.endXEntry.pack(side="left", padx=10, pady=10) self.endYEntry.pack(side="right", padx=10, pady=10) self.bboxLeftLabelFrame.pack(side="left", padx=10, pady=10) self.bboxRightLabelFrame.pack(side="left", padx=10, pady=10) self.showCapButton.pack(side="right", padx=10, pady=10) self.bboxLabelFrame.pack(side="top", fill="x", padx=10, pady=10) self.fromPrompt.pack(side="left", padx=10, pady=10) self.fromOptionMenu.pack(side="left", padx=10, pady=10) self.toPrompt.pack(side="left", padx=10, pady=10) self.toOptionMenu.pack(side="left", padx=10, pady=10) self.langLabelFrame.pack(side="top", fill="x", padx=10, pady=10) self.onetimeTransButton.pack(side="left", padx=10, pady=10) self.startAutoTransButton.pack(side="left", padx=10, pady=10) self.actionLabelFrame.pack(side="top", fill="x", padx=10, pady=10) self.origText.pack(fill="y", padx=10, pady=10) self.translatedText.pack(fill="y", padx=10, pady=10) self.origTextLabelFrame.pack(side="left", fill="x", padx=10, pady=10) self.translatedTextLabelFrame.pack(side="right", fill="x", padx=10, pady=10) self.translationLabelFrame.pack(side="top", fill="x", padx=10, pady=10, expand=True) self.statusLabel.pack(side="bottom", fill="x")
def MathScoreBoard(answer_list): right_cnt = 0 wrong_cnt = 0 empty_cnt = 0 for rst in answer_list: if rst[3] == "Right": right_cnt += 1 elif rst[3] == "Wrong": wrong_cnt += 1 else: empty_cnt += 1 score_cnt = int(right_cnt / len(answer_list) * 100) tx = "{0:<5}{1:{2}<3}" wrong_text = tx.format("错误数量:", wrong_cnt, " ") rihgt_text = tx.format("正确数量:", right_cnt, " ") empty_text = tx.format("没做数量:", empty_cnt, " ") score_text = tx.format("本次得分:", score_cnt, " ") fen = Total_Cost_Time // 60 miao = Total_Cost_Time % 60 time_text = "%-1d分%-1d秒" % (fen, miao) answe_time = tx.format("做题时间:", time_text, " ") #wrong_text = "错误数量:%-3d" %wrong_cnt #rihgt_text = "正确数量:%-3d" %right_cnt #empty_text = "没做数量:%-3d" %empty_cnt #score_text = "本次得分:%-3d" %score_cnt ## 如果得了满分或者0分,显示表扬界面 #score_cnt = 100 if 0 <= score_cnt <= 100: WelcomeAndPraise(0, score_cnt) ## 弹出窗口显示得分 score_win = tk.Tk() score_win.title("测试结果板") sw = score_win.winfo_screenwidth() sh = score_win.winfo_screenheight() (ww, hh) = (350, 540) (x, y) = ((sw - ww) / 2, (sh - hh) / 2) score_win.geometry("%dx%d+%d+%d" % (ww, hh, x, y)) score_lfm = tk.LabelFrame(score_win) score_lfm.pack() tk.Label(score_lfm, text=score_text, font=("PakTypeNaqsh", 30, "bold"), fg="red").pack() tk.Label(score_lfm, text=wrong_text, font=("华文行楷", 20), fg="blue").pack() tk.Label(score_lfm, text=rihgt_text, font=("华文行楷", 20), fg="blue").pack() tk.Label(score_lfm, text=empty_text, font=("华文行楷", 20), fg="blue").pack() tk.Label(score_lfm, text=answe_time, font=("华文行楷", 20), fg="blue").pack() def ListWrongProb(list_wrong): lbl = tk.Tk() sw = lbl.winfo_screenwidth() sh = lbl.winfo_screenheight() (ww, hh) = (841, 721) (x, y) = ((sw - ww) / 2, (sh - hh) / 2) lbl.geometry("%dx%d+%d+%d" % (ww, hh, x, y)) lbl.title("ANSWER") lfm = tk.LabelFrame(lbl) lfm.grid(row=0, column=0, columnspan=2, padx=10, pady=10) txt = tk.Text(lfm, font=("Helvetica", 14), height=25) txt.pack() result_list = [] for prob in answer_list: tuple0_prob_stem = prob[0].replace("=", '') tuple1_equal_sig = "=" tuple4_right_value = "答案: " + str(prob[1]) if prob[3] == "Wrong": tuple2_child_value = str(prob[2]) tuple3_wrong_right = "✘" elif prob[3] == "Empty": tuple2_child_value = "?" tuple3_wrong_right = "没做" elif prob[3] == "Right": tuple2_child_value = str(prob[2]) tuple3_wrong_right = "✔" tuple4_right_value = " " answer_tuple = (tuple0_prob_stem, tuple1_equal_sig, tuple2_child_value, tuple3_wrong_right, tuple4_right_value) result_list.append(answer_tuple) if list_wrong == 1: lf_name = "错误题目及参考答案" if prob[3] in ["Wrong", "Empty"]: l0 = tk.Label(txt, text=tuple0_prob_stem, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=16) l1 = tk.Label(txt, text=tuple1_equal_sig, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=3) l2 = tk.Label(txt, text=tuple2_child_value, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=8) l3 = tk.Label(txt, text=tuple3_wrong_right, font=("Helvetica", 14, "bold"), fg="red", bg="white", justify="left", width=8) l4 = tk.Label(txt, text=tuple4_right_value, font=("Helvetica", 14, "bold"), fg="green", bg="white", justify="left", width=8) txt.window_create("insert", window=l0) txt.window_create("insert", window=l1) txt.window_create("insert", window=l2) txt.window_create("insert", window=l3) txt.window_create("insert", window=l4) txt.insert("insert", "\n") else: lf_name = "全部题目及参考答案" l0 = tk.Label(txt, text=tuple0_prob_stem, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=16) l1 = tk.Label(txt, text=tuple1_equal_sig, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=3) l2 = tk.Label(txt, text=tuple2_child_value, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=8) l3 = tk.Label(txt, text=tuple3_wrong_right, font=("Helvetica", 14, "bold"), fg="red", bg="white", justify="left", width=8) l4 = tk.Label(txt, text=tuple4_right_value, font=("Helvetica", 14, "bold"), fg="green", bg="white", justify="left", width=8) txt.window_create("insert", window=l0) txt.window_create("insert", window=l1) txt.window_create("insert", window=l2) txt.window_create("insert", window=l3) txt.window_create("insert", window=l4) txt.insert("insert", "\n") # 设置参考答案的弹框窗口副名称: lfm.config(text=lf_name, labelanchor="n", font=("宋体", 15), fg="blue", padx=5, pady=5) # 设置滚动条 scl = tk.Scrollbar(lbl) scl['command'] = txt.yview scl.grid(row=0, column=3, sticky="s" + "n") txt.config(yscrollcommand=scl.set) # 设置保存结果的按钮 def SaveAnswerReslut(): now_time = time.strftime("%m%d-%H%M", time.localtime()) gen_file = "训练结果" + now_time + ".txt" f = open(gen_file, "w") for aw in result_list: write_str = "%-16s %-1s %-3s %-2s %-1s" % aw f.write(write_str) f.close() tm.showinfo( "文件信息", "文件: \"" + gen_file + "\"已成功生成!\n放在: " + os.getcwd() + " 中") tk.Button(lbl, text="保存此结果", font=("time", 14), bg="black", fg="yellow", command=SaveAnswerReslut, width=10).grid(row=1, column=0, pady=10) tk.Button(lbl, text="退出此界面", font=("time", 14), bg="black", fg="yellow", command=lbl.destroy, width=10).grid(row=1, column=1, pady=10) lbl.mainloop() def ExitProgram(): score_win.destroy() sys.exit(0) def ReExec(): score_win.destroy() ReExecuteProgram() tk.Button(score_win, text="查看错误题目", font=("华文行楷", 20), fg="black", bg="yellow", command=lambda: ListWrongProb(1)).pack(padx=10, pady=10) tk.Button(score_win, text="查看所有题目", font=("华文行楷", 20), fg="black", bg="pink", command=lambda: ListWrongProb(0)).pack(padx=10, pady=10) tk.Button(score_win, text="再做一次训练", font=("华文行楷", 20), fg="black", bg="green", command=ReExec).pack(padx=10, pady=10) tk.Button(score_win, text="退出数学训练", font=("华文行楷", 20), fg="black", bg="blue", command=ExitProgram).pack(padx=10, pady=10) score_win.mainloop()
def __init__(self, parent, root): super().__init__(parent) self.tool = interTool() self.LabelsFrame = tk.LabelFrame(self, text="你们做什么?", padx=25, pady=20) self.LabelsFrame.place(x=20, y=35, width=WIDTH / 2 - 30, height=HEIGHT - 100) self.LabelsFrame_1 = tk.LabelFrame(self.LabelsFrame, text="题目", padx=25, pady=20) self.LabelsFrame_1.place(x=5, y=5, width=WIDTH / 2 - 80, height=HEIGHT / 2 - 200) self.first = tk.Label(self.LabelsFrame_1, text='???', font=("宋体", 20, "normal"), pady=15) self.first.pack() self.second = tk.Label(self.LabelsFrame_1, text='???', font=("宋体", 30, "normal"), pady=15) self.second['fg'] = 'red' self.second.pack() self.third = tk.Label(self.LabelsFrame_1, text='???', font=("宋体", 20, "normal"), pady=15) self.third.pack() self.LabelsFrame_2 = tk.LabelFrame(self.LabelsFrame, text="队伍", padx=25, pady=20) self.LabelsFrame_2.place(x=5, y=HEIGHT / 2 - 180, width=WIDTH / 2 - 80, height=HEIGHT / 2 - 200) self.first2 = tk.Label(self.LabelsFrame_2, text='???', font=("宋体", 20, "normal"), pady=15) self.first2.pack() self.second2 = tk.Label(self.LabelsFrame_2, text='???', font=("宋体", 30, "normal"), pady=15) self.second2['fg'] = 'red' self.second2.pack() self.third2 = tk.Label(self.LabelsFrame_2, text='???', font=("宋体", 20, "normal"), pady=15) self.third2.pack() self.frameBtn = tk.Frame(self.LabelsFrame, width=200, height=50, pady=10, padx=10) self.frameBtn.place(x=WIDTH / 4 - 150, y=HEIGHT - 320, width=WIDTH / 2 - 250, height=80) # self.frameBtn.place(x=WIDTH/2+20, y=50, width=WIDTH/2 -30, height=HEIGHT-100) self.btnStart = tk.Button(self.frameBtn, text='开始', fg='white', bg='green', command=self.butStartClick) self.btnStart.place(x=0, y=5, width=45, height=25) self.btnEnd = tk.Button(self.frameBtn, text='结束', fg='white', bg='green', command=self.butEndClick) self.btnEnd.place(x=50, y=5, width=45, height=25) self.btnSave = tk.Button(self.frameBtn, text='SAVE', fg='white', bg='green', command=self.SaveClick) self.btnSave.place(x=100, y=5, width=45, height=25) self.lframeText = tk.LabelFrame(self, text='匹配信息', pady=10, padx=10) self.lframeText.place(x=WIDTH / 2 + 20, y=35, width=WIDTH / 2 - 30, height=HEIGHT - 100) self.text = tk.Text(self.lframeText) self.text.place(x=0, y=2, width=WIDTH / 2 - 55, height=HEIGHT - 150) self.speed = 0.02 # 滚动速度 self.GroupsInfo, self.MissionsInfo, self.Groups, self.Missions, self.group_single, self.mission_single \ = self.tool.PageMatchInfo() # 组号 --- 题号 self.Match = {} # 防止 开始按钮 多次点击 self.startMatchFlag = True # 匹配前控制 滚动条 的滚动信号 self.flag = True # 匹配时候控制 滚动条 的滚动信号 self.fflag = True # 匹配时候禁止点击 停止 按钮 self.showflag = True
def ListWrongProb(list_wrong): lbl = tk.Tk() sw = lbl.winfo_screenwidth() sh = lbl.winfo_screenheight() (ww, hh) = (841, 721) (x, y) = ((sw - ww) / 2, (sh - hh) / 2) lbl.geometry("%dx%d+%d+%d" % (ww, hh, x, y)) lbl.title("ANSWER") lfm = tk.LabelFrame(lbl) lfm.grid(row=0, column=0, columnspan=2, padx=10, pady=10) txt = tk.Text(lfm, font=("Helvetica", 14), height=25) txt.pack() result_list = [] for prob in answer_list: tuple0_prob_stem = prob[0].replace("=", '') tuple1_equal_sig = "=" tuple4_right_value = "答案: " + str(prob[1]) if prob[3] == "Wrong": tuple2_child_value = str(prob[2]) tuple3_wrong_right = "✘" elif prob[3] == "Empty": tuple2_child_value = "?" tuple3_wrong_right = "没做" elif prob[3] == "Right": tuple2_child_value = str(prob[2]) tuple3_wrong_right = "✔" tuple4_right_value = " " answer_tuple = (tuple0_prob_stem, tuple1_equal_sig, tuple2_child_value, tuple3_wrong_right, tuple4_right_value) result_list.append(answer_tuple) if list_wrong == 1: lf_name = "错误题目及参考答案" if prob[3] in ["Wrong", "Empty"]: l0 = tk.Label(txt, text=tuple0_prob_stem, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=16) l1 = tk.Label(txt, text=tuple1_equal_sig, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=3) l2 = tk.Label(txt, text=tuple2_child_value, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=8) l3 = tk.Label(txt, text=tuple3_wrong_right, font=("Helvetica", 14, "bold"), fg="red", bg="white", justify="left", width=8) l4 = tk.Label(txt, text=tuple4_right_value, font=("Helvetica", 14, "bold"), fg="green", bg="white", justify="left", width=8) txt.window_create("insert", window=l0) txt.window_create("insert", window=l1) txt.window_create("insert", window=l2) txt.window_create("insert", window=l3) txt.window_create("insert", window=l4) txt.insert("insert", "\n") else: lf_name = "全部题目及参考答案" l0 = tk.Label(txt, text=tuple0_prob_stem, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=16) l1 = tk.Label(txt, text=tuple1_equal_sig, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=3) l2 = tk.Label(txt, text=tuple2_child_value, font=("Helvetica", 14, "bold"), fg="black", bg="white", justify="left", width=8) l3 = tk.Label(txt, text=tuple3_wrong_right, font=("Helvetica", 14, "bold"), fg="red", bg="white", justify="left", width=8) l4 = tk.Label(txt, text=tuple4_right_value, font=("Helvetica", 14, "bold"), fg="green", bg="white", justify="left", width=8) txt.window_create("insert", window=l0) txt.window_create("insert", window=l1) txt.window_create("insert", window=l2) txt.window_create("insert", window=l3) txt.window_create("insert", window=l4) txt.insert("insert", "\n") # 设置参考答案的弹框窗口副名称: lfm.config(text=lf_name, labelanchor="n", font=("宋体", 15), fg="blue", padx=5, pady=5) # 设置滚动条 scl = tk.Scrollbar(lbl) scl['command'] = txt.yview scl.grid(row=0, column=3, sticky="s" + "n") txt.config(yscrollcommand=scl.set) # 设置保存结果的按钮 def SaveAnswerReslut(): now_time = time.strftime("%m%d-%H%M", time.localtime()) gen_file = "训练结果" + now_time + ".txt" f = open(gen_file, "w") for aw in result_list: write_str = "%-16s %-1s %-3s %-2s %-1s" % aw f.write(write_str) f.close() tm.showinfo( "文件信息", "文件: \"" + gen_file + "\"已成功生成!\n放在: " + os.getcwd() + " 中") tk.Button(lbl, text="保存此结果", font=("time", 14), bg="black", fg="yellow", command=SaveAnswerReslut, width=10).grid(row=1, column=0, pady=10) tk.Button(lbl, text="退出此界面", font=("time", 14), bg="black", fg="yellow", command=lbl.destroy, width=10).grid(row=1, column=1, pady=10) lbl.mainloop()
def create_email_recipients(self): # Frame for email recipient elements self.recipframe = tk.LabelFrame(self.parent, background='#ededed') self.recipframe.grid(column=0, row=3, sticky='we', padx=10) self.recipframe.visible = False self.recipframe.row = 3 # Creating daily recipients label and textbox self.dailyreciplabel = tk.Label(self.recipframe, text='Daily Reports') self.dailyrecipentry = tk.Entry(self.recipframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.dailyrecipentry.insert(0, self.config["DailyRecipients"]) self.dailyreciplabel.grid(column=0, row=0, sticky='w', padx=(10, 0), pady=(10, 5)) self.dailyrecipentry.grid(column=1, row=0, sticky='e', padx=(0, 10), pady=(10, 5)) # Creating weekly recipients label and textbox self.weeklyreciplabel = tk.Label(self.recipframe, text='Weekly Reports') self.weeklyrecipentry = tk.Entry(self.recipframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.weeklyrecipentry.insert(0, self.config["WeeklyRecipients"]) self.weeklyreciplabel.grid(column=0, row=1, sticky='w', padx=(10, 0), pady=5) self.weeklyrecipentry.grid(column=1, row=1, sticky='e', padx=(0, 10), pady=5) # Creating warning recipients label and textbox self.warningreciplabel = tk.Label(self.recipframe, text='Warnings') self.warningrecipentry = tk.Entry(self.recipframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.warningrecipentry.insert(0, self.config["WarningRecipients"]) self.warningreciplabel.grid(column=0, row=2, sticky='w', padx=(10, 0), pady=5) self.warningrecipentry.grid(column=1, row=2, sticky='e', padx=(0, 10), pady=5) # Creating failure recipients label and textbox self.failurereciplabel = tk.Label(self.recipframe, text='Failures') self.failurerecipentry = tk.Entry(self.recipframe, width=35, justify=tk.LEFT, highlightbackground='#ededed') self.failurerecipentry.insert(0, self.config["FailureRecipients"]) self.failurereciplabel.grid(column=0, row=3, sticky='w', padx=(10, 0), pady=(5, 10)) self.failurerecipentry.grid(column=1, row=3, sticky='e', padx=(0, 10), pady=(5, 10)) # Recipframe grid weight setup self.recipframe.grid_columnconfigure(0, weight=1) self.recipframe.grid_columnconfigure(1, weight=1) self.recipframe.grid_rowconfigure(0, weight=1) self.recipframe.grid_rowconfigure(1, weight=1) self.recipframe.grid_rowconfigure(2, weight=1) self.recipframe.grid_rowconfigure(3, weight=1)
confGridFrm = tk.Frame(wrpFrm) confGridFrm.configure(bg="white") confGridFrm.pack(padx=3, pady=3, fill="x") # チェックボックス設置 renameChkVar = tk.BooleanVar() renameChkVar.set(True) renameChk = tk.Checkbutton(confGridFrm) renameChk.configure(text="リネームする", variable=renameChkVar, command=rename_status, bg="white") renameChk.grid(row=0, column=0, sticky="nw") # ネームルールフレーム renameFrm = tk.LabelFrame(confGridFrm) renameFrm.configure(bg="white", text="リネームルール", relief="groove") renameFrm.grid(row=0, column=1, pady=(0, 5)) # レイアウト用のFrame renameFrmInn = tk.Frame(renameFrm) renameFrmInn.configure(bg="white") renameFrmInn.pack(padx=8, pady=(0, 5)) # ファイル名 fNameLbl = tk.Label(renameFrmInn) fNameLbl.configure(text="ファイル名", bg="white") fNameLbl.grid(row=0, column=0, sticky="nw") # ファイル名入力欄 fNameEnt = tk.Entry(renameFrmInn)
def load_components(self): self.buttonframe = tk.Frame(self.parent, background='#ededed') self.savebutton = tk.Button(self.buttonframe, text='Save Settings', width=20, command=self.save_hooks, highlightbackground='#ededed') # Detecting if opened from client or first run if self.firstrun: self.closebutton = tk.Button(self.buttonframe, text='Next', width=10, command=self.exit_creds, highlightbackground='#ededed') else: self.closebutton = tk.Button(self.buttonframe, text='Close', width=10, command=self.exit_creds, highlightbackground='#ededed') # Adding padding to left of save button to keep the window the same size when all is minimized self.savebutton.pack(side='left', padx=(0, 160)) self.closebutton.pack(side='right') self.buttonframe.grid(column=0, row=6, sticky='we', padx=10, pady=10) # Creating email settings elements # Creating frame for expand panel for email settings self.button_email_settings = tk.LabelFrame(self.parent) self.button_email_settings.grid(column=0, row=0, sticky="we", padx=10, pady=(10, 0)) # Expand panel buttons self.email_settings_expand_label = tk.Label( self.button_email_settings, text='Email Sender Settings') self.email_settings_expand = tk.Button(self.button_email_settings, width=3, justify=tk.CENTER, text="+") self.email_settings_expand_label.grid(column=0, row=0, sticky='w', padx=(10, 10), pady=5) self.email_settings_expand.grid(column=1, row=0, sticky='e', padx=(10, 10), pady=5) self.button_email_settings.grid_columnconfigure(0, weight=1) self.button_email_settings.grid_columnconfigure(1, weight=0) # Email settings element creation self.create_email_settings() # Expand panel configure self.email_settings_expand.configure( command=lambda: self.toggle(self.emailframe)) self.emailframe.grid_forget() # Creating frame for expand panel for email recipients self.button_email_recipients = tk.LabelFrame(self.parent) self.button_email_recipients.grid(column=0, row=2, sticky="we", padx=10, pady=(10, 0)) # Expand panel buttons self.email_recipients_expand_label = tk.Label( self.button_email_recipients, text='Email Recipients') self.email_recipients_expand = tk.Button(self.button_email_recipients, width=3, justify=tk.CENTER, text="+") self.email_recipients_expand_label.grid(column=0, row=0, sticky='w', padx=(10, 10), pady=5) self.email_recipients_expand.grid(column=1, row=0, sticky='e', padx=(10, 10), pady=5) self.button_email_recipients.grid_columnconfigure(0, weight=1) self.button_email_recipients.grid_columnconfigure(1, weight=0) # Creating email recipients elements self.create_email_recipients() # Expand panel configure self.email_recipients_expand.configure( command=lambda: self.toggle(self.recipframe)) self.recipframe.grid_forget() # Creating frame for expand panel for hook settings self.button_hook_settings = tk.LabelFrame(self.parent) self.button_hook_settings.grid(column=0, row=4, sticky="we", padx=10, pady=(10, 0)) # Expand panel buttons self.hook_settings_expand_label = tk.Label(self.button_hook_settings, text='Hook Settings') self.hook_settings_expand = tk.Button(self.button_hook_settings, width=3, justify=tk.CENTER, text="+") self.hook_settings_expand_label.grid(column=0, row=0, sticky='w', padx=(10, 10), pady=5) self.hook_settings_expand.grid(column=1, row=0, sticky='e', padx=(10, 10), pady=5) self.button_hook_settings.grid_columnconfigure(0, weight=1) self.button_hook_settings.grid_columnconfigure(1, weight=0) # Creating hook settings elements self.create_hook_settings() # Expand panel configure self.hook_settings_expand.configure( command=lambda: self.toggle(self.mainframe)) self.mainframe.grid_forget()
def create_bottom_panel(self): self.BOTTOMFRAME = tk.LabelFrame(self, pady=20, relief=FLAT) self.draw_pie_questions_state(6) self.draw_total_pts() self.add_action_buttons()
logo_label.grid(column=4, row=0) logo2 = Image.open('WUR_logo.png') logo2 = ImageTk.PhotoImage(logo2) logo_2_label = tk.Label(image=logo2) logo_2_label.image = logo logo_2_label.grid(column=4, row=1) r = tk.StringVar() # Select species r.set("'B.Nigra'") r2 = tk.StringVar() # Treatment, HL or LL r2.set("LL") r3 = tk.IntVar() # Oxygen, 0.21 or 0.02 r3.set(0.21) frame_species = tk.LabelFrame(root, text="Species", padx=5, pady=5) frame_species.grid(column=0, row=0) frame_treatment = tk.LabelFrame(root, text="Treatment", padx=5, pady=5) frame_treatment.grid(column=1, row=0) frame_Oxygen = tk.LabelFrame(root, text="Oxygen", padx=5, pady=5) frame_Oxygen.grid(column=2, row=0) #Species and treatment btn1 = tk.Radiobutton(frame_species, text="B.Nigra", variable=r, value="B.Nigra") btn2 = tk.Radiobutton(frame_species, text="H.Incana", variable=r, value="H.Incana")
def Param_widgets(self): """ Create wigets of the 'Parameters' pannel """ #NOTE This function is debugged and clean # ---------------------------------- Clocks ---------------------------------- # #Date Frame self.date_frame = tk.LabelFrame(self.Parameters, text='Date', bg='#962E12', width=400, height=80) self.date_frame.grid(row=0, column=0, padx=22) self.date_frame.grid_propagate(0) #Create clock functions def lcl_clock(): """ A local datetime clock, based on the work of Vegeseat (https://www.daniweb.com/programming/software-development/code/216785/tkinter-digital-clock-python)""" lcl_datetime = time.strftime( 'Date : %d / %m / %Y -- Hour : %H h %M min %S sec') self.lcl_date_lbl.config(text=lcl_datetime) self.lcl_date_lbl.after(1000, lcl_clock) def sdrl_clock(): """ A sidereal datetime clock """ sdrl_datetime = time.strftime( 'Date : %d / %m / %Y -- Hour : %H h %M min %S sec') self.sdrl_date_lbl.config(text=sdrl_datetime) self.sdrl_date_lbl.after(1000, sdrl_clock) #Display Local date self.lcl_date_lbl = tk.Label(self.date_frame, text=' Local Date : 00:00:00 xx/xx/xxxx', bg='#962E12') self.lcl_date_lbl.grid(row=1, column=0, sticky='w', padx=20) #Display Siderel date self.sdrl_date_lbl = tk.Label( self.date_frame, text=' Sidereal Date : 00:00:00 xx/xx/xxxx', bg='#962E12') self.sdrl_date_lbl.grid(row=2, column=0, sticky='w', padx=20) lcl_clock() sdrl_clock() #-------------------------------------- Follow Mode Activator --------------------------------------# #Follow Mode Frame self.flw_frame = tk.LabelFrame(self.Parameters, text='Des / Activate Follow Mode', bg='#962E12', width=400, height=50) self.flw_frame.grid(row=1, column=0, sticky='w', padx=22, pady=25) self.flw_frame.grid_propagate(0) #Follow Mode activator self.flw_btn = tk.Checkbutton(self.flw_frame, text='Follow Mode', variable=self.flw_state, onvalue=1, offvalue=0, command=self.follow_mode, bg='#962E12', activebackground='#962E12') self.flw_btn.grid(row=9, column=0, columnspan=2, sticky='w', padx=160) #-------------------------------------- Targetable Objects List --------------------------------------# #Targetable Objects Frame self.current_target_frame = tk.LabelFrame(self.Parameters, text='Target Selection', bg='#962E12', width=400, height=80) self.current_target_frame.grid(row=2, column=0, sticky='w', padx=22) self.current_target_frame.grid_propagate(0) #Catalogs choice list self.slct_catalog = ttk.Combobox(self.current_target_frame, text='Select a catalog : ', values=self.catalog_list, justify=tk.CENTER) self.slct_catalog.grid(row=3, column=0, padx=40, pady=15) self.slct_catalog.set(self.catalog_list[0]) self.slct_catalog.bind('<<ComboboxSelected>>', self.update_catalog) #Targetable Objects choice self.slct_target = ttk.Combobox(self.current_target_frame, text='Select a Target :', values=self.objects_list, justify=tk.CENTER) self.slct_target.grid(row=3, column=1) self.slct_target.set(self.objects_list[0]) self.slct_target.bind('<<ComboboxSelected>>', self.update_target)
def __init__(self, master, services, settings, devices): self.master = master self.services = services self.settings = settings self.devices = devices self.currentIP = "192.168.1.177" self.currentPort = "50000" master.title("STRATOS Power Distribution Unit Service Control") master.config(background="#FFFFFF") master.protocol("WM_DELETE_WINDOW", self.endApplication) # Configure default logger. Outputs to console. logging.basicConfig(filename=LOG_FILE, level=logging.INFO, format='%(asctime)s - %(message)s') self.logger = logging.getLogger() # Settings Frame self.settingsFrame = tk.LabelFrame(master, text="Settings", bg="lightgrey", borderwidth=2, relief="groove", width=380, height=250) self.settingsFrame.grid(row=1, column=0, padx=10, pady=(20, 10)) #self.settingsFrame.grid_columnconfigure(1, weight=1) self.settingsFrame.grid_rowconfigure(1, weight=1) for setting in self.settings: if setting.label == "Unit": pass else: setting.settingLabel = tk.Label(self.settingsFrame, bg="lightgrey", text=setting.label, width=14) setting.settingLabel.grid(row=(setting.nb) - 1, column=0, pady=10) if setting.key == "ip": self.currentIP = setting.value elif setting.key == "port": self.currentPort = setting.value self.updateSetting(setting) resetButton = tk.Button(self.settingsFrame, text="Reset", width=4, command=partial(self.reset)) resetButton.grid(row=len(self.settings) + 2, column=2, padx=(0, 10), pady=(10, 15)) # Services Frame self.servicesFrame = tk.LabelFrame(master, text="Output Control", bg="lightgrey", borderwidth=2, relief="groove", width=200, height=200) self.servicesFrame.grid(row=2, columnspan=2, padx=10, pady=(10, 20), sticky="news") #self.servicesFrame.grid_columnconfigure(1, weight=1) ColumnHeading1 = tk.Label(self.servicesFrame, bg="lightgrey", text="SERVICE", width=30) ColumnHeading1.grid(row=1, column=1, padx=5, pady=5) ColumnHeading2 = tk.Label(self.servicesFrame, bg="lightgrey", text="STATE", width=5) ColumnHeading2.grid(row=1, column=2, padx=5, pady=5) ColumnHeading3 = tk.Label(self.servicesFrame, bg="lightgrey", text="Current (A)", width=10) ColumnHeading3.grid(row=1, column=3, padx=(10, 10), pady=5) for service in self.services: self.updateService(service) refreshStatusButton = tk.Button(self.servicesFrame, text="Refresh All", width=10, command=partial(self.refreshStatus)) refreshStatusButton.grid(row=1, column=4, padx=(10, 10), pady=5) # Log Frame self.logFrame = tk.LabelFrame(master, text="TMTC Log", bg="lightgrey", borderwidth=2, relief="groove", width=100, height=200) self.logFrame.grid(row=1, column=1, padx=10, pady=(20, 10)) #self.logFrame.grid_columnconfigure(0, weight=1) scrollbar = tk.Scrollbar(self.logFrame) scrollbar.grid(row=1, column=1, sticky="nsew") logBox = tk.Text(self.logFrame, width=55, height=14, wrap="word", yscrollcommand=scrollbar.set) scrollbar.config(command=logBox.yview) logBox.configure(state='disabled') logBox.grid(row=1, column=0, sticky="nsew") # Attach handler to display logs in log box self.logger.addHandler(TextHandler(logBox))
def Commands_widgets(self): #-------------------------------------- Command Buttons --------------------------------------# #Command Buttons Frame self.btn_frame = tk.LabelFrame(self.Commands, text='Command Buttons', bg='#962E12', width=400, height=150) self.btn_frame.grid(row=0, column=0, sticky='w', padx=22) self.btn_frame.grid_propagate(0) #X axis 'Up' and 'Down' Buttons self.X_up = tk.Button(self.btn_frame, textvariable=self.x_up, bd=2, bg='#9B8866', activebackground='#5d513d', width=20) self.X_up.grid(row=1, column=0, padx=30, pady=25) #! padx of buttons is set only here self.X_down = tk.Button(self.btn_frame, textvariable=self.x_down, bd=2, bg='#9B8866', activebackground='#5d513d', width=20) self.X_down.grid(row=1, column=1, pady=25) #Y axis 'Up' and 'Down' Buttons self.Y_up = tk.Button(self.btn_frame, textvariable=self.y_up, bd=2, bg='#9B8866', activebackground='#5d513d', width=20) self.Y_up.grid(row=5, column=0, padx=10) self.Y_down = tk.Button(self.btn_frame, textvariable=self.y_down, bd=2, bg='#9B8866', activebackground='#5d513d', width=20) self.Y_down.grid(row=5, column=1) # --------------------------- Target Frame --------------------------- # #Target Frame self.target_frame = tk.LabelFrame(self.Commands, text='Current Target', width=400, height=200, bg='#962E12') self.target_frame.grid(row=1, column=0) self.target_frame.grid_propagate(0) #Coords Frame self.coords_frame = tk.LabelFrame(self.target_frame, text='Coordinates', width=396, height=80, bg='#962E12') self.coords_frame.grid(row=0, column=0) self.coords_frame.grid_propagate(0) #Display current target name and coordinates tk.Label(self.coords_frame, text='Target : ', bg='#962E12').grid(row=0, column=0, sticky='w', padx=20) self.current_target_lbl = tk.Label( self.coords_frame, textvariable=self.current_target_strvar, bg='#962E12') self.current_target_lbl.grid(row=0, column=0, sticky='w', padx=70) self.current_target_lbl = tk.Label(self.coords_frame, textvariable=self.target_coords, bg='#962E12') self.current_target_lbl.grid(row=1, column=0, sticky='w', padx=20)
# レーベル入力ボックス inpLabel = tk.Entry(f2, width=25) inpLabel.pack(padx=10, side=tk.LEFT) # Label 3 label3 = tk.Label(f2, text='女優設定(任意)') #label3.pack(padx = 10, side = tk.LEFT) # 女優入力ボックス inpAct = tk.Entry(f2, width=25) #inpAct.pack(padx = 10, side = tk.LEFT) f2.pack(padx=10, pady=5, side=tk.TOP, anchor=tk.NW) # 作成ページ選択 f3 = tk.LabelFrame(root, text='作成ページ') WikiPage = tk.IntVar() WikiPage.set(2) radio11 = tk.Radiobutton(f3, text='一覧+女優', variable=WikiPage, value=2) radio12 = tk.Radiobutton(f3, text='一覧ページのみ', variable=WikiPage, value=1) radio13 = tk.Radiobutton(f3, text='女優ページのみ', variable=WikiPage, value=0) radio11.pack(padx=10, side=tk.LEFT) radio12.pack(padx=20, side=tk.LEFT) radio13.pack(padx=20, side=tk.LEFT) f3.pack(padx=10, pady=5, side=tk.TOP, anchor=tk.NW) # 監督欄の出力 Director = tk.BooleanVar() Director.set(False)
def buildContext(self): """ build user interface :return: """ self.context = tk.LabelFrame(self.window, text='Params Config', height=500, width=700) self.context.grid(row=1, column=0, ipadx=20, padx=45, pady=2) # column 0,1 self.context_host = tk.Label(self.context, text='MySQL Host:') self.context_host.grid(row=0, column=0, padx=15, pady=5, sticky='w') self.entry_host_var = tk.StringVar() self.entry_host = tk.Entry(self.context, textvariable=self.entry_host_var) self.entry_host.grid(row=0, column=1, padx=15, pady=5, sticky='e') self.context_port = tk.Label(self.context, text='MySQL Port:') self.context_port.grid(row=1, column=0, padx=15, pady=5, sticky='w') self.entry_port_var = tk.StringVar() self.entry_port = tk.Entry(self.context, textvariable=self.entry_port_var) self.entry_port.grid(row=1, column=1, padx=15, pady=5) self.context_username = tk.Label(self.context, text='MySQL UserName:'******'w') self.entry_username_var = tk.StringVar() self.entry_username = tk.Entry(self.context, textvariable=self.entry_username_var) self.entry_username.grid(row=2, column=1, padx=15, pady=5) self.context_password = tk.Label(self.context, text='MySQL Password:'******'w') self.entry_password_var = tk.StringVar() self.entry_password = tk.Entry(self.context, textvariable=self.entry_password_var) self.entry_password.grid(row=3, column=1, padx=15, pady=5) self.context_project = tk.Label(self.context, text='ProjectName:') self.context_project.grid(row=4, column=0, padx=15, pady=5, sticky='w') self.entry_project_var = tk.StringVar() self.entry_project = tk.Entry(self.context, textvariable=self.entry_project_var) self.entry_project.grid(row=4, column=1, padx=15, pady=5) self.context_author = tk.Label(self.context, text='Author:') self.context_author.grid(row=5, column=0, padx=15, pady=5, sticky='w') self.entry_author_var = tk.StringVar() self.entry_author = tk.Entry(self.context, textvariable=self.entry_author_var) self.entry_author.grid(row=5, column=1, padx=15, pady=5) self.context_database = tk.Label(self.context, text='Database:') self.context_database.grid(row=6, column=0, padx=15, pady=5, sticky='w') self.entry_database_var = tk.StringVar() self.entry_database = tk.Entry(self.context, textvariable=self.entry_database_var) self.entry_database.grid(row=6, column=1, padx=15, pady=5) self.context_table = tk.Label(self.context, text='Table:') self.context_table.grid(row=7, column=0, padx=15, pady=5, sticky='w') self.entry_table_var = tk.StringVar() self.entry_table = tk.Entry(self.context, textvariable=self.entry_table_var) self.entry_table.grid(row=7, column=1, padx=15, pady=5) self.context_entity = tk.Label(self.context, text='Entity:') self.context_entity.grid(row=8, column=0, padx=15, pady=5, sticky='w') self.entry_entity_var = tk.StringVar() self.entry_entity = tk.Entry(self.context, textvariable=self.entry_entity_var) self.entry_entity.grid(row=8, column=1, padx=15, pady=5) # column 2,3 self.context_file = tk.Label(self.context, text='FilePath:') self.context_file.grid(row=0, column=2, padx=15, pady=5, sticky='w') self.file_path = tk.Entry(self.context, textvariable=self.file_path_var) self.file_path.grid(row=0, column=3, padx=15, pady=5) self.target = tk.Button(self.context, command=self.select_path, text='Select Path') self.target.grid(row=0, column=4, padx=15, pady=5) # self.context_auto = tk.Label(self.context, text='AutoPath:') # self.context_auto.grid(row=1, column=2, padx=15, pady=5, sticky='w') # self.auto_var = tk.IntVar() # self.context_auto = tk.Checkbutton(self.context, text="Auto Path", variable=self.auto_var, onvalue=1, # offvalue=0) # self.context_auto.grid(row=1, column=3, padx=10, pady=5, sticky='w') # # self.context_path = tk.Label(self.context, text='ProjectPath:') # self.context_path.grid(row=2, column=2, padx=15, pady=5, sticky='w') # # self.project_path_var = tk.StringVar() # self.project_path = tk.Entry(self.context, textvariable=self.project_path_var) # self.project_path.grid(row=2, column=3, padx=15, pady=5) # text and button self.text = tk.Text(window, width=75, height=6) self.text.grid(row=2, column=0, padx=45, pady=5, sticky='w') self.start = tk.Button(window, text='Start', width=17, command=self.start) self.start.grid(row=2, column=0, padx=45, sticky='e')