def build_checkbox(par, col, row, text, var): x = ttk.Checkbutton(par, text=text, variable=var) x.grid(column=col, row=row, padx=10, pady=2, ipadx=10, ipady=2) return x
text="Set", command=lambda: colors(listchbv, listchbh, listlabel, colorL)) buttonSet.grid(column=0, row=5, sticky=W) combo = ttk.Combobox(frame, textvar=colorL) combo.grid(column=1, columnspan=4, row=5, sticky="we") combo["values"] = ("Red", "Green", "Yellow", "Purple", "Blue", "Orange") combo.set(combo["values"][0]) combo.bind("<<ComboSelected>>"), lambda e: colors(listchbh, listchbh, listlabel, colorL) #CheckButton for i in range(4): listchbv.append(StringVar()) listchbh.append(StringVar()) check = ttk.Checkbutton(frame, variable=listchbh[i]) check.grid(row=0, column=i + 1) check = ttk.Checkbutton(frame, variable=listchbv[i]) check.grid(row=i + 1, column=0) #Labels for r in range(4): listlabel.append([]) for c in range(4): listlabel[r].append( ttk.Label(frame, relief="ridge", padding=(30, 30, 40, 30))) listlabel[r][c].grid(row=r + 1, column=c + 1, sticky=NSEW) frame.rowconfigure(r + 1, weight=1) frame.columnconfigure(c + 1, weight=1)
def __init__(self, master): self.master = master master.title('Microscopy Analysis Program') master.resizable(True, True) master.configure(background='#e1d8b9') master.iconbitmap( r"C:\Users\Stracey\Documents\Microscopy Density Analysis\venv\cme_logo.ico" ) self.style = ttk.Style() self.style.configure('TFrame', background='#e1d8b9') self.style.configure('TButton', background='#e1d8b9') self.style.configure('TLabel', background='#e1d8b9', font=('Arial', 11)) self.style.configure('Header.TLabel', font=('Arial', 18, 'bold')) self.frame_content = ttk.Frame(master) self.frame_content.pack() self.out_file = StringVar(master) self.out_file.set('Results File.xlsx') ttk.Label(self.frame_content, text='Output File Name:').grid(row=0, column=0, padx=5, sticky='sw') self.out_file_entry = ttk.Entry(self.frame_content, textvariable=self.out_file, width=15, font=('Arial', 10)) self.out_file_entry.grid(row=1, column=0, pady=2) self.images_folder = StringVar(master) self.destination_folder = StringVar(master) self.str_vars = { 'Images Folder': [self.images_folder, self.select_Images_Folder], 'Output File Location': [self.destination_folder, self.select_Output_File_Location] } fields2 = 'Images Folder', 'Output File Location' for d, td2 in enumerate(fields2, 0): self.label = ttk.Entry(self.frame_content, state="disabled", textvariable=self.str_vars[td2][0]).grid( row=1, column=d + 1, padx=5, pady=5, sticky='sw') ttk.Label(self.frame_content, text=td2).grid(row=0, column=d + 1, padx=5, sticky='sw') self.str_vars[td2][0].set("C:/") ttk.Button(self.frame_content, text='Select Folder', command=self.str_vars[td2][1]).grid(row=2, column=d + 1, padx=5, pady=1, sticky='nsew') ttk.Button(self.frame_content, text='Submit', command=self.submit).grid(row=25, column=0, padx=5, pady=10, sticky='nsew') self.default_threshold = StringVar(master) self.default_threshold.set("110") self.CheckVar1 = IntVar() self.CheckVar2 = IntVar() self.man_entry = ttk.Entry(self.frame_content, state="disabled", textvariable=self.default_threshold) self.man_entry.grid(row=16, column=1, padx=5, pady=5, sticky='sw') self.man_checkbutton = ttk.Checkbutton(self.frame_content, text='Manual Threshold', command=self.manual) self.man_checkbutton.state(['!alternate']) self.man_checkbutton.grid(row=15, column=1, padx=5, pady=1, sticky='nsew') self.saveimage_location = StringVar(master) self.saveimage_location.set("C:/") self.saveimage_entry = ttk.Entry(self.frame_content, state="disabled", textvariable=self.saveimage_location) # self.label2.configure(text = "110") self.saveimage_entry.grid(row=1, column=4, padx=5, pady=5, sticky='sw') self.saveimage_checkbutton = ttk.Checkbutton(self.frame_content, text='Save Image', command=self.save_images) self.saveimage_checkbutton.state(['!alternate']) self.saveimage_checkbutton.grid(row=0, column=4, padx=5, pady=1, sticky='nsew') self.imgoutbutton = ttk.Button( self.frame_content, text='Select Folder', command=self.images_Output_File_Location, state="disabled") self.imgoutbutton.grid(row=2, column=4, padx=5, pady=1, sticky='nsew') self.auto_checkbutton = ttk.Checkbutton(self.frame_content, text='Automatic Threshold') self.auto_checkbutton.state(['!alternate']) self.auto_checkbutton.grid(row=15, column=0, padx=5, pady=1, sticky='nsew') self.preview_checkbutton = ttk.Checkbutton(self.frame_content, text='Image Preview') self.preview_checkbutton.state(['!alternate']) self.preview_checkbutton.grid(row=16, column=0, padx=5, pady=1, sticky='nsew')
ttk.Label(mainframe, text='N:').grid(column=0, row=9, sticky=W) #添加输入框,输入值设定为待处理的N值 N = StringVar() n_entry = ttk.Entry(mainframe, width=20, textvariable=N) n_entry.grid(column=1, row=2) #添加输入框,输入值设定为触探杆长度L L = StringVar() L_entry = ttk.Entry(mainframe, width=20, textvariable=L) L_entry.grid(column=1, row=3) #添加单选按钮,判断一般粒径、有效粒径、岩土 choose_formula = StringVar() choose_formula2 = StringVar() # ttk.Radiobutton(mainframe,text='一般沙粒',value='F1',variable=choose_formula,state=ACTIVE).grid(column=0,row=4,sticky=W) ttk.Checkbutton(mainframe, text='有效沙粒', onvalue='F1', variable=choose_formula).grid(column=0, row=5, sticky=W) ttk.Checkbutton(mainframe, text='沙土', onvalue='F2', variable=choose_formula2, command=changestate).grid(column=0, row=6, sticky=W) ##添加输入框,输入值设定为实测深度处土的实际上覆压力e0 e = StringVar() e_entry = ttk.Entry(mainframe, width=20, textvariable=e, state=DISABLED) e_entry.grid(column=1, row=7) #计算按钮 ttk.Button(mainframe, text='计算', command=formula).grid(column=1, row=8, sticky=(W, E)) #添加输入框, result_n = StringVar()
main_config.write(key + ' ' + preset_configs[key] + '\n') main_config.close() state_id.set("Все изменения сохранены") except: mb.showerror("Ошибка!", "Путь к папке указан неверно или не указан вовсе") state_id = tk.StringVar(frame1, 'Изменения не сохранены') check_var = IntVar() check = ttk.Checkbutton( frame, text='Отражения на воде', onvalue=1, offvalue=0, variable=check_var, style='my.TCheckbutton', command=lambda: on_click(check_var, "r_waterdrawreflection")).pack( anchor=W, padx=2, ipady=5) check_var1 = IntVar() check1 = ttk.Checkbutton( frame, text='Продвинутые отражения на воде', onvalue=1, offvalue=0, variable=check_var1, style='my.TCheckbutton', command=lambda: on_click(check_var1, "r_waterforceexpensive")).pack( anchor=W, padx=2, ipady=5) check_var2 = IntVar()
def make_map_widgets(frame: ttk.Frame): """Create widgets for the map settings pane. These are things which mainly affect the geometry or gameplay of the map. """ frame.columnconfigure(0, weight=1) voice_frame = ttk.LabelFrame( frame, text=_('Voicelines:'), labelanchor=NW, ) voice_frame.grid(row=1, column=0, sticky=EW) UI['voice_priority'] = voice_priority = ttk.Checkbutton( voice_frame, text=_("Use voiceline priorities"), variable=VOICE_PRIORITY_VAR, ) voice_priority.grid(row=0, column=0) add_tooltip( voice_priority, _("Only choose the highest-priority voicelines. This means more " "generic lines will can only be chosen if few test elements are in " "the map. If disabled any applicable lines will be used."), ) elev_frame = ttk.LabelFrame( frame, text=_('Spawn at:'), labelanchor=N, ) elev_frame.grid(row=2, column=0, sticky=EW) elev_frame.columnconfigure(0, weight=1) elev_frame.columnconfigure(1, weight=1) UI['elev_preview'] = ttk.Radiobutton( elev_frame, text=_('Entry Door'), value=0, variable=start_in_elev, ) UI['elev_elevator'] = ttk.Radiobutton( elev_frame, text=_('Elevator'), value=1, variable=start_in_elev, ) UI['elev_preview'].grid(row=0, column=0, sticky=W) UI['elev_elevator'].grid(row=0, column=1, sticky=W) add_tooltip( UI['elev_elevator'], _("When previewing in SP, spawn inside the entry elevator. " "This also disables the map restarts when you reach the " "exit door. Use this to examine the entry and exit corridors.")) add_tooltip( UI['elev_preview'], _("When previewing in SP, spawn just before the entry door. " "When you reach the exit door, the map will restart.")) corr_frame = ttk.LabelFrame( frame, width=18, text=_('Corridor:'), labelanchor=N, ) corr_frame.grid(row=3, column=0, sticky=EW) corr_frame.columnconfigure(0, weight=1) corr_frame.columnconfigure(1, weight=1) make_corr_wid('sp_entry') make_corr_wid('sp_exit') make_corr_wid('coop') load_corridors() CORRIDOR['sp_entry'].widget(corr_frame).grid(row=1, column=0, sticky=EW) CORRIDOR['sp_exit'].widget(corr_frame).grid(row=1, column=1, sticky=EW) CORRIDOR['coop'].widget(corr_frame).grid(row=2, column=1, sticky=EW) ttk.Label( corr_frame, text=_('SP Entry:'), anchor=CENTER, ).grid(row=0, column=0, sticky=EW) ttk.Label( corr_frame, text=_('SP Exit:'), anchor=CENTER, ).grid(row=0, column=1, sticky=EW) ttk.Label( corr_frame, text=_('Coop:'), anchor=CENTER, ).grid(row=2, column=0, sticky=EW) model_frame = ttk.LabelFrame( frame, text=_('Player Model (SP):'), labelanchor=N, ) model_frame.grid(row=4, column=0, sticky=EW) UI['player_mdl'] = ttk.Combobox( model_frame, exportselection=0, textvariable=player_model_var, values=[PLAYER_MODELS[mdl] for mdl in PLAYER_MODEL_ORDER], width=20, ) # Users can only use the dropdown UI['player_mdl'].state(['readonly']) UI['player_mdl'].grid(row=0, column=0, sticky=EW) UI['player_mdl'].bind('<<ComboboxSelected>>', set_model) model_frame.columnconfigure(0, weight=1)
def main(): # PLOTDIAGR = show PLOTRAWDISP = 0 PLOTDISPALL = 0 SAVEFILES = 0 if not os.path.isdir("TOMO_DISP"): os.makedirs("TOMO_DISP") db = connect() PER = get_config(db, "ftan_periods", plugin="Tomo") PER = np.array([float(pi) for pi in PER.split(',')]) fmin = float(get_config(db, "ftan_fmin", plugin="Tomo")) fmax = float(get_config(db, "ftan_fmax", plugin="Tomo")) vgmin = float(get_config(db, "ftan_vgmin", plugin="Tomo")) vgmax = float(get_config(db, "ftan_vgmax", plugin="Tomo")) bmin = float(get_config(db, "ftan_bmin", plugin="Tomo")) bmax = float(get_config(db, "ftan_bmax", plugin="Tomo")) diagramtype = get_config(db, "ftan_diagramtype", plugin="Tomo") nfreq = int(get_config(db, "ftan_nfreq", plugin="Tomo")) ampmin = float(get_config(db, "ftan_ampmin", plugin="Tomo")) global data data = pd.DataFrame() # nfreq = 100 db = connect() def load_dir(): folder = askdirectory(parent=root) files = sorted( glob.glob(os.path.join(os.path.realpath(folder), "*_MEAN.*"))) cb['values'] = files cb_val.set(files[0]) def save(): global data print(data.head()) filename = cb_val.get() filename = filename.replace("TOMO_SAC", "TOMO_DISP").replace( ".sac", ".csv").replace(".SAC", ".csv") if not os.path.isdir(os.path.split(filename)[0]): os.makedirs(os.path.split(filename)[0]) data.to_csv(filename) def process(e=None): filename = cb_val.get() NET1, STA1, NET2, STA2, crap = os.path.split(filename)[1].split('_') st = read(filename) dist = st[0].stats.sac.dist dt = st[0].stats.delta p = ccf.gca() p.cla() taxis = np.arange(st[0].stats.npts) * st[0].stats.delta vaxis = dist / taxis[1:] zone = np.where((vaxis >= float(_vgmin.get())) & (vaxis <= float(_vgmax.get())))[0] p.plot(taxis, st[0].data) p.plot(taxis[zone], st[0].data[zone], c='r') ccf.subplots_adjust(bottom=0.25) ccfcanvas.show() per, disper, seeds = pickgroupdispcurv(filename, _fmin.get(), _fmax.get(), _vgmin.get(), _vgmax.get(), _bmin.get(), _bmax.get(), diagramtype, nfreq, _ampmin.get(), dist) basename = "%s.%s_%s.%s_%s" % (NET1, STA1, NET2, STA2, crap) basename = basename.replace(".SAC", "") for _ in [ "write_amp.txt", "write_disp.txt", "write_FP.txt", "write_ph.txt", "write_TV.txt", ]: shutil.move(_, _.replace("write", basename)) U = np.loadtxt('%s_TV.txt' % basename) P = np.loadtxt('%s_FP.txt' % basename) xmin = min(P) xmax = max(P) ymin = min(U) ymax = max(U) amp = np.loadtxt('%s_amp.txt' % basename).T iu = np.where((disper >= ymin) & (disper <= ymax)) per = per[iu] disper = disper[iu] Per, Vitg = np.meshgrid(P, U) f.clf() p = f.gca() p.cla() if int(_normed.get()): for i in range(amp.shape[1]): amp[:, i] /= amp[:, i].max() c = p.contourf(Per, Vitg, amp, 35, cmap=cm_val.get()) f.colorbar(c) idxx = np.where(float(_minWL.get()) * per * disper < dist)[0] p.plot(per, disper, '-ok', lw=1.5) p.scatter(per[idxx], disper[idxx], marker='o', s=100, c="green", lw=1.5) p.scatter(seeds[:, 0], seeds[:, 1], s=10, marker='d', facecolor='w', edgecolor="k") global data data = pd.DataFrame(disper[idxx], index=per[idxx], columns=["Velocity"]) data.index.name = "Period" # TODO add axes labels depending on diagramtype p.set_xlabel("Period (s)", fontsize=12) p.set_ylabel('Velocity (km/s)', fontsize=12) p.set_xlim(xmin, xmax) p.set_ylim(ymin, ymax) p.set_title("%s.%s - %s.%s (%.2f km)" % (NET1, STA1, NET2, STA2, dist)) canvas.show() def previous_file(e=None): idx = cb['values'].index(cb.get()) if idx > 0: idx -= 1 cb.set(cb['values'][idx]) process() def next_file(e=None): idx = cb['values'].index(cb.get()) if idx < len(cb['values']): idx += 1 cb.set(cb['values'][idx]) process() #root root = Tk() root.title("MSNoise-TOMO: Time-Frequency & Dispersion Curve Picking Tool") # root.resizable(True, True) # menubar = Menu(root) # filemenu = Menu(menubar, tearoff=0) # filemenu.add_command(label="Open", command=openfile) # filemenu.add_separator() # filemenu.add_command(label="Exit", command=root.quit) # menubar.add_cascade(label="File", menu=filemenu) # root.config(menu=menubar) #mainframe gui_style = ttk.Style() gui_style.configure('My.TLabel', background='#ffffff') gui_style.configure('My.TButton', background='#ff0011') gui_style.configure('M2.TButton', background='#B7E2F0') gui_style.configure('My.TFrame', background='#ffffff') mainframe = ttk.Frame(root, padding="3 3 12 12", style='My.TFrame') mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) _folder = StringVar(root, value=os.path.join(os.getcwd(), "TOMO_SAC")) ttk.Button(mainframe, text="Select Folder", command=load_dir, style='M2.TButton').grid(column=1, row=1, sticky=W) cb_val = StringVar() files = sorted( glob.glob(os.path.join(os.path.realpath(_folder.get()), "*_MEAN.*"))) cb = ttk.Combobox(mainframe, width=55, textvariable=cb_val, height=4) cb.grid(column=2, row=1, sticky=(W, E), columnspan=2) if len(files): cb['values'] = files cb_val.set(files[0]) else: cb_val.set("<-- SELECT A FOLDER BY CLICKING ON THE BUTTON") # PARAMS PANEL # myFont = Font(family="Helvetica", size=12) _vgmin = StringVar(root, value=vgmin) vgminSize = ttk.Entry(mainframe, width=7, textvariable=_vgmin) vgminSize.grid(column=2, row=2, sticky=(W, E)) tmp = ttk.Label(mainframe, text="Vg Min ", style='My.TLabel').grid(column=1, row=2, sticky=W) _vgmax = StringVar(root, value=vgmax) vgmaxSize = ttk.Entry(mainframe, width=7, textvariable=_vgmax) vgmaxSize.grid(column=2, row=3, sticky=(W, E)) ttk.Label(mainframe, text="Vg Max ", style='My.TLabel').grid(column=1, row=3, sticky=W) _minSNR = StringVar(root, value=0.0) minSNRSize = ttk.Entry(mainframe, width=7, textvariable=_minSNR) minSNRSize.grid(column=2, row=4, sticky=(W, E)) ttk.Label(mainframe, text="Min SNR ", style='My.TLabel').grid(column=1, row=4, sticky=W) _minWL = StringVar(root, value=1.0) minWLSize = ttk.Entry(mainframe, width=7, textvariable=_minWL) minWLSize.grid(column=2, row=5, sticky=(W, E)) ttk.Label(mainframe, text="Min Wavelength ", style='My.TLabel').grid(column=1, row=5, sticky=W) _fmin = StringVar(root, value=fmin) fminSize = ttk.Entry(mainframe, width=7, textvariable=_fmin) fminSize.grid(column=2, row=6, sticky=(W, E)) ttk.Label(mainframe, text="Min Frequency ", style='My.TLabel').grid(column=1, row=6, sticky=W) _fmax = StringVar(root, value=fmax) fmaxSize = ttk.Entry(mainframe, width=7, textvariable=_fmax) fmaxSize.grid(column=2, row=7, sticky=(W, E)) ttk.Label(mainframe, text="Max Frequency ", style='My.TLabel').grid(column=1, row=7, sticky=W) _diagType = StringVar(root, value="PV") diagTypeSize = ttk.Entry(mainframe, width=7, textvariable=_diagType) diagTypeSize.grid(column=2, row=8, sticky=(W, E)) ttk.Label(mainframe, text="Diagram (...) ", style='My.TLabel').grid(column=1, row=8, sticky=W) _bmin = StringVar(root, value=bmin) bminSize = ttk.Entry(mainframe, width=7, textvariable=_bmin) bminSize.grid(column=2, row=9, sticky=(W, E)) ttk.Label(mainframe, text="Bmin ", style='My.TLabel').grid(column=1, row=9, sticky=W) _bmax = StringVar(root, value=bmax) bminSize = ttk.Entry(mainframe, width=7, textvariable=_bmax) bminSize.grid(column=2, row=10, sticky=(W, E)) ttk.Label(mainframe, text="Bmax ", style='My.TLabel').grid(column=1, row=10, sticky=W) _ampmin = StringVar(root, value=ampmin) ampminSize = ttk.Entry(mainframe, width=7, textvariable=_ampmin) ampminSize.grid(column=2, row=11, sticky=(W, E)) ttk.Label(mainframe, text="Amp Min ", style='My.TLabel').grid(column=1, row=11, sticky=W) maps = sorted(m for m in plt.cm.datad) cm_val = StringVar() cm = ttk.Combobox(mainframe, width=7, textvariable=cm_val, height=4) cm.grid(column=2, row=12, sticky=(W, E)) ttk.Label(mainframe, text="Cmap ", style='My.TLabel').grid(column=1, row=12, sticky=W) cm['values'] = maps cm_val.set("hot_r") ccf = Figure(figsize=(5, 1), dpi=100) ccfcanvas = FigureCanvasTkAgg(ccf, master=mainframe) ccfcanvas.get_tk_widget().grid(row=2, column=3, rowspan=2) f = Figure(dpi=100) canvas = FigureCanvasTkAgg(f, master=mainframe) canvas.get_tk_widget().grid(row=4, column=3, rowspan=9) _normed = IntVar() chh = ttk.Checkbutton(mainframe, text="Normed", variable=_normed, \ onvalue=1, offvalue=0).grid(column=1, row=13, sticky=W) ttk.Button(mainframe, text="Compute", command=process, style='My.TButton').grid(column=2, row=13, sticky=W) ttk.Button(mainframe, text="Save", command=save, style='My.TButton').grid(column=2, row=14, sticky=W) toolbar = NavigationToolbar2TkAgg(canvas, mainframe) toolbar.update() toolbar.grid(column=3, row=14, columnspan=1, sticky=W) # canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=0) def onclick(event): print('button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % (event.button, event.x, event.y, event.xdata, event.ydata)) cid = f.canvas.mpl_connect('button_press_event', onclick) for child in mainframe.winfo_children(): child.grid_configure(padx=0.5, pady=0.5) root.bind('<Return>', process) root.bind('<KP_Enter>', process) root.bind('<Control-Key-Left>', previous_file) root.bind('<Control-Key-Right>', next_file) icon = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'img', 'msnoise.gif') img = PhotoImage(file=icon) root.tk.call('wm', 'iconphoto', root._w, img) # print(os.path.isfile(icon)) # root.iconbitmap(icon) root.mainloop()
eta_entry = ttk.Entry(form, textvariable = eta_str) eta_entry.place(x = 250, y = 230) m_str = StringVar(form, value= '1') m_entry = ttk.Entry(form, textvariable = m_str) m_entry.place(x = 250, y = 280) mse_str = StringVar(form, value= '0.01') mse_entry = ttk.Entry(form, textvariable = mse_str) mse_entry.place(x = 250, y = 330) #create checkbox b_string = StringVar() b_string.set("Add bias") check_var = IntVar() b_check = ttk.Checkbutton(form, textvariable = b_string, variable = check_var) b_check.place(x = 30, y = 380) #global_data_variables f1 = 'X1' f2 = 'X2' c1 = 'C1' c2 = 'C2' eta = 0.0 m = 1 b = 0 mse = 0.01 #save after complete input def save(): global f1 global f2 global c1
global start global end st = startBox.get().split(',') ed = endBox.get().split(',') start = grid[int(st[0])][int(st[1])] end = grid[int(ed[0])][int(ed[1])] window.quit() window.destroy() window = Tk() label = Label(window, text='Start(x,y): ') startBox = Entry(window) label1 = Label(window, text='End(x,y): ') endBox = Entry(window) var = IntVar() showPath = ttk.Checkbutton(window, text='Show Steps :', onvalue=1, offvalue=0, variable=var) submit = Button(window, text='Submit', command=onsubmit) showPath.grid(columnspan=2, row=2) submit.grid(columnspan=2, row=3) label1.grid(row=1, pady=3) endBox.grid(row=1, column=1, pady=3) startBox.grid(row=0, column=1, pady=3) label.grid(row=0, pady=3) window.update() mainloop() pygame.init() openSet.append(start)
map_entry = ttk.Entry(main, width=14, textvariable=map_id) map_entry.grid(row=0, column=1) user_label = ttk.Label(main, text="User id:") user_label.grid(row=1, column=0) user_entry = ttk.Entry(main, width=14, textvariable=user_id) user_entry.grid(row=1, column=1) run_button = ttk.Button(main, text="Run", command=run) run_button.grid(row=2, column=1) # Make visual elements for options frame should_cache = ttk.Frame(options) should_cache.grid(row=0, column=0) cache_check = ttk.Checkbutton(should_cache, variable=cache) cache_check.grid(row=0, column=0) cache_label = ttk.Label(should_cache, text="Cache downloaded replays?") cache_label.grid(row=0, column=1) should_local_compare = ttk.Frame(options) should_local_compare.grid(row=1, column=0) local_compare_check = ttk.Checkbutton(should_local_compare, variable=local) local_compare_check.grid(row=0, column=0) local_compare_label = ttk.Label(should_local_compare, text="Compare to local replays?") local_compare_label.grid(row=0, column=1) top_x_plays = ttk.Frame(options) top_x_plays.grid(row=2, column=0) top_plays_check = ttk.Checkbutton(top_x_plays, variable=compare_to_map)
import tkinter as tk from tkinter import ttk root = tk.Tk() root.config(width=350, height=250) root.title("Aplicación de escritorio en Tcl/Tk") frame = tk.Frame(root) frame.place(x=0, y=0, width=350, height=250) button = tk.Button(frame, text="Hola mundo!") button.place(x=50, y=50) textbox = tk.Entry(frame) textbox.insert(0, "Ingrese su nombre...") textbox.place(x=50, y=100) checkbox = ttk.Checkbutton(frame, text="Opción 1") checkbox.place(x=50, y=150) root.mainloop()
gender_combobox = ttk.Combobox(root , width=13 , textvariable=gender_var, state ='readonly') gender_combobox['value'] = ('Male' , 'Female' , 'Other') gender_combobox.current(0) gender_combobox.grid(row=6 , column=1) #radio button usertype = tk.StringVar() radiobtn1 = ttk.Radiobutton(root , text='Student' , value='Student' , variable=usertype) radiobtn1.grid(row=8 , column=0) radiobtn2 = ttk.Radiobutton(root , text='Teacher' , value='Teacher' , variable=usertype) radiobtn2.grid(row=8 , column=1) #create button #check button checkbtn_var = tk.IntVar() checkbtn = ttk.Checkbutton(root , text ='Check if you fill all the blanks' , variable=checkbtn_var) checkbtn.grid(row=10 , columnspan=3) def action(): user_name = name_var.get() user_age = age_var.get() user_email = email_var.get() user_gender = gender_var.get() user_type = usertype.get() if checkbtn_var.get() == 0: subscribed = 'NO' else: subscribed = 'YES' #write to csv file with open('file.csv' , 'a' ) as f:
FR0 = Frame(F3) FR0.pack() v_radio = StringVar() RB1 = ttk.Radiobutton(FR0,text='Japanese',variable=v_radio,value='ja') RB2 = ttk.Radiobutton(FR0,text='Thai',variable=v_radio,value='th') RB1.invoke() RB1.grid(row=0,column=1) RB2.grid(row=0,column=2) savetosheet = IntVar() savetosheet.set(0) cbtn = ttk.Checkbutton(F3,text='Save to Database',variable=savetosheet) cbtn.pack() v_texttras = StringVar() #เก็บสิ่งที่เราพิมพ์ไว้ E1 = ttk.Entry(F3, textvariable = v_texttras,font=('Angsana New',20),width=50) E1.pack(pady=20) E1.bind('<Return>',TranslateNow) EBF = Frame(F3) EBF.pack(pady=20,ipadx=20,ipady=10) EB1 = ttk.Button(EBF,text='แปล',command=TranslateNow) EB1.grid(row=0,column=0,padx=10,ipadx=15,ipady=10)
text="Student", value="Student", variable=usertype) radiobtn1.grid(row=4, column=0) radiobtn2 = ttk.Radiobutton(win, text="Teacher", value="Teacher", variable=usertype) radiobtn2.grid(row=4, column=1) #Create a CHECK BUTTON checkbtn_var = tk.IntVar() checkbtn = ttk.Checkbutton(win, text="Check if you love me", variable=checkbtn_var) checkbtn.grid( row=5, columnspan=3 ) #columnspan--> take 3 columns but dont extend the other columns # # SAVE THE DATA IN A FILE THAT USER HAVE ENTERED in txt file # # CREATE BUTTON # def action(): # action for submit button # username=name_var.get() # userage=age_var.get() # useremail=email_var.get() # usergender=gender_var.get() # user_type=usertype.get() # if checkbtn_var.get()==0:
fluidViscosity_entry.grid(row=rowWindow, column=2, sticky=W) #Second Instructions row rowWindow += 1 instructions3_text = Message( mainframe, text= "To estimate dynamic rates of capture, also fill in the following variables (and keep the chekcbox on):" ) instructions3_text.configure(width=messageWidth, bg=instructionsBG) instructions3_text.grid(row=rowWindow, column=1, columnspan=2) #Dynamic rates check button row rowWindow += 1 dynamic_check = ttk.Checkbutton(mainframe, variable=dynamicActiveSec, text="Estimate dynamic rates of capture", command=dynamicActive) dynamic_check.grid(row=rowWindow, column=1, columnspan=2, sticky=N) #Settings for the "collectorHeight" row rowWindow += 1 collectorHeight_label = ttk.Label(mainframe, text="Collector Height [m]") collectorHeight_label.grid(row=rowWindow, column=1, sticky=W) collectorHeight_entry = tk.Entry(mainframe, width=16, textvariable=collectorHeight, disabledforeground=disabledFG, disabledbackground=disabledBG, state='disabled') collectorHeight_entry.grid(row=rowWindow, column=2, sticky=W)
label2 = ttk.Label(content, text="Direction:") button = ttk.Button(content, text="Find") button1 = ttk.Button(content, text="Find All") button2 = ttk.Button(content, text="Replace") onevar = BooleanVar() twovar = BooleanVar() threevar = BooleanVar() onevar.set(False) twovar.set(False) threevar.set(False) checkbutton = ttk.Checkbutton(content, text="Match whole word only", variable=onevar, onvalue=True) checkbutton1 = ttk.Checkbutton(content, text="Match case", variable=twovar, onvalue=True) checkbutton2 = ttk.Checkbutton(content, text="Wrap around", variable=threevar, onvalue=True) radio = ttk.Radiobutton(content, text="Up", value=1) radio1 = ttk.Radiobutton(content, text="Down", value=2) content.grid(row=0, column=0) label.grid(row=0, column=0, sticky='e')
def make_comp_widgets(frame: ttk.Frame): """Create widgets for the compiler settings pane. These are generally things that are aesthetic, and to do with the file and compilation process. """ frame.columnconfigure(0, weight=1) thumb_frame = ttk.LabelFrame( frame, text=_('Thumbnail'), labelanchor=N, ) thumb_frame.grid(row=0, column=0, sticky=EW) thumb_frame.columnconfigure(0, weight=1) UI['thumb_auto'] = ttk.Radiobutton( thumb_frame, text=_('Auto'), value='AUTO', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_peti'] = ttk.Radiobutton( thumb_frame, text=_('PeTI'), value='PETI', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_custom'] = ttk.Radiobutton( thumb_frame, text=_('Custom:'), value='CUST', variable=chosen_thumb, command=set_screen_type, ) UI['thumb_label'] = ttk.Label( thumb_frame, anchor=CENTER, cursor=utils.CURSORS['link'], ) UI['thumb_label'].bind( utils.EVENTS['LEFT'], find_screenshot, ) UI['thumb_cleanup'] = ttk.Checkbutton( thumb_frame, text=_('Cleanup old screenshots'), variable=cleanup_screenshot, ) UI['thumb_auto'].grid(row=0, column=0, sticky='W') UI['thumb_peti'].grid(row=0, column=1, sticky='W') UI['thumb_custom'].grid(row=1, column=0, columnspan=2, sticky='NEW') UI['thumb_cleanup'].grid(row=3, columnspan=2, sticky='W') add_tooltip( UI['thumb_auto'], _("Override the map image to use a screenshot automatically taken " "from the beginning of a chamber. Press F5 to take a new " "screenshot. If the map has not been previewed recently " "(within the last few hours), the default PeTI screenshot " "will be used instead.")) add_tooltip(UI['thumb_peti'], _("Use the normal editor view for the map preview image.")) custom_tooltip = _( "Use a custom image for the map preview image. Click the " "screenshot to select.\n" "Images will be converted to JPEGs if needed.") add_tooltip( UI['thumb_custom'], custom_tooltip, ) add_tooltip( UI['thumb_label'], custom_tooltip, ) add_tooltip( UI['thumb_cleanup'], _('Automatically delete unused Automatic screenshots. ' 'Disable if you want to keep things in "portal2/screenshots". ')) if chosen_thumb.get() == 'CUST': # Show this if the user has set it before UI['thumb_label'].grid(row=2, column=0, columnspan=2, sticky='EW') set_screenshot() # Load the last saved screenshot vrad_frame = ttk.LabelFrame( frame, text=_('Lighting:'), labelanchor=N, ) vrad_frame.grid(row=1, column=0, sticky=EW) UI['light_fast'] = ttk.Radiobutton( vrad_frame, text=_('Fast'), value=0, variable=vrad_light_type, ) UI['light_fast'].grid(row=0, column=0) UI['light_full'] = ttk.Radiobutton( vrad_frame, text=_('Full'), value=1, variable=vrad_light_type, ) UI['light_full'].grid(row=0, column=1) add_tooltip( UI['light_fast'], _("Compile with lower-quality, fast lighting. This speeds " "up compile times, but does not appear as good. Some " "shadows may appear wrong.\n" "When publishing, this is ignored.")) add_tooltip( UI['light_full'], _("Compile with high-quality lighting. This looks correct, " "but takes longer to compute. Use if you're arranging lights. " "When publishing, this is always used.")) packfile_enable = ttk.Checkbutton( frame, text=_('Dump packed files to:'), variable=packfile_dump_enable, command=set_pack_dump_enabled, ) packfile_frame = ttk.LabelFrame( frame, labelwidget=packfile_enable, ) packfile_frame.grid(row=2, column=0, sticky=EW) UI['packfile_filefield'] = packfile_filefield = FileField( packfile_frame, is_dir=True, loc=COMPILE_CFG.get_val('General', 'packfile_dump_dir', ''), callback=set_pack_dump_dir, ) packfile_filefield.grid(row=0, column=0, sticky=EW) packfile_frame.columnconfigure(0, weight=1) ttk.Frame(packfile_frame).grid(row=1) set_pack_dump_enabled() add_tooltip( packfile_enable, _("When compiling, dump all files which were packed into the map. Useful" " if you're intending to edit maps in Hammer.")) count_frame = ttk.LabelFrame( frame, text=_('Last Compile:'), labelanchor=N, ) count_frame.grid(row=7, column=0, sticky=EW) count_frame.columnconfigure(0, weight=1) count_frame.columnconfigure(2, weight=1) ttk.Label( count_frame, text=_('Entity'), anchor=N, ).grid(row=0, column=0, columnspan=3, sticky=EW) UI['count_entity'] = ttk.Progressbar( count_frame, maximum=100, variable=count_entity, length=120, ) UI['count_entity'].grid( row=1, column=0, columnspan=3, sticky=EW, padx=5, ) ttk.Label( count_frame, text=_('Overlay'), anchor=CENTER, ).grid(row=2, column=0, sticky=EW) UI['count_overlay'] = ttk.Progressbar( count_frame, maximum=100, variable=count_overlay, length=50, ) UI['count_overlay'].grid(row=3, column=0, sticky=EW, padx=5) UI['refresh_counts'] = SubPane.make_tool_button( count_frame, img.png('icons/tool_sub', resize_to=16), refresh_counts, ) UI['refresh_counts'].grid(row=3, column=1) add_tooltip( UI['refresh_counts'], _("Refresh the compile progress bars. Press after a compile has been " "performed to show the new values."), ) ttk.Label( count_frame, text=_('Brush'), anchor=CENTER, ).grid(row=2, column=2, sticky=EW) UI['count_brush'] = ttk.Progressbar( count_frame, maximum=100, variable=count_brush, length=50, ) UI['count_brush'].grid(row=3, column=2, sticky=EW, padx=5) for wid_name in ('count_overlay', 'count_entity', 'count_brush'): # Add in tooltip logic to the widgets. add_tooltip(UI[wid_name]) refresh_counts(reload=False)
def __init__(self, parent, controller): Frame.__init__(self, parent, bg="sea green") label = Label(self, text="Normline", \ font=LARGE_FONT, bg="sea green", bd = 1, relief = SOLID) label.place(relx=0, rely=0, relwidth=1) button1 = ttk.Button(self, text="Back to Home", command=lambda: controller.show_frame(StartPage)) button1.place(relx=x1, rely=y, width=width, height=height) button2 = ttk.Button(self, text="Mass Spec", command=lambda: controller.show_frame(Mass)) button2.place(relx=x2, rely=y, width=width, height=height) button3 = ttk.Button(self, text="Powerfile", command=lambda: controller.show_frame(Powerfile)) button3.place(relx=x3, rely=y, width=width, height=height) # Opening a Directory: self.location = "/" self.fname = "" def open_dir(self): root = Tk() root.withdraw() root.filename = filedialog.askopenfilename( initialdir=self.location, title="Select file", filetypes=(("Felix files", "*.felix"), ("all files", "*.*"))) filename = root.filename filename = filename.split("/") self.fname = filename[-1] del filename[-1] self.location = "/".join(filename) root.destroy() current_location.config(text=self.location) filename_label.config(text=self.fname) return # Labels and buttons: browse_loc = ttk.Button(self, text="Browse File") browse_loc.config(command=lambda: open_dir(self)) # Printing current location: current_location = Label(self) filename_label = Label(self) #Normline #location_label = Label(self, text = "Location:", font=("Times", 10, "bold")) #location = StringVar() #location.set("Enter file lcoation here") #location_entry = Entry(self, bg = "white", bd = 5,\ # textvariable=location, justify = LEFT,\ # font=("Times", 12, "italic")) fname_label = Label(self, text="Filename: ", font=("Times", 10, "bold")) #fname = StringVar() #fname.set("Enter here") #fname_input = Entry(self, bg = "white", bd = 5, \ # textvariable=fname, justify = LEFT, font=("Times", 12, "italic")) # the compund details: molecule_name_label = Label(self, text="Molecule", font=("Times", 10, "bold")) temp_label = Label(self, text="TEMP(K)", font=("Times", 10, "bold")) bwidth_label = Label(self, text="B0 Width(ms)", font=("Times", 10, "bold")) ion_enrg_label = Label(self, text="IE(eV)", font=("Times", 10, "bold")) mname = StringVar() temp = StringVar() bwidth = StringVar() ie = StringVar() mname.set("Molecule") temp.set("-") bwidth.set("-") ie.set("-") molecule_name = Entry(self, bg="white", bd=5, textvariable=mname, justify=LEFT, font=("Times", 12, "italic")) temperature = Entry(self, bg="white", bd=5, textvariable=temp, justify=LEFT, font=("Times", 12, "italic")) bo_Width = Entry(self, bg="white", bd=5, textvariable=bwidth, justify=LEFT, font=("Times", 12, "italic")) ion_enrg = Entry(self, bg="white", bd=5, textvariable=ie, justify=LEFT, font=("Times", 12, "italic")) foravgshow = False normline_button = ttk.Button(self, text="Normline") normline_button.config( command = lambda: normline_correction( self.fname, self.location,\ mname.get(), temp.get(), bwidth.get(), ie.get(),\ normavg_saveCheck_value.get(),\ foravgshow, normallCheck_value.get(), norm_show_value.get() ) ) # Save checkbutton for normall: normallCheck_value = BooleanVar() normallCheck_value.set(False) normallCheck = ttk.Checkbutton(self, text="Plot all files at once", variable=normallCheck_value) # Show checkbutton for Normline: norm_show_value = BooleanVar() norm_show_value.set(True) norm_show = ttk.Checkbutton(self, text="Show", variable=norm_show_value) # avg_labels's label: avg_label = Label(self, text="For Average Spectrum", font=("Times", 12, "italic")) # Avg_Spectrum Labels: avg_title = Label(self, text="Title:", font=("Times", 10, "bold")) avg_ts_ls = Label(self, text="Size\n(Title,Legend)", font=("Times", 10, "bold")) avg_xaxis_count = Label(self, text="X-axis\nticks div:", font=("Times", 10, "bold")) avg_majorTick = Label(self, text="Major\nTickSz:", font=("Times", 10, "bold")) # avg_label's Entry widget: i_avg_title = StringVar() i_avg_ts = IntVar() i_avg_lgs = IntVar() i_avg_minor = IntVar() i_avg_major = IntVar() i_avg_majorTick = IntVar() i_avg_title.set("Title") i_avg_ts.set(10) i_avg_lgs.set(5) i_avg_minor.set(5) i_avg_major.set(50) i_avg_majorTick.set(8) avg_title_Entry = Entry(self, bg="white", bd=5, textvariable=i_avg_title, justify=LEFT, font=("Times", 12, "italic")) avg_ts_Entry = Entry(self, bg="white", bd=5, textvariable=i_avg_ts, justify=LEFT, font=("Times", 10, "bold")) avg_lgs_Entry = Entry(self, bg="white", bd=5, textvariable=i_avg_lgs, justify=LEFT, font=("Times", 10, "bold")) avg_minor_Entry = Entry(self, bg="white", bd=5, textvariable=i_avg_minor, justify=LEFT, font=("Times", 10, "bold")) avg_major_Entry = Entry(self, bg="white", bd=5, textvariable=i_avg_major, justify=LEFT, font=("Times", 10, "bold")) avg_majorTick_Entry = Entry(self, bg="white", bd=5, textvariable=i_avg_majorTick, justify=LEFT, font=("Times", 10, "bold")) # avg spectrum output filename: avg_outputFilename = Label(self, \ text = "Out. filename\n(Average)", font=("Times", 10, "bold")) output_filename = StringVar() output_filename.set("Average") avg_outputFilename_entry = Entry(self, bg = "white", bd = 5, \ textvariable=output_filename, justify = LEFT, font=("Times", 12, "italic")) #Avg_Spectrum Button specificFiles_status = False allFiles_status = True avg_button = ttk.Button(self, text="Avg_spectrum") avg_button.config(command = lambda: avgSpec_plot( i_avg_title.get(), \ i_avg_ts.get(), \ i_avg_lgs.get(), \ i_avg_minor.get(), \ i_avg_major.get(), \ i_avg_majorTick.get(), \ output_filename.get(),\ self.location,\ mname.get(), temp.get(), bwidth.get(), ie.get(),\ normavg_saveCheck_value.get(),\ specificFiles_status,\ allFiles_status),\ ) # Save checkbutton for normline and avgspec: normavg_saveCheck_value = BooleanVar() normavg_saveCheck_value.set(True) normavg_saveCheck = ttk.Checkbutton(self, text="Save", variable=normavg_saveCheck_value) # Spectrum Analyzer and power Analyzer Buttons: sa_button = ttk.Button(self, text="SA", \ command = lambda: FELion_Sa(self.fname, self.location)) power_button = ttk.Button(self, text = "Power", \ command = lambda: FELion_Power(self.fname, self.location)) # Placing SA and power buttons: norm_diff = 0.12 norm_smalldiff = 0.06 n_x1 = 0.1 n_x2 = n_x1 + norm_diff n_x3 = n_x2 + norm_diff + 0.05 n_x4 = n_x3 + norm_diff n_x5 = n_x4 + norm_smalldiff n_x6 = n_x5 + norm_diff n_y1 = 0.1 ynorm_diff = 0.1 n_y2 = n_y1 + ynorm_diff n_y3 = n_y2 + ynorm_diff + 0.05 n_y4 = n_y3 + ynorm_diff n_y5 = n_y4 + ynorm_diff n_y6 = n_y5 + ynorm_diff #location_label.place(relx = n_x1, rely =n_y1, width = width, height = height) browse_loc.place(relx=n_x1, rely=n_y1, width=width, height=height) fname_label.place(relx=n_x1, rely=n_y2, width=width, height=height) molecule_name_label.place(relx=n_x1, rely=n_y3, width=width, height=height) temp_label.place(relx=n_x1, rely=n_y4, width=width, height=height) bwidth_label.place(relx=n_x1, rely=n_y5, width=width, height=height) ion_enrg_label.place(relx=n_x1, rely=n_y6, width=width, height=height) #location_entry.place(relx = n_x2, rely = n_y1, relwidth = 0.5, height = height) current_location.place(relx=n_x2, rely=n_y1, relwidth=0.5, height=height) #fname_input.place(relx = n_x2, rely = n_y2, width = width, height = height) filename_label.place(relx=n_x2, rely=n_y2, width=width, height=height) molecule_name.place(relx=n_x2, rely=n_y3, width=width, height=height) temperature.place(relx=n_x2, rely=n_y4, width=width, height=height) bo_Width.place(relx=n_x2, rely=n_y5, width=width, height=height) ion_enrg.place(relx=n_x2, rely=n_y6, width=width, height=height) a_y3 = n_y2 + ynorm_diff a_y4 = a_y3 + ynorm_diff a_y5 = a_y4 + ynorm_diff a_y6 = a_y5 + ynorm_diff a_y7 = a_y6 + ynorm_diff avg_label.place(relx=n_x3, rely=n_y2, relwidth=0.2, height=40) avg_title.place(relx=n_x3, rely=a_y3, width=width, height=height) avg_ts_ls.place(relx=n_x3, rely=a_y4, width=width, height=height) avg_xaxis_count.place(relx=n_x3, rely=a_y5, width=width, height=height) avg_majorTick.place(relx=n_x3, rely=a_y6, width=width, height=height) avg_title_Entry.place(relx=n_x4, rely=a_y3, width=width, height=height) avg_ts_Entry.place(relx=n_x4, rely=a_y4, width=smallwidth, height=height) avg_lgs_Entry.place(relx=n_x5, rely=a_y4, width=smallwidth, height=height) avg_minor_Entry.place(relx=n_x4, rely=a_y5, width=smallwidth, height=height) avg_major_Entry.place(relx=n_x5, rely=a_y5, width=smallwidth, height=height) avg_majorTick_Entry.place(relx=n_x4, rely=a_y6, width=width, height=height) avg_outputFilename.place(relx=n_x3, rely=a_y7, width=width, height=height) avg_outputFilename_entry.place(relx=n_x4, rely=a_y7, width=width, height=height) normavg_saveCheck.place(relx=n_x6, rely=a_y3, width=width, height=height) norm_show.place(relx=n_x6 + 0.15, rely=a_y3, width=width, height=height) normallCheck.place(relx=n_x6, rely=a_y4, width=width + 50, height=height) normline_button.place(relx=n_x6, rely=a_y5, width=width, height=height) sa_button.place(relx=n_x6, rely=a_y6, width=width, height=height) power_button.place(relx=n_x6 + 0.15, rely=a_y6, width=width, height=height) avg_button.place(relx=n_x6, rely=a_y7, width=width, height=height)
from tkinter import * from tkinter import ttk # this is the main root or main window root = Tk() root.geometry("600x400") # checkbutton work the same as button. we can enable, disable, put pictures etc. checkbutton = ttk.Checkbutton(root, text='Coffee') ''' checkbutton1 = ttk.Checkbutton(root, text = 'Rice') checkbutton2 = ttk.Checkbutton(root, text = 'Tomatoes') checkbutton3 = ttk.Checkbutton(root, text = 'Banana') ''' checkbutton.pack() ''' checkbutton1.pack() checkbutton2.pack() checkbutton3.pack() ''' # this to at image to the button and display it to the left off the button. # NB: LEFT is in upper case logo = PhotoImage(file='G:\\All programing\\Python\\python_logo.gif') checkbutton.config(image=logo, compound=LEFT) # this to reduce the size of the image in both direction. # 5 pixels in X and 5 pixels in Y direction. small_logo = logo.subsample(3, 3) checkbutton.config(ima=small_logo) # let configure the checkbutton to do something.
def __init__(self, parent, controller): Frame.__init__(self, parent, bg="sea green") label = Label(self, text="Mass Spectrum", \ font=LARGE_FONT, bg="sea green", bd = 1, relief = SOLID) label.place(relx=0, rely=0, relwidth=1) button1 = ttk.Button(self, text="Back to Home", command=lambda: controller.show_frame(StartPage)) button1.place(relx=x1, rely=y, width=width, height=height) button2 = ttk.Button(self, text="Norm and Avg", command=lambda: controller.show_frame(Normline)) button2.place(relx=x2, rely=y, width=width, height=height) button3 = ttk.Button(self, text="Powerfile", command=lambda: controller.show_frame(Powerfile)) button3.place(relx=x3, rely=y, width=width, height=height) # Opening a Directory: self.location = "/" self.fname = "" def open_dir(self): root = Tk() root.withdraw() root.filename = filedialog.askopenfilename( initialdir=self.location, title="Select file", filetypes=(("Mass files", "*.mass"), ("all files", "*.*"))) filename = root.filename filename = filename.split("/") self.fname = filename[-1] del filename[-1] self.location = "/".join(filename) root.destroy() current_location.config(text=self.location) filename_label.config(text=self.fname) return # Labels and buttons: browse_loc = ttk.Button(self, text="Browse File") browse_loc.config(command=lambda: open_dir(self)) # Printing current location: current_location = Label(self) filename_label = Label(self) massSpec_label = Label(self, text="Mass_file: ", font=("Times", 10, "bold")) # the compund details: molecule_name_label = Label(self, text="Molecule", font=("Times", 10, "bold")) temp_label = Label(self, text="TEMP(K)", font=("Times", 10, "bold")) bwidth_label = Label(self, text="B0 Width(ms)", font=("Times", 10, "bold")) ion_enrg_label = Label(self, text="IE(eV)", font=("Times", 10, "bold")) mname = StringVar() temp = StringVar() bwidth = StringVar() ie = StringVar() mname.set("Molecule") temp.set("-") bwidth.set("-") ie.set("-") molecule_name = Entry(self, bg="white", bd=5, textvariable=mname, justify=LEFT, font=("Times", 12, "italic")) temperature = Entry(self, bg="white", bd=5, textvariable=temp, justify=LEFT, font=("Times", 12, "italic")) bo_Width = Entry(self, bg="white", bd=5, textvariable=bwidth, justify=LEFT, font=("Times", 12, "italic")) ion_enrg = Entry(self, bg="white", bd=5, textvariable=ie, justify=LEFT, font=("Times", 12, "italic")) mass_button = ttk.Button(self, text="MassSpec", \ command = lambda: massSpec(\ self.fname, mname.get(), temp.get(), bwidth.get(), ie.get(),\ mass_xmin.get(), mass_xmax.get(),\ self.location,\ m_figwidth.get(), m_figheight.get(),\ combine_entry_values.get(),\ output_filename.get(),\ mass_method_value.get(),\ mass_saveCheck_value.get() ) ) # Save checkbutton: mass_saveCheck_value = BooleanVar() mass_saveCheck_value.set(True) mass_saveCheck = ttk.Checkbutton(self, text="Save", variable=mass_saveCheck_value) # Mass Spec labels: mass_range_label = Label(self, text="Range(u):", font=("Times", 10, "bold")) mass_xmin = IntVar() mass_xmax = IntVar() mass_xmin.set(0) mass_xmax.set(80) mass_xmin_Entry = Entry(self, bg = "white", bd = 5, \ textvariable=mass_xmin, justify = LEFT, font=("Times", 10, "bold")) mass_xmax_Entry = Entry(self, bg = "white", bd = 5, \ textvariable=mass_xmax, justify = LEFT, font=("Times", 10, "bold")) mass_figsize = Label(self, text="FigSize:", font=("Times", 10, "bold")) m_figwidth = IntVar() m_figheight = IntVar() m_figwidth.set(7) m_figheight.set(5) mass_figWidth = Entry(self, bg="white", bd=5, textvariable=m_figwidth, justify=LEFT, font=("Times", 10, "bold")) mass_figHeight = Entry(self, bg="white", bd=5, textvariable=m_figheight, justify=LEFT, font=("Times", 10, "bold")) #Combine Mass spec: def combine_func(self, combine): if not combine: display_label.config(text="Single mode active:") if combine: display_label.config(text="Combine mode active:") display_label = Label(self, font=("Times", 12, "italic"), bg="sea green") mass_method_value = BooleanVar() single_mass = ttk.Radiobutton(self, text = "Single: ", \ variable = mass_method_value, value = False, \ command = lambda: combine_func(self, mass_method_value.get())) combine_mass = ttk.Radiobutton(self, text = "Combine: ", \ variable = mass_method_value, value = True, \ command = lambda: combine_func(self, mass_method_value.get())) combine_entry_values = StringVar() combine_entry_values.set( "Combine: Enter just files nos. (if same data) comma separated") combine_entry = Entry(self, bg = "white", bd = 5,\ textvariable=combine_entry_values, justify = LEFT,\ font=("Times", 12, "italic")) # avg spectrum output filename: avg_outputFilename = Label(self, \ text = "Output filename\n(Combine mode)", font=("Times", 10, "bold")) output_filename = StringVar() output_filename.set("Average") avg_outputFilename_entry = Entry(self, bg = "white", bd = 5, \ textvariable=output_filename, justify = LEFT, font=("Times", 12, "italic")) mass_diff = 0.12 mass_smalldiff = 0.06 m_x1 = 0.1 m_x2 = m_x1 + mass_diff m_x3 = m_x2 + mass_diff + 0.05 m_x4 = m_x3 + mass_diff m_x5 = m_x4 + mass_smalldiff m_x6 = m_x5 + mass_diff m_x7 = m_x6 + mass_diff m_y1 = 0.1 ymass_diff = 0.1 m_y2 = m_y1 + ymass_diff m_y3 = m_y2 + ymass_diff + 0.05 m_y4 = m_y3 + ymass_diff m_y5 = m_y4 + ymass_diff m_y6 = m_y5 + ymass_diff browse_loc.place(relx=m_x1, rely=m_y1, width=width, height=height) massSpec_label.place(relx=m_x1, rely=m_y2, width=width, height=height) molecule_name_label.place(relx=m_x1, rely=m_y3, width=width, height=height) temp_label.place(relx=m_x1, rely=m_y4, width=width, height=height) bwidth_label.place(relx=m_x1, rely=m_y5, width=width, height=height) ion_enrg_label.place(relx=m_x1, rely=m_y6, width=width, height=height) current_location.place(relx=m_x2, rely=m_y1, relwidth=0.5, height=height) filename_label.place(relx=m_x2, rely=m_y2, width=width, height=height) molecule_name.place(relx=m_x2, rely=m_y3, width=width, height=height) temperature.place(relx=m_x2, rely=m_y4, width=width, height=height) bo_Width.place(relx=m_x2, rely=m_y5, width=width, height=height) ion_enrg.place(relx=m_x2, rely=m_y6, width=width, height=height) mass_range_label.place(relx=m_x3, rely=m_y3, width=width, height=height) mass_xmin_Entry.place(relx=m_x4, rely=m_y3, width=smallwidth, height=height) mass_xmax_Entry.place(relx=m_x5, rely=m_y3, width=smallwidth, height=height) mass_figsize.place(relx=m_x3, rely=m_y4, width=width, height=height) mass_figWidth.place(relx=m_x4, rely=m_y4, width=smallwidth, height=height) mass_figHeight.place(relx=m_x5, rely=m_y4, width=smallwidth, height=height) single_mass.place(relx=m_x3, rely=m_y5, width=width, height=height) combine_mass.place(relx=m_x4, rely=m_y5, width=width, height=height) display_label.place(relx=m_x3, rely=m_y6, relwidth=0.25, height=height) combine_entry.place(relx=m_x6, rely=m_y3, relwidth=0.25, height=height) mass_saveCheck.place(relx=m_x6, rely=m_y4, width=width, height=height) mass_button.place(relx=m_x7, rely=m_y4, width=width, height=height) avg_outputFilename.place(relx=m_x6, rely=m_y6, width=width + 30, height=height) avg_outputFilename_entry.place(relx=m_x7 + 0.05, rely=m_y6, width=width, height=height)
radiobuttn1 = ttk.Radiobutton(label, text='INDIAN', value='indian', variable=nation) radiobuttn1.grid(row=6, column=0) radiobuttn2 = ttk.Radiobutton(label, text='non indian', value='non indian', variable=nation) radiobuttn2.grid(row=6, column=1) #checkbutton checkbtnv = tk.IntVar() checkbtn = ttk.Checkbutton(label, text='i declare that information are correct', variable=checkbtnv) checkbtn.grid(row=7, columnspan=3) optionv = tk.StringVar() optionc = ttk.Combobox(label, width=14, textvariable=optionv, state='readonly') optionc['values'] = ('new user', 'regular user', 'older user') optionc.current(0) optionc.grid(row=5, column=1, pady=12, padx=12) #newpage new = ttk.Label(page2, text="Enter your help :") new.grid(row=0, column=1, padx=8, pady=4) new = ttk.Label(page3, text="Enter your about :") new.grid(row=0, column=1, padx=8, pady=4) new = ttk.Label(page4, text="Enter your info :")
EmailEntry.grid(row=4, column=1, columnspan=2, pady=8, padx=5, sticky="w") CommentEntry = Text(width=30, height=10) CommentEntry.grid(row=6, column=1, columnspan=2, pady=8, padx=5, sticky="w") #Adding Radiobutton and Checkbutton gender = StringVar() cbVar = StringVar() cbVar1 = StringVar() gender.set("Male") ttk.Radiobutton(love, text="Male", variable=gender, value="Male").grid(row=3, column=1, sticky="w") ttk.Radiobutton(love, text="Female", variable=gender, value="female").grid(row=3, column=2, sticky="w") ProffesionEntry1 = ttk.Checkbutton(love, text="Web Developer") ProffesionEntry1.grid(row=5, column=1, sticky="w") ProffesionEntry1.config(variable=cbVar, onvalue="Yes Web dev", offvalue="No") ProffesionEntry2 = ttk.Checkbutton(love, text="Graphics designer") ProffesionEntry2.grid(row=5, column=2) ProffesionEntry2.config(variable=cbVar1, onvalue="Yes Graph des.", offvalue="Not at all") #Adding Buttons SubmitButton = ttk.Button(love, text="Submit") SubmitButton.grid(row=7, column=0, sticky="w", ipadx=8, ipady=6) ListButton = ttk.Button(love, text="List Reserv.") ListButton.grid(row=7, column=1, sticky="w", ipadx=8, ipady=6) UpdateButton = ttk.Button(love, text="Update Reserv") UpdateButton.grid(row=7, column=2, sticky="w", ipadx=8, ipady=6)
def __init__(self, parent, controller): freq = dict() freq["weekly"] = tk.IntVar(value=0) freq["monthly"] = tk.IntVar(value=0) freq["check"] = tk.IntVar(value=0) freq["mo"] = tk.IntVar() freq["tu"] = tk.IntVar() freq["we"] = tk.IntVar() freq["th"] = tk.IntVar() freq["fr"] = tk.IntVar() freq["sa"] = tk.IntVar() freq["su"] = tk.IntVar() freq["beg"] = tk.IntVar() freq["mid"] = tk.IntVar() freq["end"] = tk.IntVar() freq["monthday"] = tk.IntVar() freq["occ_on"] = tk.IntVar() freq["occ_after"] = tk.IntVar() frequence = tk.StringVar(value="Frequency") tk.Frame.__init__(self, parent) label = ttk.Label(self, text="Frequency generator", font=LARGE_FONT) label.grid(row=0, column=0, ipady=10) button = ttk.Button(self, text="Generate Frequency", command=lambda: freqGen(freq, frequence)) button.grid(row=13, column=0) entry = ttk.Entry(self, state="readonly", textvariable=frequence) entry.grid(row=13, column=1) label_week = ttk.Checkbutton(self, text="Weekly frequency", variable=freq["weekly"]) label_week.grid(row=2, column=0, sticky="w", padx=10) checkbox1 = ttk.Checkbutton(self, text="Every Day", variable=freq["check"], command=lambda: checkAll(freq)) checkbox1.grid(row=3, column=0, sticky="w", padx=10) checkbox1 = ttk.Checkbutton(self, text="Monday", variable=freq["mo"]) checkbox1.grid(row=4, column=0, sticky="w", padx=10) checkbox1 = ttk.Checkbutton(self, text="Tuesday", variable=freq["tu"]) checkbox1.grid(row=5, column=0, sticky="w", padx=10) checkbox1 = ttk.Checkbutton(self, text="Wednesday", variable=freq["we"]) checkbox1.grid(row=6, column=0, sticky="w", padx=10) checkbox1 = ttk.Checkbutton(self, text="Thursday", variable=freq["th"]) checkbox1.grid(row=7, column=0, sticky="w", padx=10) checkbox1 = ttk.Checkbutton(self, text="Friday", variable=freq["fr"]) checkbox1.grid(row=8, column=0, sticky="w", padx=10) checkbox1 = ttk.Checkbutton(self, text="Saturday", variable=freq["sa"]) checkbox1.grid(row=9, column=0, sticky="w", padx=10) checkbox1 = ttk.Checkbutton(self, text="Sunday", variable=freq["su"]) checkbox1.grid(row=10, column=0, sticky="w", padx=10) label_month = ttk.Checkbutton(self, text="Monthly frequency", variable=freq["monthly"]) label_month.grid(row=2, column=1, columnspan=2, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="January", variable=freq["Jan"]) # checkbox2.grid(row=3, column=1, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="February", variable=freq["Feb"]) # checkbox2.grid(row=4, column=1, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="March", variable=freq["Mar"]) # checkbox2.grid(row=5, column=1, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="April", variable=freq["Apr"]) # checkbox2.grid(row=6, column=1, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="May", variable=freq["May"]) # checkbox2.grid(row=7, column=1, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="June", variable=freq["Jun"]) # checkbox2.grid(row=8, column=1, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="July", variable=freq["Jul"]) # checkbox2.grid(row=3, column=2, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="August", variable=freq["Aug"]) # checkbox2.grid(row=4, column=2, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="September", variable=freq["Sep"]) # checkbox2.grid(row=5, column=2, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="October", variable=freq["Oct"]) # checkbox2.grid(row=6, column=2, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="November", variable=freq["Nov"]) # checkbox2.grid(row=7, column=2, sticky="w") # checkbox2 = ttk.Checkbutton(self, text="December", variable=freq["Dec"]) # checkbox2.grid(row=8, column=2, sticky="w") label_onday = ttk.Label(self, text="Day of the month:") label_onday.grid(row=3, column=1, sticky="w") entry_day = ttk.Entry(self, textvariable=freq["monthday"]) entry_day.grid(row=3, column=2) checkbox3 = ttk.Checkbutton(self, text="On Date", variable=freq["occ_on"]) checkbox3.grid(row=5, column=1, sticky="w") checkbox4 = ttk.Checkbutton(self, text="Afte Date", variable=freq["occ_after"]) checkbox4.grid(row=6, column=1, sticky="w") checkbox5 = ttk.Checkbutton(self, text="Beginning of period", variable=freq["beg"]) checkbox5.grid(row=7, column=1, sticky="w") checkbox6 = ttk.Checkbutton(self, text="Middle of period", variable=freq["mid"]) checkbox6.grid(row=8, column=1, sticky="w") checkbox7 = ttk.Checkbutton(self, text="End of period", variable=freq["end"]) checkbox7.grid(row=9, column=1, sticky="w")
winin.quit() winin.destroy() winin = tk.Tk() winin.title('Input') Label(winin, text='Start').grid(row=0) Label(winin, text='End').grid(row=1) d1 = Entry(winin) e1 = Entry(winin) d1.grid(row=0, column=1) e1.grid(row=1, column=1) step = IntVar() w = ttk.Checkbutton(winin, text='Show Steps', onvalue=1, offvalue=0, variable=step) w.grid(row=4) button = tk.Button(winin, text='Test', width=20, bd=4, justify=CENTER, command=OnSubmit) button.grid(row=5, column=1) winin.mainloop() openSet.append(start) start.draw(pink, 0) end.draw(pink, 0) # function to convert the mouse press to an obstruction by altering obs value
def create_scissor_window(): global scissor_window_exist, scissor_mode, scissor_window if scissor_window_exist == False: scissor_window_exist = True #window scissor_window = tk.Toplevel(root) scissor_window.protocol('WM_DELETE_WINDOW', close_scissor_window) scissor_window.title('Scissor Config') scissor_window.grid_columnconfigure(0, weight=1) scissor_window.grid_rowconfigure(0, weight=1) #frame scissor_frame = ttk.Frame(scissor_window, padding='5', borderwidth='8') scissor_frame.grid(column=0, row=0, sticky=(tk.N, tk.W, tk.E, tk.S)) #contents scissor_range_label = ttk.Label(scissor_frame, text='Scissor Range') work_mode_label = ttk.Label(scissor_frame, text='Work Mode') debug_mode_label = ttk.Label(scissor_frame, text='Debug Mode') scissor_debug_label = ttk.Label(scissor_frame, text='<debug info>') scissor_debug2_label = ttk.Label(scissor_frame, text='<debug info>') #TODO show separators separator1 = ttk.Separator(scissor_frame, orient=tk.HORIZONTAL) separator2 = ttk.Separator(scissor_frame, orient=tk.HORIZONTAL) brush_selection = tk.BooleanVar() scissor_range = ttk.Checkbutton(scissor_frame, text='Brush Selection', variable=brush_selection, onvalue=True, offvalue=False) scissor_mode = tk.StringVar() scissor_mode.set('image_with_contour') image_only = ttk.Radiobutton(scissor_frame, text='Image Only', variable=scissor_mode, value='image_only') image_with_contour = ttk.Radiobutton(scissor_frame, text='Image with Contour', variable=scissor_mode, value='image_with_contour') pixel_nodes = ttk.Radiobutton(scissor_frame, text='Pixel Nodes', variable=scissor_mode, value='pixel_nodes') cost_graph = ttk.Radiobutton(scissor_frame, text='Cost Graph', variable=scissor_mode, value='cost_graph') path_tree = ttk.Radiobutton(scissor_frame, text='Path Tree', variable=scissor_mode, value='path_tree') minimum_path = ttk.Radiobutton(scissor_frame, text='Minimum Path', variable=scissor_mode, value='minimum_path') gradient_map = ttk.Radiobutton(scissor_frame, text='Gradient Map', variable=scissor_mode, value='gradient_map') if brush_implemented == True: scissor_range_label.grid(column=0, row=0, sticky=(tk.W, tk.N)) scissor_range.grid(column=0, row=1, sticky=(tk.W, tk.N)) separator1.grid(column=0, row=4, sticky=tk.W) work_mode_label.grid(column=0, row=5, sticky=(tk.W, tk.N)) image_only.grid(column=0, row=6, sticky=tk.W) image_with_contour.grid(column=1, row=6, sticky=tk.W) debug_mode_label.grid(column=0, row=7, sticky=(tk.W, tk.N)) pixel_nodes.grid(column=0, row=8, sticky=tk.W) cost_graph.grid(column=1, row=8, sticky=tk.W) path_tree.grid(column=0, row=9, sticky=tk.W) minimum_path.grid(column=1, row=9, sticky=tk.W) #gradient_map.grid(column = 0, row = 10, sticky = tk.W) separator2.grid(column=0, row=13, sticky=tk.W) if debug_setting == True: scissor_debug_label.grid(column=0, row=14, sticky=(tk.W, tk.N)) scissor_debug2_label.grid(column=0, row=15, sticky=(tk.W, tk.N)) #binding scissor_window.bind( '<1>', lambda e: scissor_debug_label.configure(text=scissor_mode.get())) scissor_window.bind( '<1>', lambda e: scissor_debug2_label.configure(text=brush_selection.get( ))) image_only.bind('<1>', show_image_only) image_with_contour.bind('<1>', show_image_with_contour) pixel_nodes.bind('<1>', show_pixel_nodes) cost_graph.bind('<1>', show_cost_graph) path_tree.bind('<1>', show_path_tree) minimum_path.bind('<1>', show_minimum_path)
b=[] b.append(ttk.Button(raiz, width=ancho-1, text="Registrar Usuario", command = ru))#0 b.append(ttk.Button(raiz, width=ancho-1, text="Eliminar Usuario", command = eu))#1 b.append(ttk.Button(raiz, width=ancho-10, text="Ver mas", command = mas))#2 b.append(ttk.Button(raiz, width=ancho-10, text="Agregar", command = ai))#3 b.append(ttk.Button(raiz, width=ancho-10, text="Eliminar", command = bi))#4 b.append(ttk.Button(raiz, width=ancho-10, text="Modificar", command = mi))#5 b.append(ttk.Button(raiz, width=ancho-10, text="Buscar", command = ci))#6 b.append(ttk.Button(raiz, width=ancho-10, text="Agregar", command = ap))#7 b.append(ttk.Button(raiz, width=ancho-10, text="Eliminar", command = bp))#8 b.append(ttk.Button(raiz, width=ancho-10, text="Modificar", command = mp))#9 b.append(ttk.Button(raiz, width=ancho-10, text="Buscar", command = cp))#10 b.append(ttk.Button(raiz, width=ancho-10, text="Actualizar", command = di))#11 b.append(ttk.Button(raiz, width=ancho-10, text="Actualizar", command = dp))#12 b.append(ttk.Checkbutton(raiz, text="Administrador", variable=sera))#-1 entrada=[] entrada.append(ttk.Entry(raiz, width=ancho-8, font=("Verdana",12)))#0 entrada.append(ttk.Entry(raiz, width=ancho-8, font=("Verdana",12)))#1 entrada.append(ttk.Entry(raiz, width=ancho-10, font=("Verdana",12)))#2 entrada.append(ttk.Entry(raiz, width=ancho-9))#3 entrada.append(ttk.Entry(raiz, width=ancho-9))#4 entrada.append(ttk.Entry(raiz, width=ancho-9))#5 entrada.append(ttk.Entry(raiz, width=ancho-9))#6 entrada.append(ttk.Entry(raiz, width=ancho-9))#7 entrada.append(ttk.Entry(raiz, width=ancho-9))#8 entrada.append(ttk.Entry(raiz, width=ancho-9))#9 entrada.append(ttk.Entry(raiz, width=ancho-9))#10 entrada.append(ttk.Entry(raiz, width=ancho-9))#11 entrada.append(ttk.Entry(raiz, width=ancho-9))#12
def __init__(self, parent): tk.Frame.__init__(self, parent) frame = tk.Frame(self) canvas = tk.Canvas(frame) scrollbar = ttk.Scrollbar(frame, orient="vertical", command=canvas.yview) scrollable_frame = ttk.Frame(canvas) scrollable_frame.bind( "<Configure>", lambda e: canvas.configure(scrollregion=canvas.bbox("all"))) canvas.create_window((0, 0), window=scrollable_frame, anchor="nw") canvas.configure(yscrollcommand=scrollbar.set) global anns_2, anns_1, first_doctor, second_doctor self.first_selected = [] self.second_selected = [] row_count = 0 label_first_doctor = ttk.Label( scrollable_frame, text=f'Select from Dr.{first_doctor} Annotation', font=LARGE_FONT) label_first_doctor.grid(column=0, row=row_count, padx=10, sticky=tk.NW) var1 = tk.IntVar() var1.set(0) selectButton = tk.Checkbutton(scrollable_frame, text="All", command=self.select_all_first, variable=var1) selectButton.grid(column=1, row=row_count, padx=1, sticky=tk.NW) #print("first label @",row_count) for i, anns in enumerate(anns_1): #print(anns) #print("("+anns[3]+")"+anns[6]+" "+anns[5]) if anns[0] < 8: var = tk.IntVar() self.first_selected.append([i, var]) row_count += 1 ttk.Checkbutton(scrollable_frame, text="(" + str(anns[3]) + ")" + anns[4] + " " + anns[5], variable=var).grid(column=0, row=row_count, sticky=tk.NSEW) #print("check box added at", row_count,"("+str(anns[3])+")"+anns[4]+" "+anns[5]) row_count += 1 label_second_doctor = ttk.Label( scrollable_frame, text=f'Select from Dr.{second_doctor} Annotation', font=LARGE_FONT) label_second_doctor.grid(column=0, row=row_count, padx=10, sticky=tk.NW) var2 = tk.IntVar() var2.set(0) selectButton = tk.Checkbutton(scrollable_frame, text="All", command=self.select_all_second, variable=var2) selectButton.grid(column=1, row=row_count, padx=1, sticky=tk.NW) #print("second label @",row_count) for i, anns in enumerate(anns_2): #print("("+anns[3]+")"+anns[6]+" "+anns[5]) if anns[0] < 8: row_count += 1 var = tk.IntVar() self.second_selected.append([i, var]) ttk.Checkbutton(scrollable_frame, text="(" + str(anns[3]) + ")" + anns[4] + " " + anns[5], variable=var).grid(column=0, row=row_count, sticky=tk.NSEW) row_count += 2 self.needs_checking = tk.IntVar() ttk.Checkbutton(scrollable_frame, text="Needs Checking", variable=self.needs_checking).grid(column=0, row=row_count, sticky=tk.NSEW) row_count += 1 button4 = ttk.Button(scrollable_frame, text='Save', command=lambda: self.save_annotation(parent)) button4.grid(column=0, row=row_count, pady=5, padx=10, sticky=tk.NW) frame.pack(side=tk.RIGHT, fill=tk.BOTH, expand=True, pady=20) canvas.pack(side="left", fill="both", expand=True) scrollbar.pack(side="right", fill="y")
def display(self): """ Generate Tkinter GUI """ ## Meta self.root.title(self.name) self.root.wm_iconbitmap(self.icon_image) self.root.resizable(False, False) # Menu bar menubar = Menu(self.root) self.root.config(menu=menubar) submenu = Menu(menubar) menubar.add_cascade(label='Help', menu=submenu) submenu.add_command(label='About', command=self.about) submenu.add_command(label='Exit', command=self.on_closing) # Status bar self.statusbar = ttk.Label(self.root, text='Welcome to Jazzed', relief=SUNKEN, font='Times 10 italic') self.statusbar.pack(side=BOTTOM, fill=X) ## TopFrame topframe = Frame(self.root) topframe.pack(padx=10, pady=15) ## List of playlists self.playListFrame = PlaylistGUI(topframe, self, width=300, height=500, borderwidth=3, relief=RAISED, background="PaleTurquoise1") self.playListFrame.grid(row=0, column=0) ## Playlist/Queue tabs self.tabs = ttk.Notebook(topframe) self.pltab = PlaylistTab(self.tabs, self) self.queuetab = SongQueueTab(self.tabs, self) ## Pack tabs self.tabs.add(self.pltab, text="Playlist") self.tabs.add(self.queuetab, text="Song Queue") self.tabs.select(self.queuetab) self.tabs.grid(row=0, column=1, padx=20) ## BottomFrame bottomframe = Frame(self.root) bottomframe.pack(padx=10, pady=15) ## Playbackframe playbackframe = Frame(bottomframe) playbackframe.pack() # Rewind button self.rewindImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\rewind.png').convert( 'RGBA').resize((20, 20))) self.rewind_btn = ttk.Button(playbackframe, image=self.rewindImage, command=self.rewind_audio) self.rewind_btn.image = self.rewindImage self.rewind_btn.grid(row=0, column=0, padx=20) # Back button self.backImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\back.png').convert( 'RGBA').resize((30, 30))) self.back_btn = ttk.Button(playbackframe, image=self.backImage, command=self.play_again) self.back_btn.image = self.backImage self.back_btn.grid(row=0, column=1, padx=10) # Play/Pause button self.playImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\play.png').convert( 'RGBA').resize((30, 30))) self.pauseImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\pause.png').convert( 'RGBA').resize((30, 30))) self.play_btn = ttk.Button(playbackframe, image=self.playImage, command=self.toggle_play_pause) self.play_btn.image = self.playImage self.play_btn.grid(row=0, column=2) # Next button self.nextImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\next.png').convert( 'RGBA').resize((30, 30))) self.next_btn = ttk.Button(playbackframe, image=self.nextImage, command=self.next_song) self.next_btn.image = self.nextImage self.next_btn.grid(row=0, column=3, padx=10) # Forward button self.forwardImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\forward.png').convert( 'RGBA').resize((20, 20))) self.forward_btn = ttk.Button(playbackframe, image=self.forwardImage, command=self.forward_audio) self.forward_btn.image = self.forwardImage self.forward_btn.grid(row=0, column=4, padx=20) ## Progressframe progressframe = Frame(bottomframe) progressframe.pack() # Time labels self.total_length = ttk.Label(progressframe, text=r"__:__") self.total_length.grid(row=0, column=2, padx=5, pady=10) self.current_time = ttk.Label(progressframe, text=r"00:00") self.current_time.grid(row=0, column=0, padx=5, pady=10) # Progress Bar self.progress_bar = ttk.Progressbar(progressframe, variable=self.get_time(), length=500, mode='determinate') self.progress_bar.grid(row=0, column=1, pady=10) ## Volume frame volumeframe = Frame(bottomframe) volumeframe.pack(pady=20) # Volume button self.volumeImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\volume.png').convert( 'RGBA').resize((20, 20))) self.muteImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\mute.png').convert( 'RGBA').resize((20, 20))) self.volume_btn = ttk.Button(volumeframe, image=self.volumeImage, command=self.mute_audio) self.volume_btn.image = self.volumeImage self.volume_btn.grid(row=0, column=0, padx=5) # Volume control self.volume = Scale(volumeframe, from_=0, to=100, orient=HORIZONTAL, command=self.set_volume) self.volume.set(100) self.volume.grid(row=0, column=1) # Repeat button self.repeatImage = ImageTk.PhotoImage( Image.open(r'jazzed\frontend\static\repeat.png').convert( 'RGBA').resize((20, 20))) self.repeatVar = BooleanVar() self.repeat_btn = ttk.Checkbutton(volumeframe, image=self.repeatImage, variable=self.repeatVar, onvalue=True, offvalue=False) self.repeat_btn.image = self.repeatImage self.repeat_btn.grid(row=0, column=2, padx=5)
def __init__(self, parent=None, *args, **kwargs): # init GUI Grid.columnconfigure(parent, 1, weight=1) Grid.rowconfigure(parent, 0, weight=1) self.tab = Autoresized_Notebook(parent) self.auto_tab = ttk.Frame(self.tab) self.manually_tab = ttk.Frame(self.tab) self.setting_tab = ttk.Frame(self.tab) self.tab.add(self.manually_tab, text=u'手动') self.tab.add(self.auto_tab, text=u'自动') self.tab.add(self.setting_tab, text=u'设置') self.tab.grid(row=0, column=0, sticky='NSWE') # tab 1 # widget to display the login method. QR code or By Dingtalk self.login_method_menu = ttk.Menubutton(self.manually_tab, text=u'选择登陆方式') self.login_method_menu.grid(row=0, column=0, padx=5, pady=5, sticky='NWSE') self.menu = Menu(self.login_method_menu, tearoff=False) self.login_method_menu.config(menu=self.menu) global login_method login_method = StringVar() login_method.set('QR') self.menu.add_radiobutton(label=u"扫码登陆", variabl=login_method, value='QR') self.menu.add_radiobutton(label=u"钉钉授权登陆", variabl=login_method, value='Dingtalk') self.separator_tab1 = ttk.Separator(self.manually_tab, orient=HORIZONTAL) self.separator_tab1.grid(row=1, column=0, sticky='WE', padx=0, pady=0) self.btn_start = ttk.Button(self.manually_tab, text=u"开始学习", command=self.start_click) self.btn_start.grid(row=2, column=0, padx=5, pady=5, sticky='NSE') self.btn_pause = ttk.Button(self.manually_tab, text=u"暂停学习", command=self.pause_click) self.btn_pause.grid(row=3, column=0, padx=5, pady=5, sticky='NSE') self.btn_quit = ttk.Button(self.manually_tab, text=u"退出学习", command=self.quit_click) self.btn_quit.grid(row=4, column=0, padx=5, pady=5, sticky='NSE') # log window self.log_content = Listbox(parent, selectmode=EXTENDED, bg='#FFFFFF') self.log_content.grid(row=0, column=1, padx=5, pady=5, sticky='NSWE') self.vbar = ttk.Scrollbar( parent, orient=VERTICAL, command=self.log_content.yview) self.log_content.configure(yscrollcommand=self.vbar.set) self.vbar.grid(row=0, column=2, sticky='NS') # ######################## setting panel begin ############################################### def validate_time(): try: self.schd_time.set(time.strftime('%H:%M', time.strptime(self.schd_time.get(), '%H:%M'))) return True except ValueError: messagebox.showerror(u'错误', u'时间错误。正确格式例子:23:59') return False return False def restore_input_text(): self.schd_time.set('') return True self.separator_beforestatus = ttk.Separator(self.auto_tab, orient=HORIZONTAL) self.separator_beforestatus.grid(row=3, column=0, sticky='WE', columnspan=2, padx=0, pady=0) self.separator_afterstatus = ttk.Separator(self.auto_tab, orient=HORIZONTAL) self.separator_afterstatus.grid(row=5, column=0, sticky='WE', columnspan=2, padx=0, pady=0) # dingtalk-user self.dingtalk_user_title = ttk.Label(self.auto_tab, text=u'钉钉账号:') self.dingtalk_user_title.grid(row=0, column=0, pady=5, stick='NSE') self.dingtalk_user = StringVar() self.dingtalk_user_input = ttk.Entry(self.auto_tab, textvariable=self.dingtalk_user, width=12) self.dingtalk_user_input.grid(row=0, column=1, pady=5, stick='NSW') # dingtalk passwd self.dingtalk_pwd_title = ttk.Label(self.auto_tab, text=u'钉钉密码:') self.dingtalk_pwd_title.grid(row=1, column=0, pady=5, stick='NSE') self.dingtalk_pwd = StringVar() self.dingtalk_pwd_input = ttk.Entry(self.auto_tab, textvariable=self.dingtalk_pwd, show='*', width=12) self.dingtalk_pwd_input.grid(row=1, column=1, pady=5, stick='NSW') # schedule titie self.schd_title = ttk.Label(self.auto_tab, text=u'学习时钟:') self.schd_title.grid(row=2, column=0, pady=0, stick='NSW') # schedule_time self.schd_time = StringVar() self.schd_time_input = ttk.Entry(self.auto_tab, textvariable=self.schd_time, validate='focusout', validatecommand=validate_time, invalidcommand=restore_input_text, width=5) self.schd_time_input.grid(row=2, column=1, pady=5, stick='NSW') self.auto_status = StringVar() self.auto_status.set(u'状态:停止') self.auto_status_label = ttk.Label(self.auto_tab, textvariable=self.auto_status) self.auto_status_label.grid(row=4, column=0, pady=5, columnspan=2, sticky='NSW') # init monitor task self.__monitor_flag = threading.Event() self.__monitor_flag.set() # submit button self.btn_go = ttk.Button(self.auto_tab, text=u'Go!', command=self.go_click) self.btn_go.grid(row=6, column=1, padx=5, pady=5, sticky='NSE') self.btn_stop = ttk.Button(self.auto_tab, text=u'Stop!', command=self.stop_click) self.btn_stop.grid(row=7, column=1, padx=5, pady=5, sticky='NSE') # ######################## setting panel end ############################################### # ############### proxy settings ############ self.separator_after_proxies = ttk.Separator(self.setting_tab, orient=HORIZONTAL) self.separator_after_proxies.grid(row=5, column=0, sticky='WE', columnspan=2, padx=0, pady=0) # self.separator_before_proxies = ttk.Separator(self.setting_tab, orient=VERTICAL) # self.separator_before_proxies.grid(row=0, column=1, sticky='NS', padx=10, pady=0) self.use_proxy = IntVar() self.use_proxy_checkbox = ttk.Checkbutton(self.setting_tab, variable=self.use_proxy, text='使用代理') self.use_proxy_checkbox.grid(row=0, column=0, pady=5, columnspan=2, stick='NSW') self.http_proxy_title = ttk.Label(self.setting_tab, text=u'Http:') self.http_proxy_title.grid(row=1, column=0, pady=5, stick='NSE') self.http_proxy = StringVar() self.http_proxy_input = ttk.Entry(self.setting_tab, textvariable=self.http_proxy, width=16) self.http_proxy_input.grid(row=1, column=1, pady=5, stick='NSW') # dingtalk passwd self.https_proxy_title = ttk.Label(self.setting_tab, text=u'Https:') self.https_proxy_title.grid(row=2, column=0, pady=5, padx=5, stick='NSE') self.https_proxy = StringVar() self.https_proxy_input = ttk.Entry(self.setting_tab, textvariable=self.https_proxy, width=16) self.https_proxy_input.grid(row=2, column=1, pady=5, stick='NSW') self.mute = IntVar() self.mute_checkbox = ttk.Checkbutton(self.setting_tab, variable=self.mute, text='关闭声音') self.mute_checkbox.grid(row=3, column=0, pady=5, columnspan=2, stick='NSW') self.background_process = IntVar() self.background_process_checkbox = ttk.Checkbutton(self.setting_tab, variable=self.background_process, text='后台运行') self.background_process_checkbox.grid(row=4, column=0, pady=5, columnspan=2, stick='NSW') def proxy_submit(): app.log(u'保存{0}! 使用代理::{config[use_proxy]}. ' '关闭声音:{config[mute]}. ' '后台播放:{config[background_process]}'.format(u'成功' if self.save_settings() else u'失败', config=config)) self.proxy_submit = ttk.Button(self.setting_tab, text=u'提交', command=proxy_submit) self.proxy_submit.grid(row=6, column=0, pady=5, columnspan=2) # load settings global config self.dingtalk_user.set(config['dingtalk']['username']) self.dingtalk_pwd.set(config['dingtalk']['password']) self.schd_time.set(config['schedule']['schedule_time']) if 'use_proxy' in config: self.use_proxy.set(config['use_proxy']) if 'proxies' in config: self.http_proxy.set(config['proxies']['http']) self.https_proxy.set(config['proxies']['https']) if 'mute' in config: self.mute.set(config['mute']) if 'background_process' in config: self.background_process.set(config['background_process'])
def __init__(self): self.raiz = Tk() # --------NORMAL VARIABLES-------------- self.raiz.geometry("660x525") self.raiz.title("!bin - Keeping things simple!") self.raiz.resizable(False, False) self.raiz.iconbitmap(self.resource_path("assets/bin_small_cont.ico")) self.hOffset = 115 self.vOffset = -95 self.dirEntryVar = StringVar() self.manualDir = "" self.checkVal = IntVar() self.checkVal.set(1) self.sizeVar = StringVar() self.sizeVar.set("0.0 MB") self.videoListLen = 0 # ----------INTERFACE INSTANCES---------------- self.frame1 = Frame( self.raiz, width=660, height=620, ) self.container2 = ttk.LabelFrame(self.frame1, width=600, height=300, text="Results") self.frame2 = Frame( self.frame1, width=378, height=242, ) self.container1 = ttk.LabelFrame(self.frame1, width=470, height=140, text="Scan videos") self.sizeLabel = ttk.Label(self.frame1, text="Memory occupied by videos:", font=("Calibri", 10)) self.songDirLabel = ttk.Label(self.frame1, text="Custom 'Songs' folder:", font=("Calibri", 11)) self.sizeLabelDyn = ttk.Label( self.frame1, textvariable=self.sizeVar, font=("Calibri", 11), ) self.authorLabel = ttk.Label(self.frame1, text="Axyss - 2019 ©", font=("Calibri", 11)) self.checkBoxLabel = Label(self.frame1, text="Use default 'Songs' folder", font=("Calibri", 11)) self.checkBox1 = ttk.Checkbutton(self.frame1, takefocus=False, cursor="hand2", variable=self.checkVal, command=lambda: self.check_switch(), onvalue=1, offvalue=0) self.dirEntryWidget = ttk.Entry(self.frame1, width=50, textvariable=self.dirEntryVar, state="disabled") self.browseButton = ttk.Button(self.frame1, text="Browse...", width=13, command=lambda: self.browse_window(), state="disabled") self.progressBar = ttk.Progressbar( self.frame1, orient="horizontal", length=128, mode="determinate", maximum=99999 ) # Here because must be rendered before the findVideosButton self.findVideosButton = ttk.Button(self.frame1, text="Find videos", width=20, command=lambda: self.find_thread()) self.videoList = Listbox( self.frame2, width=72, height=15, borderwidth=0, highlightthickness=1, relief="solid", highlightbackground="#A4A4A4", ) self.yscrollVideo = ttk.Scrollbar(self.frame2, command=self.videoList.yview) self.xscrollVideo = ttk.Scrollbar(self.frame2, command=self.videoList.xview, orient="horizontal") self.videoList.config(yscrollcommand=self.yscrollVideo.set) self.videoList.config(xscrollcommand=self.xscrollVideo.set) self.deleteButton = ttk.Button(self.frame1, text="Delete videos", width=15, command=lambda: self.delete_thread()) # ---------------ICON SET-UP--------------- self.aminoBut = Button(self.frame1) self.aminoIco = PhotoImage( file=self.resource_path("assets/amino_ico.png")) self.aminoBut.config( image=self.aminoIco, border=0, cursor="hand2", relief="sunken", takefocus=False, command=lambda: wopen("https://aminoapps.com/c/osu-amino-2/join/")) self.twitterBut = Button(self.frame1) self.twitterIco = PhotoImage( file=self.resource_path("assets/twitter_ico.png")) self.twitterBut.config( image=self.twitterIco, border=0, cursor="hand2", relief="sunken", takefocus=False, command=lambda: wopen("https://twitter.com/Axyss_")) self.githubBut = Button(self.frame1) self.githubIco = PhotoImage( file=self.resource_path("assets/github_ico.png")) self.githubBut.config( image=self.githubIco, border=0, cursor="hand2", relief="sunken", takefocus=False, command=lambda: wopen("https://github.com/Axyss")) self.binBut = Button(self.frame1) self.binIco = PhotoImage(file=self.resource_path("assets/bin_ico.png")) self.binBut.config(image=self.binIco, border=0, relief="sunken", takefocus=False, command=lambda: self.egg_run())