def fillInUI(self, parent): self.morph_maps = {} # Writable maps for pairs of end-point maps. self.default_f_range = (0.0, 1.0, 0.1) self.play_stop_button = self.buttonWidgets['Play'] import Tkinter from CGLtk import Hybrid frame = parent frame.columnconfigure(0, weight=1) row = 0 h = Tkinter.Label(parent, text='Interpolate between two maps') h.grid(row=row, column=0, sticky='w') row += 1 from VolumeViewer import volume_list, Volume_Menu vlist = volume_list() vm1 = Volume_Menu(parent, 'First map', open_button=True, show_on_open=True) vm1.frame.grid(row=row, column=0, sticky='w') if len(vlist) >= 1: vm1.set_volume(vlist[0]) row += 1 self.map_menu_1 = vm1 vm2 = Volume_Menu(parent, 'Second map', open_button=True, show_on_open=True) vm2.frame.grid(row=row, column=0, sticky='w') if len(vlist) >= 2: vm2.set_volume(vlist[1]) row += 1 self.map_menu_2 = vm2 self.scale = Hybrid.Scale(parent, 'Fraction ', 0.0, 1.0, 0.01, 0) self.scale.frame.grid(row=row, column=0, sticky='ew') self.scale.callback(self.scale_changed_cb) self.scale.entry.bind('<KeyPress-Return>', self.scale_changed_cb) row += 1 op = Hybrid.Popup_Panel(parent) opf = op.frame opf.grid(row=row, column=0, sticky='news') opf.grid_remove() opf.columnconfigure(0, weight=1) self.options_panel = op.panel_shown_variable row += 1 orow = 0 cb = op.make_close_button(opf) cb.grid(row=orow, column=1, sticky='e') fr = Tkinter.Frame(opf) fr.grid(row=orow, column=0, sticky='w') orow += 1 fmin, fmax, fstep = self.default_f_range fn = Hybrid.Entry(fr, 'Movie start ', 5, fmin) fn.frame.grid(row=0, column=0, sticky='w') fx = Hybrid.Entry(fr, ' end ', 5, fmax) fx.frame.grid(row=0, column=1, sticky='w') fs = Hybrid.Entry(fr, ' step ', 5, fstep) fs.frame.grid(row=0, column=2, sticky='w') self.f_range_variables = (fn.variable, fx.variable, fs.variable) um = Hybrid.Checkbutton(opf, 'Undisplay original maps', True) um.button.grid(row=orow, column=0, sticky='w') orow += 1 self.undisplay_maps = um.variable mu = Hybrid.Checkbutton_Entries(opf, False, 'Multiplier for second map', (4, '1.0')) mu.frame.grid(row=orow, column=0, sticky='w') orow += 1 self.use_multiplier, self.map_2_multiplier = mu.variables ta = Hybrid.Checkbutton(opf, 'Adjust threshold for constant volume', False) ta.button.grid(row=orow, column=0, sticky='w') orow += 1 self.adjust_thresholds = ta.variable am = Hybrid.Checkbutton(opf, 'Add to first map instead of interpolating', False) am.button.grid(row=orow, column=0, sticky='w') orow += 1 self.add_maps = am.variable am.callback(self.add_mode_cb) rt = Hybrid.Checkbutton(opf, 'Round trip when recording movie', True) rt.button.grid(row=orow, column=0, sticky='w') orow += 1 self.roundtrip = rt.variable # # Specify a label width so dialog is not resized for long messages. # msg = Tkinter.Label(parent, width=40, anchor='w', justify='left') msg.grid(row=row, column=0, sticky='ew') row = row + 1 self.message_label = msg
def fillInUI(self, parent): self.requested_halt = False self.xform_handler = None self.last_relative_xform = None t = parent.winfo_toplevel() self.toplevel_widget = t t.withdraw() parent.columnconfigure(0, weight=1) row = 0 import Tkinter from CGLtk import Hybrid from VolumeViewer import Volume_Menu ff = Tkinter.Frame(parent) ff.grid(row=row, column=0, sticky='w') row = row + 1 from chimera.widgets import ModelOptionMenu om = ModelOptionMenu(ff, labelpos='w', label_text='Fit ', listFunc=fit_object_models, sortFunc=compare_fit_objects, command=self.object_chosen_cb) om.grid(row=0, column=0, sticky='w') self.object_menu = om fm = Volume_Menu(ff, ' in map ') fm.frame.grid(row=0, column=1, sticky='w') self.map_menu = fm gf = Tkinter.Frame(parent) gf.grid(row=row, column=0, sticky='w') row += 1 cl = Tkinter.Label(gf, text='Correlation') cl.grid(row=0, column=0, sticky='w') cv = Tkinter.Label(gf, width=6, anchor='w', relief=Tkinter.SUNKEN, borderwidth=2) cv.grid(row=0, column=1, padx=5, sticky='w') self.corr_label = cv al = Tkinter.Label(gf, text='Average map value') al.grid(row=0, column=2, sticky='w') av = Tkinter.Label(gf, width=6, anchor='w', relief=Tkinter.SUNKEN, borderwidth=2) av.grid(row=0, column=3, padx=5, sticky='w') self.ave_label = av ub = Tkinter.Button(gf, text='Update', command=self.update_metric_cb) ub.grid(row=0, column=4, sticky='w') op = Hybrid.Popup_Panel(parent) opf = op.frame opf.grid(row=row, column=0, sticky='news') opf.grid_remove() opf.columnconfigure(0, weight=1) self.options_panel = op.panel_shown_variable row += 1 orow = 0 cb = op.make_close_button(opf) cb.grid(row=orow, column=1, sticky='e') ru = Hybrid.Checkbutton(opf, 'Real-time correlation / average update', False) ru.button.grid(row=orow, column=0, sticky='w') orow += 1 self.realtime_update = ru.variable ru.callback(self.realtime_cb) sm = Hybrid.Checkbutton_Entries( opf, False, 'Use map simulated from atoms, resolution ', (4, '')) sm.frame.grid(row=orow, column=0, sticky='nw') orow += 1 self.simulate_map, self.map_resolution = sm.variables self.simulate_map.add_callback(self.simulate_map_cb) sm.entries[0].bind('<KeyPress-Return>', self.simulate_resolution_cb) dt = Hybrid.Checkbutton( opf, 'Use only data above contour level from first map', True) dt.button.grid(row=orow, column=0, sticky='w') orow += 1 dt.button['state'] = 'disabled' self.limit_data = dt self.above_threshold = dt.variable opt = Hybrid.Radiobutton_Row(opf, 'Optimize ', ('overlap', 'correlation')) opt.frame.grid(row=orow, column=0, sticky='w') orow += 1 self.optimize = opt.variable self.opt_widget = opt cam = Hybrid.Checkbutton( opf, 'Correlation calculated about mean data value', False) cam.button.grid(row=orow, column=0, sticky='w') orow += 1 cam.button['state'] = 'disabled' self.cam_widget = cam self.corr_about_mean = cam.variable al = Hybrid.Checkbutton_Row(opf, 'Allow ', ('rotation', 'shift')) al.frame.grid(row=orow, column=0, sticky='w') orow += 1 ar, ash = [c.variable for c in al.checkbuttons] ar.set(True) ash.set(True) self.allow_rotation = ar self.allow_shift = ash mm = Hybrid.Checkbutton(opf, 'Move whole molecules', True) mm.button.grid(row=orow, column=0, sticky='w') orow += 1 self.move_whole_molecules = mm.variable self.mwm_button = mm.button # # Specify a label width so dialog is not resized for long messages. # msg = Tkinter.Label(parent, width=40, anchor='w', justify='left') msg.grid(row=row, column=0, sticky='ew') row = row + 1 self.message_label = msg self.halt_button = self.buttonWidgets['Halt'] self.allow_halt(False) self.update_gray_out() self.activate_undo_redo()
def fillInUI(self, parent): self.sel_handler = None self.last_selected = set() import Tkinter from CGLtk import Hybrid top = parent.winfo_toplevel() menubar = Tkinter.Menu(top, type="menubar", tearoff=False) top.config(menu=menubar) file_menu_entries = (('Export...', self.export_cb), ) fmenu = Hybrid.cascade_menu(menubar, 'File', file_menu_entries) self.columnMenu = Tkinter.Menu(menubar) menubar.add_cascade(label="Columns", menu=self.columnMenu) from chimera.tkgui import aquaMenuBar aquaMenuBar(menubar, parent, row=0) row = 1 columns = ( ('region', lambda r: r.rid), ('grid points', lambda r: r.point_count()), ('grouped', lambda r: len(r.children())), ('has surface', lambda r: 1 if r.has_surface() else 0), ('contacts', lambda r: len(r.contacting_regions())), ('edge distance', lambda r: r.edge_distance()), ('bounds', lambda r: tuple(r.bounds()[0]) + tuple(r.bounds()[1]), '%d,%d,%d,%d,%d,%d', False), ) self.computed_attributes = dict([c[:2] for c in columns]) self.keys = set([c[0] for c in columns]) defaults = dict([(c[0], True) for c in columns]) prefs = {} mi = (self.columnMenu, prefs, defaults, True) from CGLtk.Table import SortableTable self.attribute_table = t = SortableTable(parent, menuInfo=mi) for cspec in columns: name, func = cspec[:2] format = cspec[2] if len(cspec) >= 3 else format_item display = cspec[3] if len(cspec) >= 4 else True t.addColumn(name, func, format=format, display=display, font='TkFixedFont', refresh=False) self.add_columns() # Additional region attributes. t.setData([]) t.launch(browseCmd=self.table_line_selected) t.grid(row=row, column=0, sticky="nsew") parent.rowconfigure(row, weight=1) parent.columnconfigure(0, weight=1) row += 1 naf = Tkinter.Frame(parent) naf.grid(row=row, column=0, sticky='new') naf.columnconfigure(1, weight=1) row += 1 ke = Hybrid.Entry(naf, 'Set attribute ', 15) ke.frame.grid(row=0, column=0, sticky='w') self.key_name = ke.variable ke.entry.bind('<KeyPress-Return>', self.new_value_cb) ve = Hybrid.Entry(naf, ' to value ', 15) ve.frame.grid(row=0, column=1, sticky='ew') self.value = ve.variable ve.entry.bind('<KeyPress-Return>', self.new_value_cb) ol = Tkinter.Label(naf, text=' or ') ol.grid(row=0, column=2, sticky='e') sb = Tkinter.Button(naf, text='snapshot', command=self.snapshot_cb) sb.grid(row=0, column=3, sticky='e') fl = Hybrid.Checkbutton_Entries(parent, False, 'Filter list ', (50, 'grid_points > 1000')) fl.frame.grid(row=row, column=0, sticky='new') row += 1 self.use_filter, self.filter_text = fl.variables self.use_filter.add_callback(self.filter_cb) e = fl.entries[0] fl.frame.columnconfigure(1, weight=1) e.grid(sticky='ew') e.bind('<KeyPress-Return>', self.filter_cb) op = Hybrid.Popup_Panel(parent, resize_dialog=False) opf = op.frame opf.grid(row=row, column=0, sticky='news') opf.grid_remove() opf.columnconfigure(0, weight=1) self.optionsPanel = op.panel_shown_variable row += 1 orow = 0 cb = op.make_close_button(opf) cb.grid(row=orow, column=0, sticky='e') l = Tkinter.Label(opf, text='Options', font='TkCaptionFont') l.grid(column=0, row=orow, sticky='w', pady=5) orow += 1 ss = Hybrid.Checkbutton(opf, 'Show selected region surface', False) ss.button.grid(row=orow, column=0, sticky='w') orow += 1 self.show_selected = ss.variable msg = Tkinter.Label(parent, width=60, anchor='w', justify='left') msg.grid(column=0, row=row, sticky='ew') self.msg = msg self.Update()