def __init__(self, parent, ft_value, title=None, format=None, readonly=0, width=9): self.width = width ViewFrame.__init__(self, parent) if format: self.format = format ft_value.add_view(self) if not title: title = ft_value.label if title: title = capitalize(title) + ":" if title: lbl = entry_label(self, title) else: lbl = None ent = self.entry = Entry(self, width=width, background='white') ent.sticky = 'e' if readonly: ent.configure(state='disabled', relief='flat') else: # Set up mechanism to be notified when the user enters something self.var = StringVar() self.var.trace("w", self.entry_changed) ent.configure(textvariable=self.var) self.columnconfigure(0, weight=1) grid([lbl, ent]) self.update()
def __init__(self, parent, ft_parameter): ViewFrame.__init__(self, parent) ft_parameter.add_view(self) self.flag_var = IntVar() self.flag_var.trace('w', self.flag_changed) cbf = Checkbutton(self, text=ft_parameter.label + ":", font=Layout.params.entry_label_font, variable=self.flag_var) cbf.sticky = 'w' eiv = self.init_value_view = \ NumberView(self, ft_parameter.initial_value, format="unlimited") eiv.sticky = 'ew' muv = Units.UnitView(self, ft_parameter.unit) bfb = Button(self, text="<<", padx=0, pady=1, command=self.feed_back) efv = self.fitted_value_box = \ NumberView(self, ft_parameter.fitted_value, readonly = 1) ese = self.std_err_box = \ NumberView(self, ft_parameter.standard_error, readonly = 1) self.columnconfigure(0, minsize=90) # check box self.columnconfigure(2, minsize=25) # measurement unit self.columnconfigure(3, minsize=30) # feedback button self.columnconfigure( 5, minsize=14) # space between fitted value & stderror grid([cbf, eiv, muv, bfb, efv, 0, ese]) self.update()
def __init__(self, parent, experiment_number): Frame.__init__(self, parent, borderwidth=0) self.parent = parent self.experiment_number = experiment_number self.cur_files = parent.project.get_data_files(experiment_number)[:] title = self.titles[experiment_number] head = group_label(self, title) lbox = self.listbox = make_listbox(self, height=8) badd = Button(self, text=">>", command=self.add) brmv = Button(self, text="<<", command=self.remove) grid([0, head], [badd, lbox], [brmv, lbox]) self.update_listbox()
def __init__(self, parent, double_click=None, **args): Frame.__init__(self, parent) box = self.listbox = Listbox(self) box.configure(args) bar = self.vscrollbar = Scrollbar(self, orient='v', command=box.yview) box.configure(yscrollcommand=bar.set) bar.sticky = 'ns' grid([box, bar]) if double_click: box.bind("<Double-Button-1>", double_click) self.insert = box.insert self.delete = box.delete self.get = box.get self.curselection = box.curselection
def __init__(self, parent, feed_back_all): Frame.__init__(self, parent, borderwidth=2) self.sticky = 'w' l0 = column_label(self, "Fit?") l1 = column_label(self, "Initial Value") l2 = column_label(self, "Fitted Value") l3 = column_label(self, "Std. Error") bf = Button(self, text="<<", padx=0, pady=1, command=feed_back_all) self.columnconfigure(0, minsize=90) self.columnconfigure( 1, minsize=Layout.params.param_view_header_column1_width) self.columnconfigure(2, minsize=30) self.columnconfigure( 3, minsize=Layout.params.param_view_header_column3_width) grid([l0, l1, bf, l2, l3])
def __init__(self, experiment_view): ViewFrame.__init__(self, experiment_view) self.voltage_unit_view = None self.current_unit_view = None self.selection_bars = [] self.fitting_toggles = [] self.number_displays = [] canv = self.canvas = Canvas(self, width=self.width, height=self.height, background='white') sbar = Scrollbar(self, orient='v', command=canv.yview) sbar.sticky = 'ns' canv.configure(yscrollcommand=sbar.set) grid([canv, sbar])
def __init__(self, owner, init_nh, init_nnonh): Toplevel.__init__(self) self.owner = owner self.wm_title("NEUROFIT - Channel Parameters") self.wm_transient(owner) self.wm_geometry("+%d+%d" % (owner.winfo_x() + 30, owner.winfo_y() + 30)) lnh = entry_label(self, text = "No. of inactivating channel groups:") inh = self.nh_box = NumberEntry(self, initial = init_nh) lnn = entry_label(self, text = "No.of non-inactivating channel groups:") inn = self.nnonh_box = NumberEntry(self, initial = init_nnonh) bok = Button(self, text = "OK", command = self.ok) bca = Button(self, text = "Cancel", command = self.cancel) grid([lnh, inh], [lnn, inn], [bok, bca])
def __init__(self, owner, project): Toplevel.__init__(self) self.wm_title("NF: Data Files") self.owner = owner self.project = project self.filtering = IntVar(self) self.filtering.set(1) self.filtering.trace('w', self.filtering_changed) #head = group_label(self, "Select Data Files:") mbcwd = self.dir_menubutton = \ Menubutton(self, relief = 'raised', indicatoron = 1) self.dir_menu = Menu(mbcwd, tearoff=0) mbcwd.configure(menu=self.dir_menu) lbdir = self.dir_listbox = \ make_listbox(self, height = 20, double_click = self.open_dir) sfex0 = SelectedFilesBox(self, 0) sfex0.sticky = 'n' sfex1 = SelectedFilesBox(self, 1) sfex1.sticky = 's' self.selected_files_boxes = [sfex0, sfex1] ffilt = Frame(self) ffilt.sticky = 'w' rall = Radiobutton(ffilt, text="All Files", variable=self.filtering, value=0) patterns = ["*" + suf for suf in self.suffixes] rfilt = Radiobutton(ffilt, text=string.join(patterns, ", "), variable=self.filtering, value=1) grid([rall, rfilt]) bok = Button(self, text="OK", command=self.ok) bcan = Button(self, text="Cancel", command=self.cancel) grid([mbcwd, 0], [lbdir, sfex0], [lbdir, sfex1], [ffilt, ffilt], [bok, bcan]) if DataFileSelector.last_cwd is not None: self.set_cwd(DataFileSelector.last_cwd) else: self.set_cwd(os.getcwd())
def __init__(self, parent, project): ViewFrame.__init__(self, parent) project.add_view(self) # Parameters frame fpa = Frame(self, borderwidth = 5) fpa.sticky = 'ns' # Model Specifications frame fmp = Frame(fpa) fmp.sticky = 'w' lmp = group_label(fmp, text = "Model Specifications") lnh = entry_label(fmp, text = "No. of inactivating channel groups:") inh = self.nh_box = NumberDisplay(fmp, on_click = self.edit_h_params, width = 4) lnn = entry_label(fmp, text = "No.of non-inactivating channel groups:") inn = self.nnonh_box = NumberDisplay(fmp, on_click = self.edit_h_params, width = 4) vp = NumberView(fmp, project.p, title = "No. of independent activation gates:", width = 4) grid([lmp, lmp], [lnh, inh], [lnn, inn], [vp, vp]) # Algorithm Specifications frame fnp = ViewFrame(fpa) fnp.sticky = 'w' lnp = group_label(fnp, text = "Algorithm Specifications") vnd = NumberView(fnp, project.noise_deg, title = "Noise poly degree:", width = 4) vne = NumberView(fnp, project.nevalfac, title = "Max. function evals:", width = 4) # Tolerances frame fto = Frame(fnp) lto = entry_label(fto, text = "Tolerances:") vtf = NumberView(fto, project.tol_f, title = "f") vtx = NumberView(fto, project.tol_x, title = "x") vtg = NumberView(fto, project.tol_g, title = "g") grid([lto, vtf], [0, vtx], [0, vtg]) # Algorithm Specifications frame assembly grid([lnp, 0, 0 ], [vnd, 0, fto], [vne, 0, fto], [0, 0, fto]) fnp.rowconfigure(3, weight = 1) fnp.columnconfigure(1, minsize = 10) # Model Parameters frame ffp = ViewFrame(fpa) ffp.sticky = 'nsew' for i in xrange(3): ffp.columnconfigure(i, weight = 1) lfp = group_label(ffp, "Model Parameters") lfp.sticky = 'nw' bqft_col = '#70E070' bfit_col = '#80FF80' # a slightly yellowish green, not too bright bqft = Button(ffp, text = "Quick Fit", width = 12, background = bqft_col, activebackground = bqft_col, command = project.guess_parameters) bqft.sticky = 's' bfit = Button(ffp, text = "Full Fit", width = 12, background = bfit_col, activebackground = bfit_col, command = project.fit) bfit.sticky = 's' hdr = ParamViewHeader(ffp, self.feed_back_all) tfp = ParamViewBox(ffp, background = self.cget("background")) self.fitting_parm_box = tfp tfp.sticky = 'nsew' sfp = Scrollbar(ffp, orient = 'v', command = tfp.yview) sfp.sticky = 'ns' tfp.configure(yscrollcommand = sfp.set) grid([lfp, bqft, bfit, 0 ], [hdr, hdr, hdr, 0 ], [tfp, tfp, tfp, sfp]) ffp.rowconfigure(2, weight = 1) ffp.rowconfigure(0, minsize = 33) # Parameters frame assembly vbox([fmp, fnp, ffp, ffp]) fpa.rowconfigure(3, weight = 1) # Experiment views frame fxp = Frame(self, borderwidth = 5) vx0 = ExperimentView(fxp, project.experiments[0]) vx1 = ExperimentView(fxp, project.experiments[1]) self.experiment_views = (vx0, vx1) # Fit results frame ffr = ViewFrame(fxp) ffr.sticky = 'w' lfr = group_label(ffr, "Fit Results") vnfev = NumberView(ffr, project.nfev, readonly = 1, width=5) vnjev = NumberView(ffr, project.njev, readonly = 1, width=5) vnpts = NumberView(ffr, project.npts, readonly = 1, width=6) vnfitp = NumberView(ffr, project.nfitp, readonly = 1, width=6) vvar = NumberView(ffr, project.variance, readonly = 1) grid([lfr, 0, 0, 0, 0 ], [vnfev, 0, vnpts, 0, vvar], [vnjev, 0, vnfitp, 0, 0 ]) ffr.columnconfigure(1, minsize = 8) ffr.columnconfigure(3, minsize = 8) # Messages frame fmsg = ViewFrame(fxp) fmsg.sticky = 'ew' lmsg = group_label(fmsg, "Messages") vmsg = self.messages_view = Text( fmsg, width = 70, height = 5, background = 'white', borderwidth = 0, state = 'disabled', wrap = 'word') vmsg.sticky = 'ew' sbmsg = Scrollbar(fmsg, orient = 'v', command = vmsg.yview) sbmsg.sticky = 'ns' vmsg.configure(yscrollcommand = sbmsg.set) grid([lmsg, 0], [vmsg, sbmsg]) fmsg.columnconfigure(0, weight = 1) # Experiment views frame assembly grid([vx0], [vx1], [ffr], [fmsg]) # Final assembly grid([fpa, fxp]) self.fitting_parm_views = [] self.update_h_params()
def __init__(self, parent, experiment): ViewFrame.__init__(self, parent) experiment.add_view(self) self.plot_lines = {} # FtSweep -> LineSet zeros = ((0.0, 0.0), (0.0, 0.0)) self.axis_limits = {'all': zeros, 'step': zeros, 'current': zeros,\ 'custom': None} self.zooming = 0 self.transform = Transform() self.voltage_editor = None # a VoltageEditor head = group_label(self, self.experiment_names[experiment.experiment_number]) # Create canvas to hold the plotting area, graph axes and scales, # and the fit/noise region control handles. gcanv = self.graph_canvas = Canvas(self, width=self.graph_width, height=self.graph_height, background='white') # Create subcanvas to use as the plotting area. Set its coordinate # system to be the same as the graph canvas. pcanv = self.plot_canvas = Canvas( gcanv, width=self.plot_width, height=self.plot_height, scrollregion=(self.left_margin, self.top_margin, self.left_margin + self.plot_width, self.top_margin + self.plot_height), background='white', cursor=self.zoom_cursor, highlightthickness=0) gcanv.create_window(self.left_margin, self.top_margin, window=pcanv, anchor='nw') pcanv.bind('<Button>', self.begin_zoom_rect) pcanv.bind('<Motion>', self.track_zoom_rect) pcanv.bind('<ButtonRelease>', self.end_zoom_rect) pcanv.bind('<Double-Button-1>', self.reset_zoom_step) pcanv.bind('<Double-Button-2>', self.reset_zoom_all) pcanv.bind('<Double-Button-3>', self.reset_zoom_all) pcanv.bind('<Control-Button>', self.define_step_epoch) # Create unit labels vaxis_unit = CanvasUnitView(self, gcanv, experiment.parent.units['Current'], 5, self.plot_centre_y, anchor='w') haxis_unit = CanvasUnitView(self, gcanv, experiment.parent.units['Time'], self.plot_centre_x, self.top_margin + self.plot_height + self.tick_length + 15, anchor='n') # Create region controllers self.make_region_controllers() # Create buttons bvolt = Button(self, text="Voltages...", command=self.open_voltage_editor) baxes = Menubutton(self, text="Zoom", borderwidth=2, relief="raised", indicatoron=1) self.zoom_axes_menu = Menu(baxes, tearoff=0) baxes.configure(menu=self.zoom_axes_menu) self.zoom_axes_menu.add_command(label="to step data", command=self.reset_zoom_step) self.zoom_axes_menu.add_command(label="to all data", command=self.reset_zoom_all) self.zoom_axes_menu.add_command(label="to Custom", command=self.reset_zoom_custom, state="disabled") self.zoom_axes_menu.add_separator() self.zoom_axes_menu.add_command(label="Set Custom", command=self.set_custom_axis_limits) fswp = self.sweep_list = SweepList(self) fswp.sticky = 'n' grid([head, bvolt, baxes, baxes], [fswp, fswp, gcanv, gcanv]) self.currently_displayed = self.model # tells what is currently displayed, experiment, sweep_set or sweep self.update()
def __init__(self, parent, model): Toplevel.__init__(self) self.parent = parent # an ExperimentView self.model = model # an FtExperiment self.entries = [] # a list of: # (FtSweepSet, NumberEntry, [(FtSweep, NumberEntry), ...]) proj_units = self.model.parent.units outerbox = Frame(self, background = self.cget("background"), borderwidth = 0, width = 40) self.title(self.headings[model.experiment_number]) colnum = 0 for sweep_set in model.sweep_sets: dir, name = os.path.split(sweep_set.path) fset = Frame(outerbox, borderwidth = 3, relief='groove') if proj_units['Voltage'].scale is not None and \ sweep_set.units['Voltage'].scale is not None: expo = proj_units['Voltage'].scale - sweep_set.units['Voltage'].scale factor = pow(10, expo) else: factor = 1 glbl = group_label(fset, "Voltage levels for " + name) box = Text(fset, width=25, borderwidth = 0, background = self.cget("background")) bar = fset.vscrollbar = Scrollbar(fset, orient = 'v', command = box.yview) box.configure(yscrollcommand = bar.set) bar.sticky = 'ns' box.grid(padx = 2, sticky = 'n') unitbox = UnitChooser(fset, sweep_set.units['Voltage'], heading = 'Units:') unitbox.grid(padx = 5, sticky = 'n') # Hold voltage lbl = entry_label(box, text = self.Vhold_labels[model.experiment_number]) ent = NumberEntry(box) val = sweep_set.Vhold if val is not None: val = val*factor ent.set(val) sweeps = [] self.entries.append((sweep_set, ent, sweeps)) box.window_create('end', window = lbl) box.insert('end', '\t') box.window_create('end', window = ent) box.insert('end', '\n') i = 1 for sweep in sweep_set.sweeps: lbl = entry_label(box, text = "%3d" % i) ent = NumberEntry(box) val = sweep.Vsweep if val is not None: val = val*factor ent.set(val) sweeps.append((sweep, ent)) box.window_create('end', window = lbl) box.insert('end', '\t') box.window_create('end', window = ent) box.insert('end', '\n') i = i + 1 box.configure(state = 'disabled') grid([glbl, glbl, glbl], [box, unitbox, bar]) fset.grid(row = 0, col = colnum, sticky = 'ne', padx = 3) colnum = colnum + 1 fbut = Frame(self) bok = Button(fbut, width = 6, text = "OK", command = self.ok) bcan = Button(fbut, text = "Cancel", command = self.cancel) bcan.pack(side = 'right', padx = 5, pady = 5) bok.pack(side = 'right', padx = 5, pady = 5) grid([outerbox], [fbut]) self.focus_set()