def build_widgets(self): "Build the various widgets that will be used in the program." # Create processing frame widgets. self.processing_frame = LabelFrame(self, text='Processing Mode:') self.mode_var = StringVar(self, 'encode') self.decode_button = Radiobutton(self.processing_frame, text='Decode Cipher-Text', command=self.handle_radiobuttons, value='decode', variable=self.mode_var) self.encode_button = Radiobutton(self.processing_frame, text='Encode Plain-Text', command=self.handle_radiobuttons, value='encode', variable=self.mode_var) self.freeze_var = BooleanVar(self, False) self.freeze_button = Checkbutton(self.processing_frame, text='Freeze Key & Primer', command=self.handle_checkbutton, offvalue=False, onvalue=True, variable=self.freeze_var) # Create encoding frame widgets. self.encoding_frame = LabelFrame(self, text='Encoding Options:') self.chain_size_label = Label(self.encoding_frame, text='Chain Size:') self.chain_size_entry = Entry(self.encoding_frame) self.plain_text_label = Label(self.encoding_frame, text='Plain-Text:') self.plain_text_entry = Entry(self.encoding_frame) # Create input frame widgets. self.input_frame = LabelFrame(self, text='Input Area:') self.input_text = ScrolledText(self.input_frame, **self.TEXT) # Create output frame widgets. self.output_frame = LabelFrame(self, text='Output Area:') self.output_text = ScrolledText(self.output_frame, **self.TEXT)
def __init__(self, parent, name): LabelFrame.__init__(self, parent, text=name) self.height = 100 self.width = 100 self.amount = IntVar() self.scheduled = IntVar() self.canvas = Canvas(self, bg='#FFF8B8', height=self.height, width=self.width, relief=SUNKEN) self.canvas.pack() self.img = Picture(self.canvas, name, self.height, relief=None, borderwidth=0, highlightthickness=0) x = int((self.width - self.img.width) / 2) y = int((self.height - self.img.height) / 2) self.img.place(x=x, y=y) self.lblA = Label(self.canvas, textvariable=self.amount, bg='#FFF8B8', font=("Verdana", 16)) self.lblS = Label(self.canvas, textvariable=self.scheduled, bg='#FFF8B8', font=("Verdana", 16)) d = 3 y = self.height - d self.lblA.place(x=d, y=y, anchor='sw') self.lblS.place(x=self.width - d, y=y, anchor='se')
def __init__(self, win, tabs): super().__init__(tabs) self.win = win self.tabs = tabs self.tabs.add(self, text="Stats") self.stats: StatsCollection = None self.selection: StatsCollection = None self._body = Frame(self) self._body.grid(row=0, column=0, sticky=EW, padx=PAD_X, pady=PAD_Y) # Load self._load_stats = LoadStatsFrame(self._body, self.set_stats) self._load_stats.grid(row=0, column=0, padx=PAD_X, pady=PAD_Y, sticky=EW) # Summary self._summary = LabelFrame(self._body, text=" Records ") self._summary.grid(row=1, column=0, sticky=EW) self._all_counters = CountersFrame(self._summary, text=" All ") self._all_counters.grid(row=0, column=0, padx=2 * PAD_X, pady=2 * PAD_Y, sticky=EW) self._selection_counters = CountersFrame(self._summary, text=" Selection ") self._selection_counters.grid(column=1, row=0, padx=2 * PAD_X, pady=2 * PAD_Y, sticky=EW) # Filter self._filters = FilterSelectionFrame(self._body, self.get_all, self.get_selection, self.set_selection) self._filters.grid(row=2, column=0, sticky=EW) # Reports self._reports = ReportsFrame(self._body, self.get_selection) self._reports.grid(row=3, column=0, sticky=EW)
def on_create_frame_down_lf(self, frame_name, col, row, colpad, rowpad): self.graph_down = LabelFrame(master=self.master, text=frame_name) self.graph_down.grid(column=col, row=row, padx=colpad, pady=rowpad, sticky='SE')
def add_file_info_box(self, mainframe, name, labeldict, btncallback, fvar): """ Create and add a infobox containing the info about a loaded savegame. """ title = {'source':'Copy face from source file:', 'target':'To target file:'} frame = LabelFrame(mainframe, text=title[name]) frame.pack(anchor=N, fill=X, expand=1, side=TOP, padx=0, pady=0) frame.columnconfigure(1, weight=1) btn = Button(frame, text='Browse', command=btncallback) btn.grid(column=0, row=0, padx=2, pady=2) field = Entry(frame, width=50, textvariable=fvar) field.grid(column=1, row=0, columnspan=2, padx=2, pady=2, sticky=W+E) l = ('name','gender','level','race','location','save number','playing time') for n, (i, j) in enumerate([(x.capitalize()+':', x) for x in l]): Label(frame, text=i, state=DISABLED).grid(column=0, row=n+1, padx=4, pady=3, sticky=E) labeldict[j] = StringVar() Label(frame, textvariable=labeldict[j]).grid(column=1, row=n+1, padx=4, pady=3, sticky=W) self.screenshot[name] = Label(frame) self.screenshot[name].grid(column=2, row=1, rowspan=len(l), padx=4, pady=4)
def settings(): global settings_popup try: settings_popup.destroy() except: pass settings_styles = Style() settings_styles.configure( "SettingsLabelframe.TLabelframe.Label", font=("Verdana", 18, "normal")) settings_styles.configure( "SettingsLabelframe.TLabelframe.Label", foreground=COLORS['TEXTCOLOR']) settings_popup = Toplevel() settings_popup.title("Settings") settings_popup.transient(root) settings_popup.resizable(False, False) other_frame = LabelFrame(settings_popup, text="Settings", style="SettingsLabelframe.TLabelframe") basefreq_lbl = Label(other_frame, text="Octave") basefreq_om = OptionMenu(other_frame, OPTIONS['BASE_FREQ'], BASE_FREQS[-1], *BASE_FREQS) basefreq_lbl.grid(row=0, column=0, padx=5) basefreq_om.grid(row=0, column=1, padx=5) other_frame.pack(padx=15, pady=15, ipadx=5, ipady=5) settings_popup.mainloop()
class MyContainerLabeled(object): def __init__(self, parent, name, del_name, label, x, y, width, height): self.container = LabelFrame(parent, text=label, width=width, height=height) parent.children[name] = parent.children.pop(del_name) self.container.place(x=x, y=y) self.buf_access = self.collect_access() def collect_access(self): result = {} for obj in self.container.children.values(): result[obj] = obj["state"] return result def add_objects(self, objects): self.objects += objects def disable_all(self): for obj in self.objects: obj.object.configure(state="disabled") def enable_all(self): for obj in self.objects: obj.object.configure(state="normal") def restore_state_all(self): for obj in self.objects: obj.object.configure(state=obj.buf_state)
def popup_window(self, text, filename): top = Toplevel() info = LabelFrame(top, text=text) #"Group Information") info_text = Text( info, width=50, height=8, #bg=projectBgColor, #fg=projectFgColor, font=("nimbus mono bold", "11")) def savefunc(): self.writepaste(filename, info_text) def loadfunc(): self.readpaste(filename, info_text) info_save_button = Button(info, text="Save", command=savefunc) info_load_button = Button(info, text="Load", command=loadfunc) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) info_load_button.grid(row=5, column=5, padx=10, pady=5) info_save_button.grid(row=5, column=6, padx=10, pady=5) info_text.grid(row=1, rowspan=3, column=1, columnspan=7, padx=5, pady=5) info.grid(row=7, column=0, columnspan=6, sticky=W, padx=20, pady=10) top.focus_force()
def __init__(self, parent, source): LabelFrame.__init__(self, parent, text="Tasklist") self.parent = parent self.getData = source self.text = Text(self) self.text.pack() self.parent.after(1000, self.update)
def __init__(self, parent, source): LabelFrame.__init__(self, parent, text="Orders") self.parent = parent # self.frame=Frame(self,width=550,height=400) # self.frame.pack(expand=None, fill=Y) self.getData = source self.parent.after(1000, self.update) self.orders = {}
def __init__(self, parent, name, del_name, label, x, y, width, height): self.container = LabelFrame(parent, text=label, width=width, height=height) parent.children[name] = parent.children.pop(del_name) self.container.place(x=x, y=y) self.buf_access = self.collect_access()
def memory_frame(self): self.frame_memory = LabelFrame(self.ventana, width=250, height=220, text="Recent requests", labelanchor='n', relief='ridge') self.frame_memory.place(x=780, y=130 + self.despy)
def __init__(self,parent): LabelFrame.__init__(self,parent,text="Calculate",borderwidth=5) self.startCalculationB = Button(self,text="Start calculation",width=20) self.startCalculationB.grid(row=0,column=0,padx=10,pady=5) self.endCalculationB = Button(self,text="Cancel calculation",width=20) self.endCalculationB.grid(row=1,column=0,padx=10,pady=5) self.calculationPB = Progressbar(self, mode="indeterminate",length=128) self.calculationPB.grid(row=2,column=0,padx=10,pady=5)
def showMainValues(): global tkroot global labels global mframe global values from tkinter import Tk, N, W from tkinter.ttk import LabelFrame, Label # first run, set up the thingy print("Setting up Main Values...") init_parse(getMainValues, _parse_main_values_xml, values) sleep(0.5) print("Setting up Advanced Values...") init_parse(getAdvancedValues, _parse_adv_values_xml, values) print("initializing tkinter interface...") tkroot = Tk() mframe = LabelFrame(tkroot, text="Main Frame") labels = {} for group in values: lframe = LabelFrame(mframe, text=group) labels[group] = OrderedDict() labels[group]['frame'] = lframe for param, pv in values[group].items(): labels[group][param] = {} plabel = Label(lframe, text=param) vlabel = Label(lframe, text=pv) labels[group][param]['plabel'] = plabel labels[group][param]['vlabel'] = vlabel mframe.grid() for i, group in enumerate(labels): for param in labels[group]: if param == 'frame': labels[group][param].grid(column=i, row=0, sticky=N) else: labels[group][param]['plabel'].grid(sticky=W) labels[group][param]['vlabel'].grid(sticky=W) tkroot.grid() print('setting up polling intervals') tkroot.after(500, poll_main_values) tkroot.after(750, poll_adv_values) print('Ready') tkroot.mainloop() print("afterloop")
def _build_state_display(self, position): state_field = LabelFrame(self, text=s.language.cards, relief=RAISED, width=self.master.width - 31) state_slots_per_row = int((self.master.width - 31) / 32) state_slot_height = 24 + ( (int(len(self._current_player.states) / state_slots_per_row) + 1) * 32) if self._current_player.states: for index, state in enumerate(self._current_player.states): if state not in self._main_window.engine.nemKartyaStatusz: if state in self._main_window.engine.eventszotar.keys(): origin = self._main_window.engine.eventszotar prefix = "event" else: origin = self._main_window.engine.kincsszotar prefix = "treasure" icon = f"{prefix}_{self._main_window.engine.eventszotar[state].kep}_i" icon = icon[(icon.find('_') + 1):] button = Button( state_field, image=Gallery.get(icon), command=lambda s=state: origin[s].megjelenik(1)) button.grid(row=int(index / state_slots_per_row), column=index % state_slots_per_row) state_field.config(height=state_slot_height) if state_field.winfo_children(): state_field.grid(row=position, column=0) state_field.grid_propagate(False)
def serverpanel(server): ''' Draws the top panel with the server information ''' serverpanel = LabelFrame(win, text = "Server Details") serverpanel.grid(column = 0, row = 0, padx = 5, pady = 5, sticky = W+E) Label(serverpanel, text = "Server Name: ").grid(column = 0, row = 0, sticky = W) Label(serverpanel, text = "Server Type: ").grid(column = 0, row = 1, sticky = W) Label(serverpanel, text = "Load Balancer Status: ").grid(column = 0, row = 2, sticky = W) Label(serverpanel, textvariable = snv).grid(column = 1, row = 0, sticky = W) Label(serverpanel, textvariable = stv ).grid(column = 1, row = 1, sticky = W) Label(serverpanel, textvariable = lbv).grid(column = 1, row = 2, sticky = W) serverstatus(server)
def __init__(self, master): Frame.__init__(self, master) self._main_window = self.master.master self._land_land_roll = False self._heading = Frame(self) self._inventory_display = Frame(self) self._die_field = Frame(self) self._score_field = LabelFrame(self) self._turn_order = Frame(self) self.die = None if self._main_window.is_game_in_progress.get(): self._load_content()
class StatsTabFrame(Frame): def __init__(self, win, tabs): super().__init__(tabs) self.win = win self.tabs = tabs self.tabs.add(self, text="Stats") self.stats: StatsCollection = None self.selection: StatsCollection = None self._body = Frame(self) self._body.grid(row=0, column=0, sticky=EW, padx=PAD_X, pady=PAD_Y) # Load self._load_stats = LoadStatsFrame(self._body, self.set_stats) self._load_stats.grid(row=0, column=0, padx=PAD_X, pady=PAD_Y, sticky=EW) # Summary self._summary = LabelFrame(self._body, text=" Records ") self._summary.grid(row=1, column=0, sticky=EW) self._all_counters = CountersFrame(self._summary, text=" All ") self._all_counters.grid(row=0, column=0, padx=2 * PAD_X, pady=2 * PAD_Y, sticky=EW) self._selection_counters = CountersFrame(self._summary, text=" Selection ") self._selection_counters.grid(column=1, row=0, padx=2 * PAD_X, pady=2 * PAD_Y, sticky=EW) # Filter self._filters = FilterSelectionFrame(self._body, self.get_all, self.get_selection, self.set_selection) self._filters.grid(row=2, column=0, sticky=EW) # Reports self._reports = ReportsFrame(self._body, self.get_selection) self._reports.grid(row=3, column=0, sticky=EW) def get_all(self) -> StatsCollection: return self.stats def get_selection(self) -> StatsCollection: return self.selection def set_stats(self, stats: StatsCollection): self.stats = stats self._all_counters.set_stats(stats.get_counters()) self._filters.set_countries(stats.unique_countries) self.set_selection(stats) def set_selection(self, stats: StatsCollection): self.selection = stats self._selection_counters.set_stats(stats.get_counters()) self._filters.set_tournaments(stats.unique_tournaments)
def __init__(self, parent, label_text, add_headers, params, category_type, *args, **kw): LabelFrame.__init__(self, parent, text=label_text, *args, **kw) self.parent = parent self.frame_with_boxes = None self.canvas = None self.options = dict() self.nb_entries = 0 self.add_headers = add_headers self.category_objects = dict() self.params = params self.category_type = category_type self.create_widgets()
def buttonpanel(): ''' Draws the panel with the buttons at the bottom ''' butpanel = LabelFrame(win, text = "") butpanel.grid(column = 0, row = 2, padx = 5, pady = 5, sticky = W+E) Button(butpanel, text = "Stop Services", command = onStop).grid(column = 0, row = 0) Button(butpanel, text = "Start Services", command = onStart).grid(column = 1, row = 0) Button(butpanel, text = "Refresh List", command = onStatus).grid(column = 2, row = 0) if server.lbalanced.upper() == "YES": # lbutpanel = LabelFrame(win, text = "") # lbutpanel.grid(column = 0, row = 3, padx = 5, pady = 5, sticky = W+E) Button(butpanel, text = "Stop Load Balancer", command = lbStop).grid(column = 0, row = 1) Button(butpanel, text = "Start Load Balancer", command = lbStart).grid(column = 1, row = 1)
def on_create_labelframe(self, frame_name, col, row, colpad, rowpad, pos): """ Erstellung eines oberen Bezeichner fuer ein Element und Positionierung des Elements in einem Frame :param frame_name: Titel oben auf ein Objekt :param col: Spalten :param row: ZEile :param colpad: Innenabstand in der Spaltenrichtung :param rowpad: Innenabstand in der Zeilenrichtung :param pos: Plazierung in einem Frame ('N':Nord, 'S':Sued, 'W':West, usw.) :return: """ self.lf = LabelFrame(master=self.master, text=frame_name) self.lf.grid(column=col, row=row, padx=colpad, pady=rowpad, sticky=pos)
def body(self, szulo): self._projekt_valaszto = Valaszto("megnevezés", self._projektek(), self) self._projekt_valaszto.set_callback(self._projekt_megjelenit) self._projekt_valaszto.pack(ipadx=2, ipady=2) megnevezes = LabelFrame(self, text="projekt neve") self._projekt_urlap = ProjektUrlap(megnevezes) self._projekt_urlap.pack(ipadx=2, ipady=2) self._projekt_megjelenit(1) megnevezes.pack(fill=X, padx=2, pady=2) return self._projekt_valaszto.valaszto
def __init__(self, parent): LabelFrame.__init__(self, parent, text="Results", width=825, height=485) # Terrible kludgy hack to force the app to stay the right size # Need to work out how to remove self.grid_propagate(False) self.resultsDict = None self.modelType = None self.currentSegment = 0 # Stats frame self.statsFrame = StatsFrame(self, self.padX, self.padY) self.statsFrame.calculate_B.bind("<Button-1>", self._parametersChanged) self.statsFrame.reset_B.bind("<Button-1>", self._parametersReset) def onComboBoxSelect(e): self.currentSegment = e.widget.current() self._updateDisplay(True) self.statsFrame.expSeg_CB.bind("<<ComboboxSelected>>", onComboBoxSelect) # Error frame self.errorSurfaceFrame = ErrorSurfaceFrame(self) self.errorSurfaceFrame.errorSurfaceB.bind("<Button-1>", self._displayErrorSurface) # Graph notebook self.errorSurfaceSeperator = Separator(self, orient=tkinter.HORIZONTAL) self.graphNotebook = ImprovedNotebook(self) self.modelGraphFrame = GraphFrame(self.graphNotebook, dim=2) self.modelGraphFrame.axes.set_ylabel(r'$thickness(m)$') self.regressionGraphFrame = GraphFrame(self.graphNotebook, dim=2) self.regressionGraphFrame.axes.set_ylabel(r'$\log{(thickness(m))}$') self.errorSurfaceGraphFrame = GraphFrame(self.graphNotebook, dim=3) self.errorSurfaceGraphFrame.axes.set_zlabel(r'$error$') self.graphNotebook.addFrame(self.modelGraphFrame, text="Model")
def statistics(df, dictionaries): """ фомрмирование статистик """ global stat report = Toplevel() qty = StringVar(report) headers = [item for item in df if item not in ['Цена', 'Билет', 'Время']] q1 = LabelFrame(report, text='Качественные') q2 = LabelFrame(report, text='Количественные') choice = Combobox(q1, values=headers, textvariable=qty) qty.trace('w', lambda name, index, mode, sv=qty: updateBoxes(sv)) qty.set(headers[0]) choice.current(0) choice.pack(side=LEFT, padx=5, pady=5) q1.pack(side=TOP, padx=10, pady=10) choice2 = Combobox(q2, values=['Цена']) choice2.pack(side=LEFT, padx=5, pady=5) choice2.current(0) choice2.config(state=DISABLED) q2.pack(side=TOP, padx=10, pady=10) bframe = Frame(report) Button(bframe, text='Сформировать', command=lambda frame=df: text_report_old(frame))\ .pack(side=LEFT, padx=10, pady=10) Button(bframe, text='Закрыть', command=lambda: report.destroy())\ .pack(side=LEFT, padx=10, pady=10) bframe.pack(side=TOP)
def __init__(self, parent): LabelFrame.__init__(self, parent, text="Calculate", borderwidth=5) self.startCalculationB = Button(self, text="Start calculation", width=20) self.startCalculationB.grid(row=0, column=0, padx=10, pady=5) self.endCalculationB = Button(self, text="Cancel calculation", width=20) self.endCalculationB.grid(row=1, column=0, padx=10, pady=5) self.calculationPB = Progressbar(self, mode="indeterminate", length=128) self.calculationPB.grid(row=2, column=0, padx=10, pady=5)
def create_widgets(self): ''' creates GUI for app ''' # expand widget to fill the grid # self.columnconfigure(1, weight=1, pad=100) # self.rowconfigure(1, weight=1, pad=20) lframe = LabelFrame(self, text="Combobox", width=100, height=100) lframe.grid(row=1, column=1, sticky=N + S + E + W) self.cbov = StringVar() cbox = Combobox(lframe, textvariable=self.cbov) cbox['values'] = ('value1', 'value2', 'value3') # COMBO.bind('<<ComboboxSelected>>', self.ONCOMBOSELECT) cbox.current(0) cbox.grid(row=1, column=1, sticky=E + W, padx=10, pady=20)
def reset_content(self): self._heading.destroy() self._heading = Frame(self) self._inventory_display.destroy() self._inventory_display = Frame(self) self._die_field.destroy() self._die_field = Frame(self) self._score_field.destroy() self._score_field = LabelFrame(self) self._turn_order.destroy() self._turn_order = Frame(self) if self.die: self.die.destroy() self.die = None self._load_content()
def get_info(self): x, y = (self.size[0]/2, self.size[1]/2) for i in self.info: label_frame= LabelFrame(self, text="name") label_frame.pack(fill="y") for entry in self.info[i]["Entry"]: frame = Frame(label_frame) frame.pack(fill="x") label = Label(label_frame, text=self.info[i]["Entry"][entry], width=6) label.pack(side="left", anchor="n", padx=5, pady=5) for text in self.info[i]["Text"]: frame = Frame(label_frame) frame.pack(fill="x") label = Label(label_frame, text=self.info[i]["Text"][text], width=6) label.pack(side="left", anchor="n", padx=5, pady=5) window = self.canvas.create_window(x, y, window=label_frame, tag="test")
def __init__(self, pipepanel, pipeline_name, *args, **kwargs): PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs) self.info = None eframe = self.eframe = LabelFrame(self, text="Options") #,fg=textLightColor,bg=baseColor) eframe.grid(row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5) label = Label(eframe, text="Pipeline") #,fg=textLightColor,bg=baseColor) label.grid(row=3, column=0, sticky=W, padx=10, pady=5) Pipelines = ["CAPmirseq-plus"] Pipeline = self.Pipeline = StringVar() Pipeline.set(Pipelines[0]) om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller) om.config() #bg = widgetBgColor,fg=widgetFgColor) om["menu"].config() #bg = widgetBgColor,fg=widgetFgColor) #om.pack(side=LEFT,padx=20,pady=5) om.grid(row=3, column=1, sticky=W, padx=10, pady=5) self.add_info(eframe)
def __init__(self, pipepanel, pipeline_name, *args, **kwargs) : PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs) self.info = None eframe = self.eframe = LabelFrame(self,text="Options") #,fg=textLightColor,bg=baseColor) eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 ) label = Label(eframe,text="Pipeline:")#,fg=textLightColor,bg=baseColor) label.grid(row=3,column=0,sticky=W,padx=10,pady=5) Pipelines=["InitialChIPseqQC", "ChIPseq" ] Pipeline = self.Pipeline = StringVar() Pipeline.set(Pipelines[0]) om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller) om.config()#bg = widgetBgColor,fg=widgetFgColor) om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor) #om.pack(side=LEFT,padx=20,pady=5) om.grid(row=3,column=1,sticky=W,padx=20,pady=5) #readtypes = ['Single', 'Paired'] #self.readtype = readtype = StringVar() #readtype.set(readtypes[0]) #readtype_menu = OptionMenu(eframe, readtype, *readtypes) #readtype_menu.grid(row=3, column=3, sticky=E, pady=5) #readtype_label = Label(eframe, text="-end ") #readtype_label.grid( row=3, column=4, stick=W, pady=5) self.add_info(eframe) self.option_controller() self.peakinfo_fn = 'peakcall.tab' self.contrast_fn = 'contrast.tab'
def add_pairs( self, parent ) : if not self.pairs : self.pairs = LabelFrame(parent, text='Pairs') self.pairs_text = Text( self.pairs, width=50, height=8, #bg=projectBgColor, #fg=projectFgColor, font=("nimbus mono bold","11") ) self.pairs_save_button = Button(self.pairs, text="Save", command = self.writepair ) self.pairs_load_button = Button(self.pairs, text="Load", command = self.readpair ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) self.pairs_load_button.grid( row=5, column=5, padx=10, pady=5 ) self.pairs_save_button.grid( row=5, column=6, padx=10, pady=5 ) self.pairs_text.grid( row=1, rowspan=3, column=1, columnspan=7, padx=5, pady=5 ) self.pairs.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 )
def _create_label_frame(self): ''' Creates label frame. ''' self.panel = panel = LabelFrame(self, text=TEXT_FOR_PANEL) panel.columnconfigure(0, weight=1) panel.rowconfigure(0, weight=1) panel.grid(row=1, column=0, padx=5, pady=5, sticky=E + W + S + N)
def __init__(self, pipepanel, pipeline_name, *args, **kwargs): PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs) self.pairs = None eframe = self.eframe = LabelFrame(self, text="Options") #,fg=textLightColor,bg=baseColor) eframe.grid(row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5) label = Label(eframe, text="Pipeline") #,fg=textLightColor,bg=baseColor) label.grid(row=3, column=0, sticky=W, padx=10, pady=5) PipelineLabels = [ 'Initial QC', 'Germline', 'Somatic Tumor-Normal', 'Somatic Tumor-Only' ] Pipelines = [ "initialqcgenomeseq", "wgslow", 'wgs-somatic', 'wgs-somatic-tumoronly' ] self.label2pipeline = {k: v for k, v in zip(PipelineLabels, Pipelines)} PipelineLabel = self.PipelineLabel = StringVar() Pipeline = self.Pipeline = StringVar() PipelineLabel.set(PipelineLabels[0]) #om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller) om = OptionMenu(eframe, PipelineLabel, *PipelineLabels, command=self.option_controller) om.config() #bg = widgetBgColor,fg=widgetFgColor) om["menu"].config() #bg = widgetBgColor,fg=widgetFgColor) #om.pack(side=LEFT,padx=20,pady=5) om.grid(row=3, column=1, sticky=W, padx=10, pady=5)
def on_create_labelframe(self, frame_name, col, row, colpad, rowpad, pos, pic=None): if pic is None: self.panel_control_lf = LabelFrame(master=self.dev_control_panel, text=frame_name) self.panel_control_lf.grid(column=col, row=row, padx=colpad, pady=rowpad, sticky=pos) else: self.house_plan_lf = LabelFrame(master=self.dev_control_panel, text=frame_name) self.house_plan_lf.grid(column=col, row=row, padx=colpad, pady=rowpad, sticky=pos) img = None try: img = Image.open( os.path.join(self.imgpath, str(self.plan[pic]))) print(str(self.plan[pic])) except IOError: pass print(img.mode, '- - - - ', img.size) img.rotate(90) # Bild Umdrehen img.thumbnail((self.pic_width, self.pic_height), Image.ANTIALIAS) # groesse des Bild anpassen img_lbl = ImageTk.PhotoImage( image=img ) # ohne dass --> UnboundLocalError: local variable 'img' # referenced before assignment img_lbl musst als label image zugewiesen werden # ohne dass - - > _tkinter.TclError: image specification must contain an odd number of elements self.house_lbl = Label(self.house_plan_lf, image=img_lbl) self.house_lbl.grid(column=0, row=0, padx=8, pady=5) self.house_lbl = img_lbl # und diese Zuweisung am Ende
def __init__(self, parent, calculationTimeEstimationFunction): LabelFrame.__init__(self, parent, text="Isopachs", borderwidth=5) self.numberOfIsopachs = DEFAULT_NUMBER_OF_ISOPACHS self.calculationTimeEstimationFunction = calculationTimeEstimationFunction openButtonImage = tkinter.PhotoImage(file=IMAGE_DIR + "open_file-icon.gif") self.tickImage = tkinter.PhotoImage(file=IMAGE_DIR + "tick.gif") self.loadFromFileButton = Button(self, image=openButtonImage) self.loadFromFileButton.grid(row=0, column=0, padx=self.buttonPadding, pady=10) self.loadFromFileButton.bind("<Button-1>", self.loadFromFile) self.loadFromFileButton.image = openButtonImage self.addButton = Button(self, text="Add isopach", width=self.buttonWidth) self.addButton.grid(row=0, column=1, padx=self.buttonPadding, pady=10) self.addButton.bind("<Button-1>", self.addIsopach) self.removeButton = Button(self, text="Remove isopach", width=self.buttonWidth) self.removeButton.grid(row=0, column=2, padx=self.buttonPadding, pady=10) self.removeButton.bind("<Button-1>", self.removeIsopach) self.scrollFrame = ScrollFrame(self) self.scrollFrame.grid(row=1, column=0, columnspan=3, sticky="NS") self.innerFrame = self.scrollFrame.innerFrame self.grid_rowconfigure(1, weight=1) self.rows = [self.createRow(i) for i in range(self.numberOfIsopachs)] thicknessM_L = Label(self.innerFrame, text="Thickness (m)") thicknessM_L.grid(column=1, row=1, padx=5, pady=5) sqrtAreaKM_L = Label(self.innerFrame, text="\u221AArea (km)") sqrtAreaKM_L.grid(column=2, row=1, padx=5, pady=5) include_L = Label(self.innerFrame, text="Use?") include_L.grid(column=3, row=1, padx=5, pady=5)
def init_ui(self): self.master.title("Speech Demo") self.pack(fill=BOTH, expand=True) label_frame = LabelFrame(self, text="System words") label_frame.pack(fill=X, padx=40, pady=20) self.labels = [] rows = 8 cols = 2 for j in range(rows): for i in range(cols): k = i + j * cols label = Label(label_frame, text=labels[k]) label.config(font=("Cambria Math", 20)) label.grid(row=j, column=i, padx=20, pady=10) self.labels += [label] self.selected = None self.after(100, self.ontick)
def __init__(self,parent): LabelFrame.__init__(self, parent,text="Results", width=825, height=485) # Terrible kludgy hack to force the app to stay the right size # Need to work out how to remove self.grid_propagate(False) self.resultsDict = None self.modelType = None self.currentSegment = 0 # Stats frame self.statsFrame = StatsFrame(self, self.padX, self.padY) self.statsFrame.calculate_B.bind("<Button-1>", self._parametersChanged) self.statsFrame.reset_B.bind("<Button-1>", self._parametersReset) def onComboBoxSelect(e): self.currentSegment = e.widget.current() self._updateDisplay(True) self.statsFrame.expSeg_CB.bind("<<ComboboxSelected>>", onComboBoxSelect) # Error frame self.errorSurfaceFrame = ErrorSurfaceFrame(self) self.errorSurfaceFrame.errorSurfaceB.bind("<Button-1>", self._displayErrorSurface) # Graph notebook self.errorSurfaceSeperator = Separator(self,orient=tkinter.HORIZONTAL) self.graphNotebook = ImprovedNotebook(self) self.modelGraphFrame = GraphFrame(self.graphNotebook, dim=2) self.modelGraphFrame.axes.set_ylabel(r'$thickness(m)$') self.regressionGraphFrame = GraphFrame(self.graphNotebook, dim=2) self.regressionGraphFrame.axes.set_ylabel(r'$\ln{(thickness(m))}$') self.errorSurfaceGraphFrame = GraphFrame(self.graphNotebook, dim=3) self.errorSurfaceGraphFrame.axes.set_zlabel(r'$error$') self.graphNotebook.addFrame(self.modelGraphFrame, text="Model")
def __init__(self): self.BTL = [110, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 56000, 57600, 115200, 128000, 256000] # 波特率下拉列表框内容 self.JYW = ['NONE', 'ODD', 'EVEN', 'MARK', 'SPACE'] # 校验位下拉列表框内容 self.SJW = [5, 6, 7, 8] # 数据位下拉列表内容 self.TZW = [1, 1.5, 2] # 停止位下拉列表内容 self.CKXX = self.read_serial_info() self.PZMC = ['串口号','波特率','校验位','数据位','停止位'] self.serial_res_hex_bzw = False # 接收数据框内容显示hex标志位 self.serial_sen_hex_bzw = False # 发送数据框内容显示hex标志位 self.radiobutton_sen_ascii_click_count = 1 # 设置发送ASCII单选框点击次数为0 self.radiobutton_sen_hex_click_count = 0 # 设置发送HEX单选框点击次数为0 self.root = Tk(className='串口调试助手') # 创建一个主窗体,并命名为‘串口调试助手’ self.root.protocol('WM_DELETE_WINDOW',self.close_window) # 实现点击窗口关闭按钮,调用self.close_window方法,关闭已经打开的串口,销毁窗口 self.root.geometry('630x580') # 设置窗体大小 self.root.minsize(width=630, height=435) # 这两句语言限制窗口不能随意变化 self.root.maxsize(width=630, height=435) self.lf = LabelFrame(self.root, text='串口设置') # 创建标签容器,并且命名为‘串口设置’ self.lf.grid(padx=8, pady=10,ipadx=3, ipady=5,row=1,column=1,sticky='n') # 设置标签容器在窗口中的位置 self.text_res_con = LabelFrame(master=self.root,text='接收设置') # 创建标签容器,并命名为接收设置 self.text_res_con.grid(row=1,column=1,sticky='s') # 设置标签容器在窗口中的位置 self.text_sen_con = LabelFrame(master=self.root,text='发送设置') # 创建标签容器,并命名为接收设置 self.text_sen_con.grid(padx=8, pady=10,row=2,column=1,sticky='nesw') # 设置标签容器在窗口中的位置 self.data_rec = LabelFrame(self.root, text='数据日志') # 创建标签容器,并且命名为‘数据日志’ self.data_rec.grid(ipadx=3, ipady=5,row=1, column=2, sticky='e') # 设置标签容器在窗口中的位置 self.y_scroll = Scrollbar(self.data_rec) # 创建接收文本框的Y轴下拉框 self.y_scroll.pack(side=RIGHT,fill=Y) # 确定位置 self.result_text = Text(master=self.data_rec,height=22,width=66,yscrollcommand=self.y_scroll.set) # 创建一个多文本组件,用来显示接收的串口信息,并且配置关联滚轴 self.result_text.pack(side=RIGHT,fill=Y) # 设置多文本组件在窗口中的位置 self.y_scroll.config(command=self.result_text.yview) # 让文本框和滚轴关联起来 self.data_sen = LabelFrame(self.root, text='数据发送') # 创建标签容器,并且命名为‘数据日志’ self.data_sen.grid(ipadx=3, ipady=5,row=2, column=2, sticky='w') # 设置标签容器在窗口中的位置 self.send_text = Text(master=self.data_sen,height=6,width=60) # 创建一个发送文本框 self.send_text.grid(row=1,column=1,sticky='n') # 设置标签容器在窗口中的位置 self.button_send = Button(self.data_sen,text='发送消息',command=self.button_send_serial_click,width=7) # 创建一个发送文本框 self.button_send.grid(row=1,column=2,sticky='NSEW') # 设置串口打开按钮的位置
def servicepanel(server): ''' Draws the panel with the service information ''' global servv, spanel servicepanel = LabelFrame(win, text = "Service Details") servicepanel.grid(column = 0, row = 1, padx = 5, pady = 5, sticky = W+E) services = server.getservices() scount = 0 for service in services: servv[service] = StringVar() Label(servicepanel, text = service + ": ").grid(column = 0, row = scount, sticky = W) Label(servicepanel, textvariable = servv[service]).grid(column = 1, row = scount, sticky = W) servicestatus(server, service) scount += 1 spanel = Label(servicepanel, textvariable = status).grid(column = 0, row = scount + 1, columnspan = 2, sticky = W) status.set("")
def popup_window( self, text, filename ) : top = Toplevel() info = LabelFrame(top, text=text )#"Group Information") info_text = Text(info, width=50, height=8, #bg=projectBgColor, #fg=projectFgColor, font=("nimbus mono bold","11") ) def savefunc() : self.writepaste( filename, info_text ) def loadfunc() : self.readpaste( filename, info_text ) info_save_button = Button(info, text="Save", command = savefunc ) info_load_button = Button(info, text="Load", command = loadfunc ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) info_load_button.grid( row=5, column=5, padx=10, pady=5 ) info_save_button.grid( row=5, column=6, padx=10, pady=5 ) info_text.grid(row=1, rowspan=3, column=1, columnspan=7, padx=5, pady=5 ) info.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 ) top.focus_force()
def __init__(self,parent,calculationTimeEstimationFunction): LabelFrame.__init__(self,parent,text="Isopachs",borderwidth=5) self.numberOfIsopachs = DEFAULT_NUMBER_OF_ISOPACHS self.calculationTimeEstimationFunction = calculationTimeEstimationFunction openButtonImage = tkinter.PhotoImage(file=IMAGE_DIR + "open_file-icon.gif") self.tickImage = tkinter.PhotoImage(file=IMAGE_DIR + "tick.gif") self.loadFromFileButton = Button(self,image=openButtonImage) self.loadFromFileButton.grid(row=0,column=0,padx=self.buttonPadding,pady=10) self.loadFromFileButton.bind("<Button-1>",self.loadFromFile) self.loadFromFileButton.image = openButtonImage self.addButton = Button(self,text="Add isopach",width=self.buttonWidth) self.addButton.grid(row=0,column=1,padx=self.buttonPadding,pady=10) self.addButton.bind("<Button-1>",self.addIsopach) self.removeButton = Button(self,text="Remove isopach",width=self.buttonWidth) self.removeButton.grid(row=0,column=2,padx=self.buttonPadding,pady=10) self.removeButton.bind("<Button-1>",self.removeIsopach) self.scrollFrame = ScrollFrame(self) self.scrollFrame.grid(row=1,column=0,columnspan=3, sticky="NS") self.innerFrame = self.scrollFrame.innerFrame self.grid_rowconfigure(1,weight=1) self.rows = [self.createRow(i) for i in range(self.numberOfIsopachs)] thicknessM_L = Label(self.innerFrame, text="Thickness (m)") thicknessM_L.grid(column=1, row=1, padx=5, pady=5) sqrtAreaKM_L = Label(self.innerFrame, text="\u221AArea (km)") sqrtAreaKM_L.grid(column=2, row=1, padx=5, pady=5) include_L = Label(self.innerFrame, text="Use?") include_L.grid(column=3, row=1, padx=5, pady=5)
def __init__(self,parent): LabelFrame.__init__(self, parent, borderwidth=0) entryWidth = 7 xPad1 = 30 xPad2 = 5 self.errorXLowerLimitL = Label(self) self.errorXLowerLimitE = CustomEntry(self,width=entryWidth,justify="right") self.errorXLowerLimitL.grid(row=0,column=0,padx=(10,xPad2),pady=5,sticky="W") self.errorXLowerLimitE.grid(row=0,column=1,padx=(xPad2,xPad1),pady=5) self.errorXUpperLimitL = Label(self) self.errorXUpperLimitE = CustomEntry(self,width=entryWidth,justify="right") self.errorXUpperLimitL.grid(row=1,column=0,padx=(10,xPad2),pady=5,sticky="W") self.errorXUpperLimitE.grid(row=1,column=1,padx=(xPad2,xPad1),pady=5) self.errorYLowerLimitL = Label(self) self.errorYLowerLimitE = CustomEntry(self,width=entryWidth,justify="right") self.errorYLowerLimitL.grid(row=0,column=2,padx=(xPad1,xPad2),pady=5,sticky="W") self.errorYLowerLimitE.grid(row=0,column=3,padx=(xPad2,xPad1),pady=5) self.errorYUpperLimitL = Label(self) self.errorYUpperLimitE = CustomEntry(self,width=entryWidth,justify="right") self.errorYUpperLimitL.grid(row=1,column=2,padx=(xPad1,xPad2),pady=5,sticky="W") self.errorYUpperLimitE.grid(row=1,column=3,padx=(xPad2,xPad1),pady=5) self.errorResolutionL = Label(self,text="Resolution: ") self.errorResolutionE = CustomEntry(self,width=entryWidth,justify="right") self.errorResolutionE.insert(0,ERROR_SURFACE_DEFAULT_RESOLUTION) self.errorResolutionL.grid(row=0,column=4,padx=(xPad1,xPad2),pady=5,sticky="W") self.errorResolutionE.grid(row=0,column=5,padx=(xPad2,xPad1),pady=5,sticky="E") self.errorSurfaceB = Button(self,text=" Calculate error surface ") self.errorSurfaceB.grid(row=1,column=4,columnspan=2,padx=(xPad1,xPad1),sticky="EW") self.errorSurfaceB.configure(state=tkinter.ACTIVE)
def add_info( self, parent ) : if not self.info : self.info = LabelFrame(parent, text="Sample Information") self.groups_button = Button(self.info, text="Set Groups", command = self.popup_groups ) self.contrasts_button = Button(self.info, text="Set Contrasts", command = self.popup_contrasts ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) self.groups_button.grid( row=5, column=5, padx=10, pady=5 ) self.contrasts_button.grid( row=5, column=6, padx=10, pady=5 ) self.info.grid(row=10,column=0, columnspan=6, sticky=W, padx=20, pady=10 )
def create_widgets(self): ''' Creates all widgets. ''' self.columnconfigure(0, weight=1) self.rowconfigure(1, weight=1) validate_btn = Button(self, text='Validate weight restrictions', command=self.on_validate_weights) validate_btn.grid(row=0, column=0, padx=10, pady=5, sticky=N+W) panel = LabelFrame(self, text='Weight restrictions') panel.columnconfigure(0, weight=1) panel.rowconfigure(0, weight=1) panel.grid(row=1, column=0, padx=5, pady=5, sticky=E+W+S+N) weight_tab_main = VerticalScrolledFrame(panel) weight_tab_main.grid(row=0, column=0, sticky=E+W+S+N) weights_tab = weight_tab_main.interior self.abs_weights = TextForWeights(weights_tab, 'absolute', 'Input1 <= 0.02', self.current_categories, self.params, 'ABS_WEIGHT_RESTRICTIONS') self.abs_weights.grid(row=0, column=0, padx=10, pady=5, sticky=N+W) self.virtual_weights = TextForWeights(weights_tab, 'virtual', 'Input1 >= 0.34', self.current_categories, self.params, 'VIRTUAL_WEIGHT_RESTRICTIONS') self.virtual_weights.grid(row=1, column=0, padx=10, pady=5, sticky=N+W) self.price_ratio_weights = TextForWeights(weights_tab, 'price ratio', 'Input1/Input2 <= 5', self.current_categories, self.params, 'PRICE_RATIO_RESTRICTIONS', True) self.price_ratio_weights.grid(row=2, column=0, padx=10, pady=5, sticky=N+W)
class GenomeSeqFrame( PipelineFrame ) : def __init__(self, pipepanel, pipeline_name, *args, **kwargs) : PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs) self.pairs = None eframe = self.eframe = LabelFrame(self,text="Options") #,fg=textLightColor,bg=baseColor) eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 ) label = Label(eframe,text="Pipeline")#,fg=textLightColor,bg=baseColor) label.grid(row=3,column=0,sticky=W,padx=10,pady=5) PipelineLabels = ['Initial QC', 'Germline', 'Somatic Tumor-Normal', 'Somatic Tumor-Only'] Pipelines=["initialqcgenomeseq", "wgslow", 'wgs-somatic', 'wgs-somatic-tumoronly'] self.label2pipeline = { k:v for k,v in zip(PipelineLabels, Pipelines)} PipelineLabel = self.PipelineLabel = StringVar() Pipeline = self.Pipeline = StringVar() PipelineLabel.set(PipelineLabels[0]) #om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller) om = OptionMenu(eframe, PipelineLabel, *PipelineLabels, command=self.option_controller) om.config()#bg = widgetBgColor,fg=widgetFgColor) om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor) #om.pack(side=LEFT,padx=20,pady=5) om.grid(row=3,column=1,sticky=W,padx=10,pady=5) def option_controller( self, *args, **kwargs ) : PipelineFrame.option_controller( self ) self.Pipeline.set( self.label2pipeline[self.PipelineLabel.get()] ) print( self.Pipeline.get() ) if self.Pipeline.get() == 'wgs-somatic' : self.add_pairs( self.eframe ) #self.dry_button.config( state="disabled" ) elif self.Pipeline.get() != 'wgs-somatic' : self.del_pairs( self.eframe ) #if self.workpath.get() : # self.dry_button.config( state='active' ) def add_pairs( self, parent ) : if not self.pairs : self.pairs = LabelFrame(parent, text='Pairs') self.pairs_text = Text( self.pairs, width=50, height=8, #bg=projectBgColor, #fg=projectFgColor, font=("nimbus mono bold","11") ) self.pairs_save_button = Button(self.pairs, text="Save", command = self.writepair ) self.pairs_load_button = Button(self.pairs, text="Load", command = self.readpair ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) self.pairs_load_button.grid( row=5, column=5, padx=10, pady=5 ) self.pairs_save_button.grid( row=5, column=6, padx=10, pady=5 ) self.pairs_text.grid( row=1, rowspan=3, column=1, columnspan=7, padx=5, pady=5 ) self.pairs.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 ) def del_pairs( self, parent ) : if self.pairs : self.pairs.grid_forget() def writepair( self ) : self.writepaste( 'pairs', self.pairs_text ) #self.dry_button.config( state='active' ) def readpair( self ) : self.readpaste( 'pairs', self.pairs_text )
def make_widgets(frame: ttk.LabelFrame, pane: SubPane) -> SelectorWin: """Generate the UI components, and return the base window.""" def for_channel(channel: MusicChannel) -> List[SelItem]: """Get the items needed for a specific channel.""" music_list = [] for music in Music.all(): if music.provides_channel(channel): selitem = SEL_ITEMS[music.id].copy() selitem.snd_sample = music.get_sample(channel) music_list.append(selitem) return music_list # This gets overwritten when making windows. last_selected = { channel: GEN_OPTS.get_val( 'Last_Selected', 'music_' + channel.name.casefold(), '<NONE>', ) for channel in MusicChannel } base_win = WINDOWS[MusicChannel.BASE] = SelectorWin( TK_ROOT, for_channel(MusicChannel.BASE), title=_('Select Background Music - Base'), desc=_('This controls the background music used for a map. Expand ' 'the dropdown to set tracks for specific test elements.'), has_none=True, sound_sys=filesystem, none_desc=_('Add no music to the map at all. Testing Element-specific ' 'music may still be added.'), callback=selwin_callback, callback_params=[MusicChannel.BASE], attributes=[ SelAttr.bool('SPEED', _('Propulsion Gel SFX')), SelAttr.bool('BOUNCE', _('Repulsion Gel SFX')), SelAttr.bool('TBEAM', _('Excursion Funnel Music')), SelAttr.bool('TBEAM_SYNC', _('Synced Funnel Music')), ], ) WINDOWS[MusicChannel.TBEAM] = SelectorWin( TK_ROOT, for_channel(MusicChannel.TBEAM), title=_('Select Excursion Funnel Music'), desc=_('Set the music used while inside Excursion Funnels.'), has_none=True, sound_sys=filesystem, none_desc=_('Have no music playing when inside funnels.'), callback=selwin_callback, callback_params=[MusicChannel.TBEAM], attributes=[ SelAttr.bool('TBEAM_SYNC', _('Synced Funnel Music')), ], ) WINDOWS[MusicChannel.BOUNCE] = SelectorWin( TK_ROOT, for_channel(MusicChannel.BOUNCE), title=_('Select Repulsion Gel Music'), desc=_('Select the music played when players jump on Repulsion Gel.'), has_none=True, sound_sys=filesystem, none_desc=_('Add no music when jumping on Repulsion Gel.'), callback=selwin_callback, callback_params=[MusicChannel.BOUNCE], ) WINDOWS[MusicChannel.SPEED] = SelectorWin( TK_ROOT, for_channel(MusicChannel.SPEED), title=_('Select Propulsion Gel Music'), desc=_('Select music played when players have large amounts of horizontal velocity.'), has_none=True, sound_sys=filesystem, none_desc=_('Add no music while running fast.'), callback=selwin_callback, callback_params=[MusicChannel.SPEED], ) assert set(WINDOWS.keys()) == set(MusicChannel), "Extra channels?" # Widgets we want to remove when collapsing. exp_widgets = [] # type: List[tkinter.Widget] def toggle_btn_enter(event=None): toggle_btn['text'] = BTN_EXPAND_HOVER if is_collapsed else BTN_CONTRACT_HOVER def toggle_btn_exit(event=None): toggle_btn['text'] = BTN_EXPAND if is_collapsed else BTN_CONTRACT def set_collapsed(): """Configure for the collapsed state.""" global is_collapsed is_collapsed = True GEN_OPTS['Last_Selected']['music_collapsed'] = '1' base_lbl['text'] = _('Music: ') toggle_btn_exit() # Set all music to the children - so those are used. set_suggested(WINDOWS[MusicChannel.BASE].chosen_id, sel_item=True) for wid in exp_widgets: wid.grid_remove() def set_expanded(): """Configure for the expanded state.""" global is_collapsed is_collapsed = False GEN_OPTS['Last_Selected']['music_collapsed'] = '0' base_lbl['text'] = _('Base: ') toggle_btn_exit() for wid in exp_widgets: wid.grid() pane.update_idletasks() pane.move() def toggle(event=None): if is_collapsed: set_expanded() else: set_collapsed() pane.update_idletasks() pane.move() frame.columnconfigure(2, weight=1) base_lbl = ttk.Label(frame) base_lbl.grid(row=0, column=1) toggle_btn = ttk.Label(frame, text=' ') toggle_btn.bind('<Enter>', toggle_btn_enter) toggle_btn.bind('<Leave>', toggle_btn_exit) toggle_btn.bind('<ButtonPress-1>', toggle) toggle_btn.grid(row=0, column=0) for row, channel in enumerate(MusicChannel): btn = WINDOWS[channel].widget(frame) if row: exp_widgets.append(btn) btn.grid(row=row, column=2, sticky='EW') for row, text in enumerate([ _('Funnel:'), _('Bounce:'), _('Speed:'), ], start=1): label = ttk.Label(frame, text=text) exp_widgets.append(label) label.grid(row=row, column=1, sticky='EW') if GEN_OPTS.get_bool('Last_Selected', 'music_collapsed', True): set_collapsed() else: set_expanded() for channel, win in WINDOWS.items(): win.sel_item_id(last_selected[channel]) return base_win
def init_project_frame( self ) : projframe = Frame(self) ###################### #The Project Entry Form # #Current design inherited from others #is very bad. It should have been made as #json or dictionary as is in this point #then the subsequent coding will be much #eaiser. #BK ###################### BS=StringVar() self.eprojectid = eprojectid= StringVar() self.eorganism = eorganism=StringVar() self.eanalyst = eanalyst=StringVar() self.epoc = epoc=StringVar() self.epi = epi=StringVar() self.euser = euser=StringVar() self.eflowcell = eflowcell=StringVar() self.eplatform = eplatform=StringVar() eplatform.set("Illumina") self.technique = technique=StringVar() self.pipehome = pipehome=StringVar() pipehome.set(PIPELINER_HOME) editframe = Frame( self ) editframe.grid( column=0, row=3, columnspan=3 ) projpanel1 = LabelFrame(editframe,text="Project Information") #,fg=textLightColor,bg=baseColor) projpanel1.pack( side = TOP, fill=X, padx=10, pady=5, expand=YES ) pipeline_panel = LabelFrame(editframe, text="Global Settings") pipeline_panel.pack( side=TOP, fill=X, padx=10, pady=5, expand=YES ) l=Label( pipeline_panel, text="Genome:" ) l.grid(row=1,column=3,sticky=W,padx=0,pady=5) l = Label( pipeline_panel, text="Pipeline Family:" ) l.grid(row=1,column=1,sticky=W,padx=0,pady=5) annotations=['hg19','mm10','mm9','hg38','GRCh38'] self.annotation = annotation = StringVar() annotation.set(annotations[0]) #annotation.trace('w', lambda *_ :settargets(annotation) ) om = OptionMenu(pipeline_panel, annotation, *annotations, command=self.set_pipeline) #, command=lambda _:makejson("refsets")) om.config() #bg = widgetBgColor,fg=widgetFgColor) om["menu"].config() #bg = widgetBgColor,fg=widgetFgColor) om.grid(row=1,column=4,sticky=W,padx=10,pady=10) pfamilys = ['exomeseq', 'rnaseq', 'genomeseq', 'mirseq', 'ChIPseq', 'scrnaseq'] self.pfamily = pfamily = StringVar() pfamily.set('Select a pipeline') om = OptionMenu(pipeline_panel, pfamily, *pfamilys, command=self.set_pipeline) #, command=lambda _:makejson(pfamily.get())) om.config() #bg = widgetBgColor,fg=widgetFgColor) om["menu"].config() #bg = widgetBgColor,fg=widgetFgColor) om.grid(row=1,column=2,sticky=W,padx=10,pady=5) #add_button = Button( pipeline_panel, # text="Set a pipeline", # command=self.add_pipeline # ) #add_button.grid(row=1, column=5, sticky=W, padx=10, pady=5) self.notebook = notebook = Notebook( editframe ) self.pipelineframe = None #the pipeline frame in the notebook frame! projpanel2 = Frame(notebook) #,fg=textLightColor,bg=baseColor) projpanel2.pack( side = LEFT, fill=BOTH, padx=10, pady=5, expand=YES ) notebook.add( projpanel2, text="Project Description" ) notebook.pack( side=LEFT, fill=BOTH, padx=10, pady=5, expand=YES ) Dscrollbar = Scrollbar(projpanel2) Dscrollbar.grid(row=2,column=4,rowspan=40) self.description =description= Text(projpanel2, width=75, height=28, #bg=commentBgColor, #fg=commentFgColor, font=("nimbus mono bold","10"), yscrollcommand = Dscrollbar.set) description.delete("1.0", END) description.insert(INSERT, "Enter CCBR Project Description and Notes here.") #description.bind('<FocusOut>',lambda _:makejson("none")) description.grid(row=2,column=3,sticky="e",padx=10,pady=5) Dscrollbar['command']=description.yview L=Label(projpanel1, text="Project Id", anchor="ne" ) #,bg=baseColor,fg=textLightColor) E = Entry(projpanel1, bd =2, width=20, #bg=entryBgColor, #fg=entryFgColor, textvariable=eprojectid ) #L.pack(pady=5,padx=5) #E.pack(pady=1,padx=5) L.grid(row=0, column=0, sticky=W, padx=10, pady=5) E.grid(row=0, column=2, sticky=W, padx=10, pady=5) eprojectid.set("project") #eprojectid.trace('w', makejson) L2=Label(projpanel1, text = "(Examples: CCBR-nnn,Labname or short project name)", anchor="ne" )#,bg="firebrick",fg="white") L2.grid(row=0, column=3, padx=10, pady=5, sticky="w") L=Label( projpanel1, text="Email address", anchor="ne")#,bg=baseColor,fg=textLightColor) E = Entry( projpanel1, bd =2, width=20, #bg=entryBgColor, #fg=entryFgColor, textvariable=euser) L3 = Label(projpanel1, text ="(Mandatory field: must use @nih.gov email address)", anchor="ne") L3.grid(row=1,column=3,padx=10,pady=5,sticky="w") L.grid(row=1,column=0,sticky=W,padx=10,pady=5) E.grid(row=1,column=2,sticky=W,padx=10,pady=5) #euser.trace('w', makejson) L=Label(projpanel1,text="Flow Cell ID",anchor="ne") E = Entry(projpanel1, bd =2, width=20, textvariable=eflowcell )#, bg=entryBgColor) L4=Label( projpanel1, text="(Examples: FlowCellID, Labname, date or short project name)", anchor="ne" )#,bg="firebrick",fg="white") L4.grid(row=2,column=3,padx=10,pady=5,sticky="w") L.grid(row=2,column=0,sticky=W,padx=10,pady=5) E.grid(row=2,column=2,sticky=W,padx=10,pady=5) eflowcell.set("stats") #eflowcell.trace('w', makejson) Projscrollbar = Scrollbar(projframe) Projscrollbar.grid(row=2,column=4,rowspan=30 ) self.jsonconf = jsonconf = Text( projframe, width=80, height=30, #bg=projectBgColor, #fg=projectFgColor, font=("nimbus mono bold","11"), yscrollcommand = Projscrollbar.set) Projscrollbar['command']=jsonconf.yview jsonconf.grid(row=3,column=0,sticky="e",padx=10,pady=5)
def _gui(): try: from tkinter import Tk, ttk, filedialog, messagebox, StringVar, IntVar from tkinter.ttk import Button, Entry, Frame, Label, LabelFrame, Notebook, Radiobutton, Style except: sys.exit("Unable to load tkinter. Aborting.") def _check_single(): #check the input and accordingly give the output... for the f_single tab if txt_f_single_entry.get()=="": lbl_f_single_result.config(text="", style="TLabel") elif check_afm(txt_f_single_entry.get()): lbl_f_single_result.config(text="Έγκυρο ΑΦΜ.", style="valid.TLabel") else: lbl_f_single_result.config(text="Άκυρο ΑΦΜ.", style="invalid.TLabel") def _select_input_file(): strv_f_file_input.set(filedialog.askopenfilename(title="Άνοιγμα αρχείου")) if strv_f_file_input.get() != "" and strv_f_file_output.get() != "": btn_f_file_submit.config(state="normal") else: btn_f_file_submit.config(state="disabled") #TODO a much better mechanism to enable / disable btn_f_file_submit is needed. def _select_output_file(): strv_f_file_output.set(filedialog.asksaveasfilename(title="Αποθήκευση ως...")) if strv_f_file_input.get() != "" and strv_f_file_output.get() != "": btn_f_file_submit.config(state="normal") else: btn_f_file_submit.config(state="disabled") def _check_file():#TODO this could / should be merged with the TUI version... input_filepath = strv_f_file_input.get() output_filepath = strv_f_file_output.get() filter_output = intvar_filter_sel.get() try: input_file = open(input_filepath, "r") output_file = open(output_filepath, "w") except: messagebox.showerror(title="Σφάλμα", message="Αδυναμία διαχείρησης των αρχείων που ορίσατε.\n\nΠαρακαλώ επιβεβαιώστε πως το αρχείο με τα δεδομένα υπάρχει, πως έχετε δικαιώματα ανάγνωσης, και πως έχετε δικαιώματα εγγραφής στον κατάλογο εξαγωγής των αποτελεσμάτων.") return counter = {True:0, False:0} for entry in input_file: validation = check_afm(entry.strip()) counter[validation]+=1 if filter_output == 3 and validation == False: output_file.write(entry) elif filter_output == 2 and validation == True: output_file.write(entry) elif filter_output == 1: output_file.write(entry.strip() + "\t" + str(validation) + "\n\r") lbl_f_file_result.config(text="Σύνολο: "+str(counter[True]+counter[False])+"\nΈγκυρα: "+str(counter[True])+"\nΆκυρα: "+str(counter[False])) #create the window main_window = Tk() main_window.title("Έλεγχος εγκυρότητας Α.Φ.Μ. (v 2.0)") main_window.geometry("600x180") main_window.minsize(600,180) #fool arround with styling style = ttk.Style() style.configure("valid.TLabel", background="green") style.configure("empty.TLabel", background="white") style.configure("invalid.TLabel", background="red") style.configure("TNotebook", padding = 10) #create the Notebook tabs = Notebook(main_window) f_single = Frame(tabs) f_file = Frame(tabs) tabs.add(f_single, text="Μεμονομένα Α.Φ.Μ.") tabs.add(f_file, text="Λίστα από αρχείο")#add state="disabled" prior to git push until ready tabs.pack(anchor="nw") #add some widgets in f_single tab lbl_f_single_instructions = Label(f_single, text="Εισάγετε έναν ΑΦΜ για έλεγχο") lbl_f_single_instructions.grid(column=0, row=0) lbl_f_single_result = Label(f_single, text="", width=10, justify="center") lbl_f_single_result.grid(column=1, row=0, rowspan=2, sticky="ewns") txt_f_single_entry = Entry(f_single, width=11) txt_f_single_entry.focus() txt_f_single_entry.bind("<KeyRelease>", lambda e: _check_single() ) txt_f_single_entry.grid(column=0,row=1) #btn_f_single_submit = Button(f_single, text="Έλεγχος", command=_check_single) #btn_f_single_submit.grid(column=0,row=2) #add some widgets in f_file tab lbl_f_file_finput = Label(f_file, text="Άνοιγμα...") lbl_f_file_finput.grid(column=0, row=0) strv_f_file_input = StringVar() txt_f_file_finput = Entry(f_file, textvariable = strv_f_file_input) txt_f_file_finput.grid(column=1, row=0) btn_f_file_finput = Button(f_file, text="...", width=3, command=_select_input_file) btn_f_file_finput.grid(column=2, row=0, sticky="W") lbl_f_file_foutput = Label(f_file, text="Αποθήκευση ως...") lbl_f_file_foutput.grid(column=0, row=1) strv_f_file_output = StringVar() txt_f_file_foutput = Entry(f_file, textvariable = strv_f_file_output) txt_f_file_foutput.grid(column=1, row=1) btn_f_file_foutput = Button(f_file, text="...", width=3, command=_select_output_file) btn_f_file_foutput.grid(column=2, row=1, sticky="W") lf_filter = LabelFrame(f_file, text="Επιστροφή") lf_filter.grid(column=3, row=0, rowspan=2, sticky="ewns") intvar_filter_sel = IntVar() rb_filter_all = Radiobutton(lf_filter, text="Όλων", variable=intvar_filter_sel, value=1) #TODO maybe add command rb_filter_all.pack(anchor="w") rb_filter_all.invoke() rb_filter_true = Radiobutton(lf_filter, text="Έγκυρων", variable=intvar_filter_sel, value=2) rb_filter_true.pack(anchor="w") rb_filter_false = Radiobutton(lf_filter, text="Άκυρων", variable=intvar_filter_sel, value=3) rb_filter_false.pack(anchor="w") lf_result = LabelFrame(f_file, text="Σύνοψη") lf_result.grid(column=4, row=0, rowspan=2, sticky="ewns") lbl_f_file_result = Label(lf_result, text="", width=12)#TODO bring results lbl_f_file_result.pack() btn_f_file_submit = Button(f_file, text="Επεξεργασία", state="disabled", command=_check_file) btn_f_file_submit.grid(column=0, row=2, columnspan=3) btn_main_exit = Button(main_window, text="Έξοδος", command=sys.exit) btn_main_exit.pack(anchor="se") main_window.mainloop()
def __init__(self,parent): LabelFrame.__init__(self,parent,text="Model",borderwidth=5) self.selection = tkinter.IntVar() self.exponential = Radiobutton(self,text="Exponential model",variable=self.selection,value=Model.EXP.value,command=self.changeSelection) self.powerlaw = Radiobutton(self,text="Power law model",variable=self.selection,value=Model.POW.value,command=self.changeSelection) self.weibull = Radiobutton(self,text="Weibull model",variable=self.selection,value=Model.WEI.value,command=self.changeSelection) self.exponential.grid(row=0,column=0,sticky="W",padx=10,pady=(self.topPadding,5)) self.powerlaw.grid(row=1,column=0,sticky="W",padx=10,pady=5) self.weibull.grid(row=2,column=0,sticky="W",padx=10,pady=(5,0)) seperator = Separator(self, orient=tkinter.VERTICAL) seperator.grid(row=0, column=1, rowspan=3, sticky="NS", padx=(20,10), pady=(self.topPadding,0)) ## Exponential setup self.expNumberOfSegments_L = Label(self,text="Number of segments: ") self.expNumberOfSegments_E = Entry(self,width=5, justify="right") self.expNumberOfSegments_E.insert(0, settings.EXP_DEFAULT_NUMBER_OF_SEGMENTS) self.expWidgets = [self.expNumberOfSegments_L,self.expNumberOfSegments_E] ## Power law setup self.powProximalLimit_L = Label(self,text="Proximal limit of integration: ") self.powProximalLimit_E = Entry(self,width=5, justify="right") self.powDistalLimit_L = Label(self,text="Distal limit of integration: ") self.powDistalLimit_E = Entry(self,width=5, justify="right") self.powProximalLimit_E.insert(0, settings.POW_DEFAULT_PROXIMAL_LIMIT) self.powDistalLimit_E.insert(0, settings.POW_DEFAULT_DISTAL_LIMIT) self.powWidgets = [self.powProximalLimit_L,self.powProximalLimit_E, self.powDistalLimit_L,self.powDistalLimit_E] ## Weibull setup self.weiNumberOfRuns_L = Label(self,text="Number of runs: ") self.weiNumberOfRuns_E = Entry(self,width=5, justify="right") self.weiIterationsPerRun_L = Label(self,text="Iterations per run: ") self.weiIterationsPerRun_E = Entry(self,width=5, justify="right") self.weiEstimatedTime_L = Label(self,text="Estimated time (s): ") self.weiEstimatedTime_E = CustomEntry(self,width=5, justify="right") self.weiEstimatedTime_E.setUserEditable(False) self.weiLambdaLowerBoundL = Label(self,text="\u03BB lower bound:") self.weiLambdaUpperBoundL = Label(self,text="\u03BB upper bound:") self.weiLambdaLowerBoundE = Entry(self,width=5, justify="right") self.weiLambdaUpperBoundE = Entry(self,width=5, justify="right") self.weiKLowerBoundL = Label(self,text="k lower bound:") self.weiKUpperBoundL = Label(self,text="k upper bound:") self.weiKLowerBoundE = Entry(self,width=5, justify="right") self.weiKUpperBoundE = Entry(self,width=5, justify="right") self.weiNumberOfRuns_E.insert(0, settings.WEI_DEFAULT_NUMBER_OF_RUNS) self.weiIterationsPerRun_E.insert(0, settings.WEI_DEFAULT_ITERATIONS_PER_RUN) self.weiLambdaLowerBoundE.insert(0, settings.WEI_DEFAULT_LAMBDA_LOWER_BOUND) self.weiLambdaUpperBoundE.insert(0, settings.WEI_DEFAULT_LAMBDA_UPPER_BOUND) self.weiKLowerBoundE.insert(0, settings.WEI_DEFAULT_K_LOWER_BOUND) self.weiKUpperBoundE.insert(0, settings.WEI_DEFAULT_K_UPPER_BOUND) self.weiWidgets = [self.weiNumberOfRuns_L,self.weiNumberOfRuns_E, self.weiIterationsPerRun_L,self.weiIterationsPerRun_E, self.weiEstimatedTime_L,self.weiEstimatedTime_E, self.weiLambdaLowerBoundL,self.weiLambdaUpperBoundL,self.weiLambdaLowerBoundE,self.weiLambdaUpperBoundE, self.weiKLowerBoundL,self.weiKUpperBoundL,self.weiKLowerBoundE,self.weiKUpperBoundE] ## General self.currentWidgets = [] self.selection.set(Model.EXP.value) self.changeSelection()
class ExomeSeqFrame( PipelineFrame ) : def __init__(self, pipepanel, pipeline_name, *args, **kwargs) : PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs) self.pairs = None eframe = self.eframe = LabelFrame(self,text="Options") #,fg=textLightColor,bg=baseColor) eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 ) label = Label(eframe,text="Pipeline")#,fg=textLightColor,bg=baseColor) label.grid(row=3,column=0,sticky=W,padx=10,pady=5) Pipelines=["initialqc","exomeseq-somatic","exomeseq-germline"] Pipeline = self.Pipeline = StringVar() Pipeline.set(Pipelines[0]) om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller) #om.config()#bg = widgetBgColor,fg=widgetFgColor) #om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor) #om.pack(side=LEFT,padx=20,pady=5) om.grid(row=3,column=1,sticky=W,padx=10,pady=5) targetsL=Label(eframe, text="Target Capture Kit") #,fg=textLightColor,bg=baseColor) targetsL.grid(row=5,column=0,sticky=W,padx=10,pady=5) targetsE = Entry(eframe,textvariable=self.targetspath, width=50) if self.genome=="hg19": self.targetspath.set( "/data/CCBR_Pipeliner/db/PipeDB/lib/SS_v5_UTRs_hg19.bed" ) else: self.targetspath.set( "/data/CCBR_Pipeliner/db/PipeDB/lib/SureSelect_mm10.bed") targetsE.grid(row=5,column=1,columnspan=6,sticky=W,padx=10,pady=5) self.targetspath.trace('w', lambda a,b,c,x="targetspath":self.makejson(x)) label = Label (eframe, text = "By default, the path to the Agilent V5+UTR targets file is filled in here" ) label.grid(row=6, column=0, columnspan=5, sticky=W, padx=10, pady=5) def option_controller( self, *args, **kwargs ) : PipelineFrame.option_controller( self ) if self.Pipeline.get() == 'exomeseq-somatic' : self.add_pairs( self.eframe ) #self.dry_button.config( state="disabled" ) elif self.Pipeline.get() != 'exomeseq-somatic' : self.del_pairs( self.eframe ) #if self.workpath.get() : # self.dry_button.config( state='active' ) def add_pairs( self, parent ) : if not self.pairs : self.pairs = LabelFrame(parent, text='Pairs') self.pairs_text = Text( self.pairs, width=50, height=8, #bg=projectBgColor, #fg=projectFgColor, font=("nimbus mono bold","11") ) self.pairs_save_button = Button(self.pairs, text="Save", command = self.writepair ) self.pairs_load_button = Button(self.pairs, text="Load", command = self.readpair ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) self.pairs_load_button.grid( row=5, column=5, padx=10, pady=5 ) self.pairs_save_button.grid( row=5, column=6, padx=10, pady=5 ) self.pairs_text.grid( row=1, rowspan=3, column=1, columnspan=7, padx=5, pady=5 ) self.pairs.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 ) def del_pairs( self, parent ) : if self.pairs : self.pairs.grid_forget() def writepair( self ) : self.writepaste( 'pairs', self.pairs_text ) #self.dry_button.config( state='active' ) def readpair( self ) : self.readpaste( 'pairs', self.pairs_text )
class MiRSeqFrame( PipelineFrame ) : def __init__(self, pipepanel, pipeline_name, *args, **kwargs) : PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs) self.info = None eframe = self.eframe = LabelFrame(self,text="Options") #,fg=textLightColor,bg=baseColor) eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 ) label = Label(eframe,text="Pipeline")#,fg=textLightColor,bg=baseColor) label.grid(row=3,column=0,sticky=W,padx=10,pady=5) Pipelines=["CAPmirseq-plus"] Pipeline = self.Pipeline = StringVar() Pipeline.set(Pipelines[0]) om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller) om.config()#bg = widgetBgColor,fg=widgetFgColor) om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor) #om.pack(side=LEFT,padx=20,pady=5) om.grid(row=3,column=1,sticky=W,padx=10,pady=5) self.add_info( eframe ) def add_info( self, parent ) : if not self.info : self.info = LabelFrame(parent, text="Sample Information") self.groups_button = Button(self.info, text="Set Groups", command = self.popup_groups ) self.contrasts_button = Button(self.info, text="Set Contrasts", command = self.popup_contrasts ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) self.groups_button.grid( row=5, column=5, padx=10, pady=5 ) self.contrasts_button.grid( row=5, column=6, padx=10, pady=5 ) self.info.grid(row=10,column=0, columnspan=6, sticky=W, padx=20, pady=10 ) def popup_groups( self ) : self.popup_window( "Groups Information", "groups.tab" ) def popup_contrasts( self ) : self.popup_window( "Contrasts Information", "contrasts.tab" ) def popup_window( self, text, filename ) : top = Toplevel() info = LabelFrame(top, text=text )#"Group Information") info_text = Text(info, width=50, height=8, #bg=projectBgColor, #fg=projectFgColor, font=("nimbus mono bold","11") ) def savefunc() : self.writepaste( filename, info_text ) def loadfunc() : self.readpaste( filename, info_text ) info_save_button = Button(info, text="Save", command = savefunc ) info_load_button = Button(info, text="Load", command = loadfunc ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) info_load_button.grid( row=5, column=5, padx=10, pady=5 ) info_save_button.grid( row=5, column=6, padx=10, pady=5 ) info_text.grid(row=1, rowspan=3, column=1, columnspan=7, padx=5, pady=5 ) info.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 ) top.focus_force() def makejson(self, *args): #print(args[0]) caller=args[0] #global PD #global UnitsBak #global RGbak D=dict() try: F=open(self.workpath.get()+"/samples","r") f=F.read().split("\n") F.close() for line in f: L=line.split() a=L.pop(0) D[a]=L samples=D except: samples={"na":"na"} D=dict() try: F=open(self.workpath.get()+"/pairs","r") f=F.read().split() F.close() for i in range(0,len(f),2): # a=f[i].split(".")[0] # b=f[i+1].split(".")[0] a=f[i] b=f[i+1] D[a+"+"+b]=[a,b] pairs=D except: pairs={"na":"na"} D=dict() try: F=open(self.workpath.get()+"/contrasts.tab","r") # f=F.read().split('\n') # F.close() # D["rsamps"]=f[0].split() # D["rgroups"]=f[1].split() # D["rcontrasts"]=f[2].split() # D["rlabels"]=f[3].split() f=F.readlines() F.close() ## sampl=[] ## grp=[] cont=[] ## lbl=[] for x in f: if len(x.split()) == 2: cont.append(x.split()[0]) cont.append(x.split()[1]) D["rcontrasts"]=cont # contrasts["rcontrasts"]=cont contrasts=D except: contrasts={"rcontrasts":"na"} ## contrasts={"rsamps":"na","rgroups":"na","rcontrasts":"na","rlabels":"na"} ##------ D=dict() try: F=open(self.workpath.get()+"/groups.tab","r") f=F.readlines() F.close() sampl=[] grp=[] # cont=[] lbl=[] for x in f: # if len(x.split()) == 4 or len(x.split()) == 3: if len(x.split()) == 3: sampl.append(x.split()[0]) grp.append(x.split()[1]) lbl.append(x.split()[2]) D["rsamps"]=sampl D["rgroups"]=grp D["rlabels"]=lbl # D["rcontrasts"]="na" # contrasts=D groups=D except: # contrasts={"rsamps":"na","rgroups":"na","rcontrasts":"na","rlabels":"na"} groups={"rsamps":"na","rgroups":"na","rlabels":"na"} ##------ D=dict() FT = filetype#.get() # p = Popen("ls "+workpath.get()+"/*."+FT, shell=True, stdin=PIPE, stdout=PIPE, stderr=DEVNULL, close_fds=True) p = Popen("find "+self.workpath.get()+" -maxdepth 1 -type l -printf '%f\n' ", shell=True, stdin=PIPE, stdout=PIPE, stderr=DEVNULL, close_fds=True) a = p.stdout.read().decode(encoding='UTF-8').split("\n") RG=dict() b=a.pop() # tkinter.messagebox.showerror("",a) # if freezeunits.get()=="no": for i in a: key=re.sub(".realign","",i.split("/")[-1]) key=re.sub(".bai","",key) key=re.sub(".bam","",key) key=re.sub(".sam","",key) key=re.sub(".recal","",key) key=re.sub(".dedup","",key) key=re.sub(".sorted","",key) key=re.sub(".fin","",key) key=re.sub(".R[12]","",key) key=re.sub("_R[12]","",key) key=re.sub(".fastq","",key) key=re.sub(".gz","",key) # key=re.sub("[\._](R[12]\.)*"+FT+"$","",i.split("/")[-1]) # key=re.sub(".R[12]."+FT+"$","",i.split("/")[-1]) # key=re.sub("([._]R[12][._])*([fin|sorted|dedup|recal|realign])*\.{0}$".format(FT),"",i.split("/")[-1]) D[key]=key RG[key]={'rgsm':key,'rglb':'na','rgpu':'na','rgpl':'ILLUMINA','rgcn':'na'} units=D UnitsBak=D try: F=open(self.workpath.get()+"/rg.tab","r") f=F.read().splitlines() F.close() for theLine in f: if not re.match("^ID",theLine): (rgid,rgsm,rglb,rgpl,rgpu,rgcn)=theLine.split("\t") RG[rgid]={'rgsm':rgsm,'rglb':rglb,'rgpu':rgpu,'rgpl':rgpl,'rgcn':rgcn} except: pass RGbak=RG # else: # units=UnitsBak # RG=RGbak # PD=dict() smparams=[] for i in range(len(self.parameters)): if cp[i].var.get()=="1": smparams.append(parameters[i]) AD=eval( open( join(PIPELINER_HOME, self.annotation.get()+".json" ), "r" ).read() ) SD=AD['references']['rnaseq']['STARDIR'] # tkinter.messagebox.showinfo("initLock","SD={0}".format(SD)) gi = self.global_info PD={ 'project': { 'pfamily': gi.pfamily.get(), 'units': units, 'samples': samples, 'pairs': pairs, 'id': gi.eprojectid.get(), 'pi': gi.epi.get(), 'organism': gi.eorganism.get(), 'analyst': gi.eanalyst.get(), 'poc': gi.epoc.get(), 'pipeline': self.Pipeline.get(), 'version':"1.0", 'annotation': gi.annotation.get(), 'datapath': self.datapath.get(), 'targetspath': self.targetspath.get(), 'filetype': filetype , 'binset': "standard-bin", 'username': gi.euser.get(), 'flowcellid': gi.eflowcell.get(), 'platform': gi.eplatform.get(), 'custom': customRules, 'efiletype': efiletype, 'workpath': self.workpath.get(), 'batchsize': batchsize, "smparams": smparams, "rgid": RG, "cluster": "cluster_medium.json", "description": gi.description.get('1.0',END), "technique" : gi.technique.get(), "TRIM": "yes", "groups": groups, "contrasts": contrasts, } } J=json.dumps(PD, sort_keys = True, indent = 4, ensure_ascii=True) gi.jsonconf.delete("1.0", END) gi.jsonconf.insert(INSERT, J) self.saveproject(gi.jsonconf.get("1.0",END))
def popup_window_contrast(self) : text = "Comparing ChIP-seq Peaks" contrast_fn = join(self.workpath.get(),self.contrast_fn) peakinfo_fn = join(self.workpath.get(),self.peakinfo_fn) NA='N/A' try : groups = list(set([l.split('\t')[-1].strip() for l in open(peakinfo_fn) if l.split('\t')[-1].strip()])) if len(groups) < 2 : showwarning( 'WARNING!', "More than one groups need to be fefined in Peak Information File!" ) print( 'groups:', groups ) return except IOError : showerror( 'Error', "Did you set peak information?" ) print('Error:', 'Cannot process peakcall.tab file:') return top = Toplevel() info = LabelFrame(top, text=text )#"Group Information") print( groups ) contrast_vars = [] contrast_menus = [] n = 0 groups.insert(0, NA) for i in range( int((len(groups)-1)*(len(groups)-2)/2) ): n = n + 1 v1, v2 = StringVar(), StringVar() contrast_vars.append( [v1, v2] ) o1, o2 = OptionMenu(info, v1, *groups), OptionMenu(info, v2, *groups) contrast_menus.append( [o1, o2] ) v1.set(NA) v2.set(NA) vslabel = Label(info, text=" VS ") o1.grid( row=n, column=0, padx=4, pady=1 ) o2.grid( row=n, column=2, padx=4, pady=1 ) vslabel.grid( row=n, column=1, padx=4, pady=1 ) def savefunc() : info_text = StringIO() for v1, v2 in contrast_vars : v1 = v1.get() if v1.get() != NA else "" v2 = v2.get() if v2.get() != NA else "" if v1 and v2 : pass elif v1 or v2 : showerror( 'Error', "None or Both columns should be selected!" ) return else: continue print( v1, v2, file=info_text, sep="\t" ) fp = open( contrast_fn, 'w' ) fp.write( info_text.getvalue() ) fp.close() def loadfunc() : #self.readpaste( filename, info_text ) for i, l in enumerate(open( contrast_fn )) : v1, v2 = l.split('\t') v1 = v1.strip() v2 = v2.strip() if v1 : try : assert v1 in groups except : showwarning('WARNING', 'Group name is not in the selection list!' ) print( 'v1:',v1 ) print( 'group:', groups ) continue if v2 : try: assert v2 in groups except : showwarning('WARNING', 'Group name is not in the selection list!' ) print( 'v2:',v2 ) print( 'group:', groups ) continue contrast_vars[i][0].set(v1) contrast_vars[i][1].set(v2) def clearfunc() : for v1, v2 in contrast_vars : v1.set(NA) v2.set(NA) info_clear_button = Button(top, text="Clear", command = clearfunc ) info_save_button = Button(top, text="Save", command = savefunc ) info_load_button = Button(top, text="Load", command = loadfunc ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) info_clear_button.grid( row=5, column=3, padx=10, pady=5 ) info_load_button.grid( row=5, column=4, padx=10, pady=5 ) info_save_button.grid( row=5, column=5, padx=10, pady=5 ) info.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 ) top.focus_force()
def popup_window_peakinfo( self, text, filename ) : NA = 'N/A' selections = [fn.split('.R1.fastq.gz')[0] for fn in self.datafiles if fn.endswith( ".R1.fastq.gz" )] ################################ #check availablity of the files before moving on! if not selections : showerror( "No FASTQ files available matching the pattern *.R1.fastq.gz" ) return ################################ selections.insert(0, NA) #Adding N/A for the groups where no input is available groups = ['Grp%d'%i for i in range(1, len(selections)+1)] ##checking for debugging purpose print( selections ) assert len(selections) == len(set(selections)) ## top = Toplevel() info = LabelFrame(top, text=text )#"Group Information") chip_vars = [ StringVar() for s in selections[1:] ] input_vars = [ StringVar() for s in selections[1:] ] group_vars = [ StringVar() for s in selections[1:] ] chip_menus = [OptionMenu(info,var,*selections) for var in chip_vars] input_menus = [OptionMenu(info,var,*selections) for var in input_vars] group_menus = [OptionMenu(info,var,*groups) for var in group_vars] group_entries = [Entry(info, bd=2, width=8, textvariable=var) for var in group_vars] chiplabel = Label(info, text= "ChIP Names") inputlabel = Label(info, text="Input Names") grouplabel = Label(info, text="Group Names") chiplabel.grid( row = 0, column = 1, padx=4, pady=1) inputlabel.grid( row = 0, column = 2, padx=4, pady=1) grouplabel.grid( row = 0, column = 3, padx=4, pady=1 ) for i, (chvar, invar) in enumerate(zip(chip_vars, input_vars)) : chvar.set(selections[0]) invar.set(selections[0]) chip_menus[i].grid( row = i+1, column = 1, padx=4, pady=1 ) input_menus[i].grid( row = i+1, column = 2, padx=4, pady=1 ) group_entries[i].grid( row = i+1, column = 3, padx=4, pady=1 ) group_menus[i].grid( row = i+1, column = 4, padx=4, pady=1 ) def savefunc() : info_text = StringIO() for v1, v2, v3 in zip( chip_vars, input_vars, group_vars ) : v1 = v1.get().strip() if v1.get().strip() != NA else "" if not v1 : continue v2 = v2.get().strip() if v2.get().strip() != NA else "" v3 = v3.get().strip() if v3.get().strip() != NA else "" if not v3 : showerror( "Error", "Missing Replicate group name detected.\nReplicate group names should be given!" ) print( "Error", "Missing Replicate group name detected.\nReplicate group names should be given!" ) return print( v1, v2, v3, file=info_text, sep="\t" ) fp = open( filename, 'w' ) fp.write( info_text.getvalue() ) fp.close() def loadfunc() : if not exists(filename) : print( filename, 'does not exists!' ) return for i, l in enumerate(open( filename )) : v1, v2, v3 = l.split('\t') if v1 : try : assert v1 in selections except : showwarning('WARNING', 'ChIP name is not in the selection list!' ) print( 'v1:',v1 ) print( 'selection:', selection ) continue if v2 : try: assert v2 in selections except : showwarning('WARNING', 'Input name is not in the selection list!' ) print( 'v2:',v2 ) print( 'selection:', selection ) return chip_vars[i].set(v1.strip()) input_vars[i].set(v2.strip()) group_vars[i].set(v3.strip()) def clearfunc() : for i, (chvar, invar, grvar) in enumerate(zip(chip_vars, input_vars, group_vars)) : chvar.set(selections[0]) invar.set(selections[0]) grvar.set('') info_clear_button = Button(top, text="Clear", command = clearfunc ) info_save_button = Button(top, text="Save", command = savefunc ) info_load_button = Button(top, text="Load", command = loadfunc ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) info_clear_button.grid( row=5, column=3, padx=10, pady=5 ) info_load_button.grid( row=5, column=4, padx=10, pady=5 ) info_save_button.grid( row=5, column=5, padx=10, pady=5 ) info.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 ) top.focus_force()
class MarkovDemo(Frame): "MarkovDemo(master=None, **kw) -> MarkovDemo instance" TEXT = dict(height=2, width=46, wrap=WORD) # Text Options GRID = dict(padx=5, pady=5) # Grid Options # Initialize a MarkovDemo instance with a GUI for interaction. def __init__(self, master=None, **kw): "Initialize the MarkovDemo instance's widgets and settings." super().__init__(master, **kw) self.build_widgets() self.place_widgets() self.setup_widgets() self.grid_rowconfigure(2, weight=1) self.grid_rowconfigure(3, weight=1) self.grid_columnconfigure(0, weight=1) self.key = self.primer = None def build_widgets(self): "Build the various widgets that will be used in the program." # Create processing frame widgets. self.processing_frame = LabelFrame(self, text='Processing Mode:') self.mode_var = StringVar(self, 'encode') self.decode_button = Radiobutton(self.processing_frame, text='Decode Cipher-Text', command=self.handle_radiobuttons, value='decode', variable=self.mode_var) self.encode_button = Radiobutton(self.processing_frame, text='Encode Plain-Text', command=self.handle_radiobuttons, value='encode', variable=self.mode_var) self.freeze_var = BooleanVar(self, False) self.freeze_button = Checkbutton(self.processing_frame, text='Freeze Key & Primer', command=self.handle_checkbutton, offvalue=False, onvalue=True, variable=self.freeze_var) # Create encoding frame widgets. self.encoding_frame = LabelFrame(self, text='Encoding Options:') self.chain_size_label = Label(self.encoding_frame, text='Chain Size:') self.chain_size_entry = Entry(self.encoding_frame) self.plain_text_label = Label(self.encoding_frame, text='Plain-Text:') self.plain_text_entry = Entry(self.encoding_frame) # Create input frame widgets. self.input_frame = LabelFrame(self, text='Input Area:') self.input_text = ScrolledText(self.input_frame, **self.TEXT) # Create output frame widgets. self.output_frame = LabelFrame(self, text='Output Area:') self.output_text = ScrolledText(self.output_frame, **self.TEXT) def place_widgets(self): "Place the widgets where they belong in the MarkovDemo frame." # Locate processing frame widgets. self.processing_frame.grid(sticky=EW, **self.GRID) self.decode_button.grid(row=0, column=0, **self.GRID) self.encode_button.grid(row=0, column=1, **self.GRID) self.freeze_button.grid(row=0, column=2, **self.GRID) # Locate encoding frame widgets. self.encoding_frame.grid(sticky=EW, **self.GRID) self.chain_size_label.grid(row=0, column=0, sticky=W, **self.GRID) self.chain_size_entry.grid(row=0, column=1, sticky=EW, **self.GRID) self.plain_text_label.grid(row=1, column=0, sticky=W, **self.GRID) self.plain_text_entry.grid(row=1, column=1, sticky=EW, **self.GRID) self.encoding_frame.grid_columnconfigure(1, weight=1) # Locate input frame widgets. self.input_frame.grid(sticky=NSEW, **self.GRID) self.input_text.grid(sticky=NSEW, **self.GRID) self.input_frame.grid_rowconfigure(0, weight=1) self.input_frame.grid_columnconfigure(0, weight=1) # Locate output frame widgets. self.output_frame.grid(sticky=NSEW, **self.GRID) self.output_text.grid(sticky=NSEW, **self.GRID) self.output_frame.grid_rowconfigure(0, weight=1) self.output_frame.grid_columnconfigure(0, weight=1) def setup_widgets(self): "Setup each widget's configuration for the events they handle." self.input_text.bind('<Key>', self.handle_key_events) self.input_text.bind('<Control-Key-a>', self.handle_control_a) self.input_text.bind('<Control-Key-/>', lambda event: 'break') self.output_text['state'] = DISABLED self.output_text.bind('<Control-Key-a>', self.handle_control_a) self.output_text.bind('<Control-Key-/>', lambda event: 'break') ######################################################################## # Take care of any special event needing dedicated processing. def handle_radiobuttons(self): "Change the interface based on the encoding / decoding setting." if self.encrypting: self.freeze_button.grid() if not self.freeze_var.get(): self.encoding_frame.grid() else: self.freeze_button.grid_remove() if not self.freeze_var.get(): self.encoding_frame.grid_remove() self.handle_key_events(None) def handle_checkbutton(self): "Change the interface based on the key / primer freeze setting." if self.freeze_var.get(): self.encoding_frame.grid_remove() else: self.encoding_frame.grid() def handle_key_events(self, event): "Schedule refreshing the output area after an input area event." if event is None or event.char and event.state | 0o11 == 0o11: self.after_idle(self.refresh) @staticmethod def handle_control_a(event): "Select all text in the widget associated with the given event." event.widget.tag_add(SEL, 1.0, END + '-1c') return 'break' ######################################################################## # Handle interface's updates when either encoding or decoding. def refresh(self): "Refresh the output based on the value of the input." text = self.input_text.get(1.0, END + '-1c') if not text: self.output = text elif self.encrypting: self.encode(text) else: self.decode(text) def output(self, value): "Set the text in the output area to the string value." self.output_text['state'] = NORMAL self.output_text.delete(1.0, END) self.output_text.insert(END, value) if self.encrypting and self.freeze_var.get(): self.output_text.see(END) self.output_text['state'] = DISABLED output = property(fset=output, doc='Output area property.') @property def chain_size(self): "Chain size for the Markov chains used when encrypting." try: value = ast.literal_eval(self.chain_size_entry.get()) assert isinstance(value, int) and 2 <= value <= 256 return value except: self.chain_size_entry.delete(0, END) self.chain_size_entry.insert(0, '2') return 2 @property def plain_text(self): "Plain text or ignored characters in encryption process." try: value = self.repr_to_obj(self.plain_text_entry.get(), '') assert isinstance(value, str) return value except: self.plain_text_entry.delete(0, END) return '' ######################################################################## # Encrypt a string for display in the interface's output area. def encode(self, string): "Encode the string and show the cipher-text in the output." try: cipher = self.build_cipher(string) except ValueError: self.output = '' except: self.output = traceback.format_exc() else: self.output = self.build_header() + '\n\n' + cipher def build_cipher(self, string): "Build cipher-text based on plain-text and return answer." if self.key and self.freeze_var.get(): cipher, primer = me.encrypt_str(string, self.key, self.primer) else: args = string, self.chain_size, self.plain_text cipher, self.key, self.primer = me.auto_encrypt_str(*args) return cipher def build_header(self): "Build header from key and primer values in current use." header = '\n'.join(map(self.bytes_to_repr, self.key.data)) header += '\n' + self.bytes_to_repr(self.primer.data) return header ######################################################################## # Decrypt a string for display in the interface's output area. def decode(self, string): "Decode encrypted message and display plain-text in output." try: cipher = self.extract_keys(string) text = self.extract_text(cipher) except ValueError: self.output = '' except: self.output = traceback.format_exc() else: self.output = text def extract_keys(self, string): "Extract keys to decryption and return the cipher-text area." header, cipher = string.split('\n\n', 1) *key, primer = map(self.repr_to_obj, header.split('\n')) self.key, self.primer = me.Key(tuple(key)), me.Primer(primer) return cipher def extract_text(self, string): "Extract text message from string using built key and primer." text, primer = me.decrypt_str(string, self.key, self.primer) return text ######################################################################## # Provide some special methods to simplify the program's code. @property def encrypting(self): "Encrypting boolean stating current operations mode." return {'encode': True, 'decode': False}[self.mode_var.get()] @staticmethod def bytes_to_repr(obj): "Convert bytes object into suitable representation." if not isinstance(obj, bytes): raise TypeError('Object must be a bytes instance!') return repr(obj)[2:-1] @staticmethod def repr_to_obj(string, prefix='b'): "Convert representation into an equivalent object." for template in '{}"{}"', "{}'{}'": try: return ast.literal_eval(template.format(prefix, string)) except: pass raise ValueError('Cannot convert {!r} to object!'.format(string)) @classmethod def main(cls): "Create context for demo and run a test instance." NoDefaultRoot() root = Tk() root.minsize(420, 330) root.title('Markov Demo 2') test = cls(root) test.grid(sticky=NSEW) root.grid_rowconfigure(0, weight=1) root.grid_columnconfigure(0, weight=1) root.mainloop()
def __init__(self,parent, padX, padY): LabelFrame.__init__(self,parent,borderwidth=0) # Total volume self.totalEstimatedVolume_L = Label(self,text="Estimated total volume (km\u00B3): ") self.totalEstimatedVolume_E = CustomEntry(self,width=10,justify="right") self.totalEstimatedVolume_E.setUserEditable(False) self.totalEstimatedVolume_E.grid(row=0,column=1,padx=10,pady=padY,sticky="E") self.totalEstimatedVolume_L.grid(row=0,column=0,sticky="W",padx=10) # Relative squared error self.relativeSquaredError_L = Label(self,text="Mean relative squared error: ") self.relativeSquaredError_L.grid(row=1,column=0,sticky="W",padx=10,pady=padY) self.relativeSquaredError_E = CustomEntry(self,width=10,justify="right") self.relativeSquaredError_E.grid(row=1,column=1,padx=10,sticky="E") self.relativeSquaredError_E.setUserEditable(False) # Equation self.equation_L = Label(self,text="Equation: ") self.equation_E = CustomEntry(self,width=10,justify="right") self.equation_E.setUserEditable(False) # General self.parameters_L = Label(self,text="Parameters:") self.calculate_B = Button(self,text="Recalculate",width=12) self.reset_B = Button(self,text="Reset",width=8) ######### ## Exp ## ######### # Segment combobox self.expSeg_CB = Combobox(self,state="readonly",width=10) # Segment volume self.expSegVolume_L = Label(self,text="Segment volume (km\u00B3): ") self.expSegVolume_E = CustomEntry(self, width=10, justify="right") self.expSegVolume_E.setUserEditable(False) # Segment start self.expSegStartLimit_L = Label(self,text="Start of segment: ") self.expSegStartLimit_E = NumericEntry(self, width=10, justify="right") self.expSegStartLimit_E.setSF(NUMBER_OF_SF) # Segment end self.expSegEndLimit_L = Label(self,text="End of segment: ") self.expSegEndLimit_E = NumericEntry(self, width=10, justify="right") self.expSegEndLimit_E.setSF(NUMBER_OF_SF) # Segment coefficient self.expSegCoefficent_L = Label(self,text="Segment coefficient, c: ") self.expSegCoefficent_E = NumericEntry(self, width=10, justify="right") self.expSegCoefficent_E.setSF(NUMBER_OF_SF) # Segment exponent self.expSegExponent_L = Label(self,text="Segment exponent, m: ") self.expSegExponent_E = NumericEntry(self, width=10, justify="right") self.expSegExponent_E.setSF(NUMBER_OF_SF) ######### ## Pow ## ######### # Coefficient self.powCoefficient_L = Label(self,text="Coefficient, c: ") self.powCoefficient_E = NumericEntry(self,width=10, justify="right") self.powCoefficient_E.setSF(NUMBER_OF_SF) # Exponent self.powExponent_L = Label(self,text="Exponent, m: ") self.powExponent_E = NumericEntry(self,width=10, justify="right") self.powExponent_E.setSF(NUMBER_OF_SF) # Proximal limit self.powProximalLimit_L = Label(self,text="Proximal limit: ") self.powProximalLimit_E = NumericEntry(self,width=10, justify="right") self.powProximalLimit_E.setSF(NUMBER_OF_SF) # Distal limit self.powDistalLimit_L = Label(self,text="Distal limit: ") self.powDistalLimit_E = NumericEntry(self,width=10, justify="right") self.powDistalLimit_E.setSF(NUMBER_OF_SF) # Suggested proximal limit self.powSuggestedProximalLimit_L = Label(self,text="Suggested proximal limit: ") self.powSuggestedProximalLimit_E = CustomEntry(self,width=10, justify="right") self.powSuggestedProximalLimit_E.setUserEditable(False) ######### ## Wei ## ######### # lambda self.weiLambdaL = Label(self,text="Estimated \u03BB: ") self.weiLambdaE = NumericEntry(self,width=10, justify="right") self.weiLambdaE.setSF(NUMBER_OF_SF) # k self.weiKL = Label(self,text="Estimated k: ") self.weiKE = NumericEntry(self,width=10, justify="right") self.weiKE.setSF(NUMBER_OF_SF) # theta self.weiThetaL = Label(self,text="Estimated \u03B8: ") self.weiThetaE = NumericEntry(self,width=10, justify="right") self.weiThetaE.setSF(NUMBER_OF_SF) self.components = { Model.EXP : [ self.expSeg_CB, self.expSegVolume_L, self.expSegVolume_E, self.expSegStartLimit_L, self.expSegStartLimit_E, self.expSegEndLimit_L, self.expSegEndLimit_E, self.expSegCoefficent_L, self.expSegCoefficent_E, self.expSegExponent_L, self.expSegExponent_E ], Model.POW : [ self.powCoefficient_L, self.powCoefficient_E, self.powExponent_L, self.powExponent_E, self.powProximalLimit_L, self.powProximalLimit_E, self.powDistalLimit_L, self.powDistalLimit_E, self.powSuggestedProximalLimit_L, self.powSuggestedProximalLimit_E ], Model.WEI : [ self.weiLambdaL, self.weiLambdaE, self.weiKL, self.weiKE, self.weiThetaL, self.weiThetaE, ], }
class ChIPSeqFrame( PipelineFrame ) : def __init__(self, pipepanel, pipeline_name, *args, **kwargs) : PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs) self.info = None eframe = self.eframe = LabelFrame(self,text="Options") #,fg=textLightColor,bg=baseColor) eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 ) label = Label(eframe,text="Pipeline")#,fg=textLightColor,bg=baseColor) label.grid(row=3,column=0,sticky=W,padx=10,pady=5) Pipelines=["ChIPSeq"] Pipeline = self.Pipeline = StringVar() Pipeline.set(Pipelines[0]) om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller) om.config()#bg = widgetBgColor,fg=widgetFgColor) om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor) #om.pack(side=LEFT,padx=20,pady=5) om.grid(row=3,column=1,sticky=W,padx=10,pady=5) label.grid(row=6, column=0, columnspan=5, sticky=W, padx=10, pady=5) self.add_info(eframe) ''' def set_data_directory( self ): fname = askdirectory( initialdir = USER_HOME, title="Select Data Directory") self.datapath.set(fname) #count number self.data_count['text'] = str( len([fn for fn in listdir(fname) if fn.endswith(filetype) or fn.endswith('.fastq')] ) ) print( "Found", self.data_count['text'], filetype, "files!" ) ''' def add_info( self, parent ) : if not self.info : self.info = LabelFrame(parent, text='Peak Call Info') self.info_text = Text( self.info, width=50, height=8, #bg=projectBgColor, #fg=projectFgColor, font=("nimbus mono bold","11") ) self.info_save_button = Button(self.info, text="Save", command = self.writeinfo ) self.info_load_button = Button(self.info, text="Load", command = self.readinfo ) #self.pairs_load_button.pack( side=BOTTOM, padx=5, pady=5 ) #self.pairs_save_button.pack( side=BOTTOM, padx=5, pady=5 ) self.info_load_button.grid( row=5, column=5, padx=10, pady=5 ) self.info_save_button.grid( row=5, column=6, padx=10, pady=5 ) self.info_text.grid( row=1, rowspan=3, column=1, columnspan=7, padx=5, pady=5 ) self.info.grid(row=7,column=0, columnspan=6, sticky=W, padx=20, pady=10 ) def writeinfo( self ) : self.writepaste( 'peakcallinfo.csv', self.info_text ) def readinfo( self ) : self.readpaste( 'peakcallinfo.csv', self.info_text )