def fillInUI(self, parent):

    self.toplevel_widget = parent.winfo_toplevel()
    self.toplevel_widget.withdraw()

    parent.columnconfigure(0, weight=1)
    row = 0

    import Tkinter
    from CGLtk import Hybrid

    from chimera.widgets import MoleculeOptionMenu
    mm = MoleculeOptionMenu(parent, labelpos = 'w', label_text = 'Molecule ')
    mm.grid(row = row, column = 0, sticky = 'w')
    self.molecule_menu = mm
    row = row + 1

    cd = Hybrid.Entry(parent, 'Contact distance', 5, '1.0')
    cd.frame.grid(row = row, column = 0, sticky = 'w')
    self.contact_distance = cd.variable
    cd.entry.bind('<KeyPress-Return>', self.show_contacts)
    row = row + 1

    mc = Hybrid.Checkbutton(parent, 'Create copies of contacting molecules.', False)
    mc.button.grid(row = row, column = 0, sticky = 'w')
    row += 1
    self.copy_molecule = mc.variable
    
    msg = Tkinter.Label(parent, anchor = 'w', justify = 'left')
    msg.grid(row = row, column = 0, sticky = 'ew')
    row = row + 1
    self.message_label = msg
  def fillInUI(self, parent):

    self.surface_change_handler = None

    self.toplevel_widget = parent.winfo_toplevel()
    self.toplevel_widget.withdraw()

    parent.columnconfigure(0, weight=1)
    row = 0

    import Tkinter
    from CGLtk import Hybrid
    from chimera import widgets

    from MeasureVolume import surface_models
    sm = widgets.ModelOptionMenu(parent, labelpos = 'w',
                                 label_text = 'Surface ',
                                 listFunc = surface_models,
                                 command = self.surface_menu_cb)
    sm.grid(row = row, column = 0, sticky = 'w')
    self.surface_menu = sm
    row = row + 1

    ve = Hybrid.Entry(parent, 'Volume = ', 20)
    ve.entry.configure(relief = Tkinter.FLAT, state = 'readonly',
                       highlightthickness = 0)
    ve.frame.grid(row = row, column = 0, sticky = 'w')
    row = row + 1
    self.volume = ve.variable

    ae = Hybrid.Entry(parent, 'Area = ', 20)
    ae.entry.configure(relief = Tkinter.FLAT, state = 'readonly',
                       highlightthickness = 0)
    ae.frame.grid(row = row, column = 0, sticky = 'w')
    row = row + 1
    self.area = ae.variable

    au = Hybrid.Checkbutton(parent, 'Update automatically', True)
    au.button.grid(row = row, column = 0, sticky = 'w')
    row = row + 1
    self.autoupdate = au.variable
    au.callback(self.update_switch_cb)

    # Set menu to a displayed surface.
    surfs = filter(lambda sm: sm.display, surface_models())
    if surfs:
      self.surface_menu.setvalue(surfs[0])
    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
Esempio n. 4
0
	def fillInUI(self, parent):
		from sys import getrefcount
		import Tkinter, Pmw
		top = parent.winfo_toplevel()
		menubar = Tkinter.Menu(top, type="menubar", tearoff=False)
		top.config(menu=menubar)

		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

		from CGLtk.Table import SortableTable
		self.cavityTable = SortableTable(parent, menuInfo=
				(self.columnMenu, prefs, dict.fromkeys(
				defaults[SHOWN_COLS], True), False))
		if not self.tableData:
			from CASTp import mouthFieldNames, pocketFieldNames
			# add preferred columns first
			shownCols = prefs[SHOWN_COLS]
			for fn in ("ID", "MS volume", "SA volume",
					"pocket MS area", "pocket SA area",
					"# openings"):
				if fn[0] == '#' or fn == "ID":
					kw = {'format': "%d"}
				else:
					kw = {'format': "%6.1f", 'font': "TkFixedFont"}
				self.cavityTable.addColumn(fn, "lambda c: "
					"c.pocketInfo['%s']" % fn, **kw)
			for fn in ("mouth MS area", "mouth SA area",
					"MS circumference sum",
					"SA circumference sum"):
				self.cavityTable.addColumn(fn, "lambda c: "
					"c.mouthInfo['%s']" % fn,
					format="%6.1f", font='TkFixedFont')
			for fieldNames, attrName in [
					(pocketFieldNames, "pocketInfo"),
					(mouthFieldNames, "mouthInfo")]:
				for fn in fieldNames:
					if fn[0] == '#' or fn == "ID":
						kw = {'format': "%d"}
					else:
						kw = {'format': "%6.1f", 'font': "TkFixedFont"}
					c = self.cavityTable.addColumn(fn,
						"lambda c: "
						"getattr(c, '%s')['%s']" %
						(attrName, fn), **kw)
					if fn == "ID":
						self.cavityTable.sortBy(c)
						self.cavityTable.sortBy(c)
		self.cavityTable.setData(self.cavities)
		self.cavityTable.launch(browseCmd=self._selCavityCB,
						restoreInfo=self.tableData)
		self.cavityTable.grid(row=row, column=0, sticky="nsew")
		parent.rowconfigure(row, weight=1)
		parent.columnconfigure(0, weight=1)
		row += 1

		grp = Pmw.Group(parent,
				tag_text="Treatment of Chosen Pocket Atoms")
		grp.grid(row=row)
		checkFrame = grp.interior()
		from CGLtk import Hybrid
		def buttonCB(s=self):
			self._selCavityCB(self.cavityTable.selected())
		self.doSelect = Hybrid.Checkbutton(checkFrame, "Select",
							prefs[DO_SELECT])
		self.doSelect.variable.add_callback(buttonCB)
		self.doSelect.button.grid(row=0, sticky='w')
		f = Tkinter.Frame(checkFrame)
		f.grid(row=1, sticky='w')
		self.doColor = Hybrid.Checkbutton(f, "Color",
							prefs[DO_COLOR])
		self.doColor.variable.add_callback(buttonCB)
		self.doColor.button.grid(row=0, column=0)
		from CGLtk.color.ColorWell import ColorWell
		self.pocketColor = ColorWell(f, color=prefs[POCKET_COLOR],
							noneOkay=True)
		self.pocketColor.grid(row=0, column=1)
		Tkinter.Label(f, text=" (and color all other atoms ").grid(
			row=0, column=2)
		self.nonpocketColor = ColorWell(f, color=prefs[NONPOCKET_COLOR],
							noneOkay=True)
		self.nonpocketColor.grid(row=0, column=3)
		Tkinter.Label(f, text=")").grid(row=0, column=4)
		self.doSurface = Hybrid.Checkbutton(checkFrame, "Surface",
							prefs[DO_SURFACE])
		self.doSurface.variable.add_callback(buttonCB)
		self.doSurface.button.grid(row=2, sticky='w')
		self.doZoom = Hybrid.Checkbutton(checkFrame, "Zoom in on",
							prefs[DO_ZOOM])
		self.doZoom.variable.add_callback(buttonCB)
		self.doZoom.button.grid(row=3, sticky='w')
		self.excludeMouth = Hybrid.Checkbutton(checkFrame,
				"Exclude mouth atoms", prefs[EXCLUDE_MOUTH])
		self.excludeMouth.variable.add_callback(buttonCB)
		self.excludeMouth.button.grid(row=4, sticky='w')
		row += 1
Esempio n. 5
0
    def fillInUI(self, parent):

        self.plot = None

        t = parent.winfo_toplevel()
        self.toplevel_widget = t
        t.withdraw()

        parent.columnconfigure(0, weight=1)
        row = 0

        from chimera.preferences import addCategory, HiddenCategory
        prefs = addCategory("SAXS",
                            HiddenCategory,
                            optDict={'saxs executable': ''})
        self.preferences = prefs

        import Tkinter
        from CGLtk import Hybrid

        from chimera import widgets as w
        mm = w.ExtendedMoleculeOptionMenu(
            parent,
            label_text='Molecule ',
            labelpos='w',
            labels=['selected atoms', 'all molecules'])
        mm.grid(row=row, column=0, sticky='w')
        row += 1
        self.molecule_menu = mm

        ep = Hybrid.Entry(parent, 'Experimental profile ', 25, browse=True)
        ep.frame.grid(row=row, column=0, sticky='ew')
        row += 1
        self.experimental_profile = ep.variable

        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')

        np = Hybrid.Checkbutton(opf, 'Use new plot window', False)
        np.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.new_plot = np.variable

        ex = Hybrid.Entry(opf,
                          'Executable ',
                          25,
                          initial=prefs['saxs executable'],
                          browse=True)
        ex.frame.grid(row=orow, column=0, sticky='ew')
        orow += 1
        ex.entry.xview('end')
        self.executable = ex.variable
    def fillInUI(self, parent):

        self.toplevel_widget = parent.winfo_toplevel()
        self.toplevel_widget.withdraw()

        row = 0

        import Tkinter
        from CGLtk import Hybrid

        from surfcaps import capper
        c = capper()

        cp = Hybrid.Checkbutton(parent, 'Cap surfaces at clip planes',
                                c.caps_shown())
        cp.button.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.show_caps = cp.variable
        self.show_caps.add_callback(self.settings_changed_cb)

        ccf = Tkinter.Frame(parent)
        ccf.grid(row=row, column=0, sticky='w')
        row = row + 1

        ucc = Hybrid.Checkbutton(ccf, 'Use cap color ',
                                 not c.cap_color is None)
        ucc.button.grid(row=0, column=0, sticky='w')
        self.use_cap_color = ucc.variable
        self.use_cap_color.add_callback(self.settings_changed_cb)

        from CGLtk.color import ColorWell
        cc = ColorWell.ColorWell(ccf, callback=self.settings_changed_cb)
        self.cap_color = cc
        rgba = c.cap_color
        if rgba is None:
            rgba = (1, 1, 1, 1)
        cc.showColor(rgba, doCallback=0)
        cc.grid(row=0, column=1, sticky='w')

        cs = Hybrid.Radiobutton_Row(parent, 'Cap style: ', ('solid', 'mesh'),
                                    self.settings_changed_cb)
        cs.frame.grid(row=row, column=0, sticky='w')
        if c.mesh_style: style = 'mesh'
        else: style = 'solid'
        cs.variable.set(style, invoke_callbacks=False)
        row = row + 1
        self.cap_style = cs.variable

        sf = Hybrid.Entry(parent, 'Mesh subdivision factor', 4,
                          '%g' % c.subdivision_factor)
        sf.frame.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.subdivision_factor = sf.variable
        sf.entry.bind('<KeyPress-Return>', self.settings_changed_cb)

        cd = Hybrid.Entry(parent, 'Cap to clip plane distance', 5,
                          '%.3g' % c.cap_offset)
        cd.frame.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.cap_offset = cd.variable
        cd.entry.bind('<KeyPress-Return>', self.settings_changed_cb)

        import SimpleSession
        chimera.triggers.addHandler(SimpleSession.SAVE_SESSION,
                                    self.save_session_cb, None)

        chimera.replyobj.status("Capping surfaces might reduce responsiveness",
                                color="orange red")
    def fillInUI(self, parent):

        self.last_xy = None
        
        import Tkinter
        from CGLtk import Hybrid

        parent.columnconfigure(0, weight = 1)
        row = 0
        
        cr = Hybrid.Checkbutton(parent, 'Constrain mouse rotations', 0)
        cr.button.grid(row = row, column = 0, sticky = 'w')
        row = row + 1
        self.constrain_rotations = cr.variable
        cr.callback(self.constrain_rotation_cb)

        raf = Tkinter.Frame(parent)
        raf.grid(row = row, column = 0, sticky = 'w')
        row = row + 1

        ra = Hybrid.Entry(raf, 'Axis ', 8, '0 0 1')
        ra.frame.grid(row = 0, column = 0, sticky = 'w')
        self.rot_axis = ra.variable

        rotx_cb = lambda v=self.rot_axis: v.set('1 0 0')
        roty_cb = lambda v=self.rot_axis: v.set('0 1 0')
        rotz_cb = lambda v=self.rot_axis: v.set('0 0 1')
        rab = Hybrid.Button_Row(raf, ' ',
                                (('x', rotx_cb),
                                 ('y', roty_cb),
                                 ('z', rotz_cb)))
        rab.frame.grid(row = 0, column = 1, sticky = 'w')

        rof = Tkinter.Frame(parent)
        rof.grid(row = row, column = 0, sticky = 'w')
        row = row + 1

        ro = Hybrid.Entry(rof, 'Origin ', 8, '0 0 0')
        ro.frame.grid(row = 0, column = 0, sticky = 'w')
        self.rot_origin = ro.variable

        zorigin_cb = lambda v=self.rot_origin: v.set('0 0 0')
        rob = Hybrid.Button_Row(rof, ' ',
                                (('zero', zorigin_cb),
                                 ('center', self.set_rotation_origin_at_center),))
        rob.frame.grid(row = 0, column = 1, sticky = 'w')

        sep = Tkinter.Frame(parent,  relief = Tkinter.GROOVE,
                            borderwidth=1, height=2)
        sep.grid(row = row, column = 0, sticky = 'ew', pady = 10)
        row = row + 1
        
        tr = Hybrid.Checkbutton(parent, 'Constrain mouse translations', 0)
        tr.button.grid(row = row, column = 0, sticky = 'w')
        row = row + 1
        self.constrain_translations = tr.variable
        tr.callback(self.constrain_translation_cb)

        taf = Tkinter.Frame(parent)
        taf.grid(row = row, column = 0, sticky = 'w')
        row = row + 1

        ta = Hybrid.Entry(taf, 'Axis ', 8, '0 0 1')
        ta.frame.grid(row = 0, column = 0, sticky = 'w')
        self.trans_axis = ta.variable

        tx_cb = lambda v=self.trans_axis: v.set('1 0 0')
        ty_cb = lambda v=self.trans_axis: v.set('0 1 0')
        tz_cb = lambda v=self.trans_axis: v.set('0 0 1')
        tab = Hybrid.Button_Row(taf, ' ',
                                (('x', tx_cb),
                                 ('y', ty_cb),
                                 ('z', tz_cb)))
        tab.frame.grid(row = 0, column = 1, sticky = 'w')

        ttf = Tkinter.Frame(parent)
        ttf.grid(row = row, column = 0, sticky = 'w')
        row = row + 1

        tt = Hybrid.Option_Menu(ttf, 'Allow only ',
                                'parallel', 'perpendicular')
        tt.variable.set('parallel')
        tt.frame.grid(row = 0, column = 0, sticky = 'w')
        self.translation_type = tt.variable
        
        tl = Tkinter.Label(ttf, text = ' motion')
        tl.grid(row = 0, column = 1, sticky = 'w')

        sep = Tkinter.Frame(parent,  relief = Tkinter.GROOVE,
                            borderwidth=1, height=2)
        sep.grid(row = row, column = 0, sticky = 'ew', pady = 10)
        row = row + 1

        rl = Tkinter.Label(parent, text = 'Axis and origin relative to')
        rl.grid(row = row, column = 0, sticky = 'w')
        row = row + 1

        mmf = Tkinter.Frame(parent)
        mmf.grid(row = row, column = 0, sticky = 'w')
        row = row + 1

        mm = Hybrid.Option_Menu(mmf, 'model ')
        mm.frame.grid(row = 0, column = 0, sticky = 'w')
        self.model_menu = mm
        self.model_name = mm.variable
        from chimera import openModels
        openModels.addAddHandler(self.model_list_changed_cb, None)
        openModels.addRemoveHandler(self.model_list_changed_cb, None)
                
        ml = Tkinter.Label(mmf, text = ' coordinates.')
        ml.grid(row = 0, column = 1, sticky = 'w')

        self.update_model_menu()
        self.register_mouse_modes()
    def fillInUI(self, parent):

        t = parent.winfo_toplevel()
        self.toplevel_widget = t
        t.withdraw()

        parent.columnconfigure(0, weight=1)
        row = 0

        import Tkinter
        from CGLtk import Hybrid

        rs = Hybrid.Scale(parent, ' Radius ', 0, 1000, .1, '')
        rs.frame.grid(row=row, column=0, sticky='ew')
        row = row + 1
        #    rs.callback(self.flatten_cb)
        rs.entry.bind('<KeyPress-Return>', self.flatten_cb)
        self.radius = rs.variable

        # Mesh
        mf = Tkinter.Frame(parent)
        mf.grid(row=row, column=0, sticky='w')
        row = row + 1

        sm = Hybrid.Checkbutton(mf, 'Show triangle mesh,', True)
        sm.button.grid(row=0, column=0, sticky='w')
        self.show_mesh = sm.variable
        self.show_mesh.add_callback(self.show_mesh_cb)

        cl = Tkinter.Label(mf, text='color')
        cl.grid(row=0, column=1, sticky='w')

        initial_color = (.5, .5, .5, 1)
        from CGLtk.color import ColorWell
        mc = ColorWell.ColorWell(mf, callback=self.mesh_color_changed_cb)
        mc.grid(row=0, column=2, sticky='w')
        self.mesh_color = mc
        mc.showColor(initial_color)

        mo = Hybrid.Entry(mf, ' z offset ', 5, '0')
        mo.frame.grid(row=0, column=3, sticky='w')
        self.mesh_offset = mo.variable
        mo.entry.bind('<KeyPress-Return>', self.mesh_offset_changed_cb)

        # Orthographic camera mode.
        import chimera
        c = chimera.viewer.camera
        oc = Hybrid.Checkbutton(parent, 'Use orthographic camera mode.',
                                c.ortho)
        oc.button.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.orthographic = oc.variable
        self.orthographic.add_callback(self.orthographic_cb)

        #
        # 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.key_buffer = ''
    self.key_callback_registered = None
    self.time_out_id = None

    import Accelerators
    self.preferences = Accelerators.accelerator_preferences_category()
    self.top = parent.winfo_toplevel()
    self.top.wm_withdraw()     # Do not show automatically when dialog created
    
    parent.columnconfigure(0, weight = 1)
    row = 0

    import Tkinter
    from CGLtk import Hybrid

    al = Hybrid.Scrollable_List(parent, 'Available shortcuts', 10,
				self.accelerator_selection_cb)
    self.accelerator_listbox = al.listbox
    al.frame.grid(row = row, column = 0, sticky = 'news')
    parent.rowconfigure(row, weight = 1)
    row = row + 1

    fi = Hybrid.Entry(parent, 'Filter list ', 20)
    fi.entry.bind('<KeyRelease>', self.filter_cb)
    fi.frame.grid(row = row, column = 0, sticky = 'ew')
    self.filter_text = fi.variable
    row = row + 1
    
    ao = Hybrid.Checkbutton(parent, 'Enable keyboard shortcuts', False)
    ao.button.grid(row = row, column = 0, sticky = 'w')
    row = row + 1
    ao.callback(self.activate_accelerators_cb)
    self.active_var = ao.variable

    from chimera import statusline
    sl = Hybrid.Checkbutton(parent, 'Show main window status line',
                            statusline.status_line_shown())
    sl.button.grid(row = row, column = 0, sticky = 'w')
    row = row + 1
    sl.callback(self.status_line_cb)
    self.status_line_var = sl.variable
    from chimera import triggers
    triggers.addHandler('status line', self.status_line_visibility_cb, None)

    rf = Tkinter.Frame(parent)
    rf.grid(row = row, column = 0, sticky = 'w')
    row = row + 1

    rb = Tkinter.Button(rf, text = 'Load', command = self.load_cb)
    rb.grid(row = 0, column = 0, sticky = 'w')
    
    afl = Tkinter.Label(rf, text = ' shortcuts file')
    afl.grid(row = 0, column = 1, sticky = 'w')

    path = self.preferences['path']             # Path might be None
    af = Hybrid.Entry(parent, '', 20, path)
    af.entry.xview_moveto(1)    # show right most part of path
    af.entry.bind('<KeyPress-Return>', self.load_cb)
    af.frame.grid(row = row, column = 0, sticky = 'ew')
    row = row + 1
    self.accelerator_file = af.variable

    tot = self.preferences['time out']
    tm = Hybrid.Entry(parent, 'Key press time-out (seconds) ', 3, tot)
    tm.frame.grid(row = row, column = 0, sticky = 'w')
    row = row + 1
    self.time_out = tm.variable
    self.time_out.add_callback(self.time_out_changed_cb)

    #
    # Specify a label width so dialog is not resized for long messages.
    #
    msg = Tkinter.Label(parent, width = 30, anchor = 'w', justify = 'left')
    msg.grid(row = row, column = 0, sticky = 'ew')
    row = row + 1
    self.message_label = msg

    self.load_accelerators()
Esempio n. 10
0
    def fillInUI(self, parent):

        self.model = None
        self.position_handler = None
        self.screen_position = (-.6, -.6)
        self.last_xyz_position = None
        self.frozen_model_list = []

        self.toplevel_widget = parent.winfo_toplevel()
        self.toplevel_widget.withdraw()

        row = 0

        import Tkinter
        from CGLtk import Hybrid

        sb = Hybrid.Checkbutton(parent, 'Show scale bar', 0)
        sb.button.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.show_scalebar = sb.variable
        self.show_scalebar.add_callback(self.settings_changed_cb)

        bf = Tkinter.Frame(parent)
        bf.grid(row=row, column=0, sticky='w')
        row = row + 1

        le = Hybrid.Entry(bf, 'Length ', 5, '10')
        le.frame.grid(row=0, column=0, sticky='w')
        le.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.bar_length = le.variable

        te = Hybrid.Entry(bf, ' Thickness', 3, '1')
        te.frame.grid(row=0, column=1, sticky='w')
        te.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.bar_thickness = te.variable

        cl = Tkinter.Label(bf, text=' Color ')
        cl.grid(row=0, column=2, sticky='w')

        from CGLtk.color import ColorWell
        bc = ColorWell.ColorWell(bf, callback=self.settings_changed_cb)
        self.bar_color = bc
        bc.showColor((1, 1, 1), doCallback=0)
        bc.grid(row=0, column=3, sticky='w')

        lf = Tkinter.Frame(parent)
        lf.grid(row=row, column=0, sticky='w')
        row = row + 1

        # \u00C5 is the Angstrom symbol
        lb = Hybrid.Entry(lf, 'Label ', 5, u'# \u00C5')
        lb.frame.grid(row=0, column=0, sticky='w')
        lb.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.label_text = lb.variable

        xo = Hybrid.Entry(lf, ' Offset ', 3, '')
        xo.frame.grid(row=0, column=1, sticky='w')
        xo.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.label_x_offset = xo.variable

        yo = Hybrid.Entry(lf, '', 3, '')
        yo.frame.grid(row=0, column=2, sticky='w')
        yo.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.label_y_offset = yo.variable

        ct = Tkinter.Label(lf, text=' Color ')
        ct.grid(row=0, column=3, sticky='w')

        from CGLtk.color import ColorWell
        lc = ColorWell.ColorWell(lf, callback=self.settings_changed_cb)
        self.label_color = lc
        lc.showColor((1, 1, 1), doCallback=0)
        lc.grid(row=0, column=4, sticky='w')

        ore = Hybrid.Radiobutton_Row(parent, 'Orientation ',
                                     ('horizontal', 'vertical'),
                                     self.orientation_cb)
        ore.frame.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.orientation = ore.variable
        self.orientation.set('horizontal', invoke_callbacks=0)

        pf = Tkinter.Frame(parent)
        pf.grid(row=row, column=0, sticky='w')
        row = row + 1

        pp = Hybrid.Checkbutton(pf, 'Preserve screen position', 1)
        pp.button.grid(row=0, column=0, sticky='w')
        self.preserve_position = pp.variable
        self.preserve_position.add_callback(self.settings_changed_cb)

        xp = Hybrid.Entry(pf, '', 5, '')
        xp.frame.grid(row=0, column=1, sticky='w')
        xp.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.screen_x_position = xp.variable

        yp = Hybrid.Entry(pf, '', 5, '')
        yp.frame.grid(row=0, column=2, sticky='w')
        yp.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.screen_y_position = yp.variable

        self.set_screen_position_entries()

        mb = Hybrid.Checkbutton(parent,
                                'Move scale bar with data models locked', 0)
        mb.button.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.move_scalebar = mb.variable
        self.move_scalebar.add_callback(self.move_scalebar_cb)

        import SimpleSession
        chimera.triggers.addHandler(SimpleSession.SAVE_SESSION,
                                    self.save_session_cb, None)
        chimera.triggers.addHandler(chimera.CLOSE_SESSION,
                                    self.close_session_cb, None)
Esempio n. 11
0
    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()
    def fillInUI(self, parent):

        self.molecules = []
        self.add_model_handler = None
        self.remove_model_handler = None

        import Tkinter
        from CGLtk import Hybrid

        row = 0

        mm = Hybrid.Option_Menu(parent, 'Molecule: ')
        mm.frame.grid(row=row, column=0, sticky='w')
        row = row + 1
        mm.add_callback(self.molecule_menu_cb)
        self.molecule_menu = mm

        labels = []
        for text in (
                'Space group: ',
                'Cell size: ',
                'Cell angles: ',
                'Number of SMTRY matrices: ',
                'Number of space group symmetries: ',
                'Number of MTRIX matrices: ',
        ):
            lbl = Tkinter.Label(parent, text=text)
            lbl.grid(row=row, column=0, sticky='w')
            row = row + 1
            labels.append(lbl)
        (
            self.space_group,
            self.cell_size,
            self.cell_angles,
            self.smtry_count,
            self.sg_smtry_count,
            self.mtrix_count,
        ) = labels

        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')

        usr = Hybrid.Checkbutton(opf, 'Use SMTRY records in PDB header', True)
        usr.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.use_smtry_records = usr.variable

        ucr = Hybrid.Checkbutton(
            opf, 'Use CRYST1 record if SMTRY records are missing', True)
        ucr.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.use_cryst1_smtry = ucr.variable

        umr = Hybrid.Checkbutton(
            opf, 'Use MTRIX records for non-crystallographic symmetry', True)
        umr.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.use_mtrix_records = umr.variable

        co = Hybrid.Entry(opf, 'Cell origin ', 12, '0 0 0')
        co.frame.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.grid_orig = co.variable
        co.entry.bind('<KeyPress-Return>', self.origin_change_cb)

        nc = Hybrid.Entry(opf, 'Number of cells ', 12, '1 1 1')
        nc.frame.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.ncells = nc.variable
        nc.entry.bind('<KeyPress-Return>', self.make_unit_cell_cb)

        br = Hybrid.Button_Row(parent, '', (
            ('Make copies', self.make_unit_cell_cb),
            ('Outline', self.show_outline_cb),
            ('Delete copies', self.close_unit_cell_cb),
        ))
        br.frame.grid(row=row, column=0, sticky='e')
        row = row + 1
Esempio n. 13
0
  def fillInUI(self, parent):

    self.filter_widgets = fw = []

    self.toplevel_widget = parent.winfo_toplevel()
    self.toplevel_widget.withdraw()

    parent.columnconfigure(0, weight=1)         # Allow scalebar to expand.
    
    row = 0

    import Tkinter
    from CGLtk import Hybrid

    self.gaussian = 'Gaussian'
    self.median = 'Median 3x3x3'
    self.bin = 'Bin'
    self.laplacian = 'Laplacian'
    self.fourier = 'Fourier Transform'
    self.scale = 'Scale'
    ft = Hybrid.Option_Menu(parent, 'Filter type:',
                            self.gaussian, self.median, self.bin,
                            self.laplacian, self.fourier, self.scale)
    ft.button.configure(indicatoron = False)
    ft.frame.grid(row = row, column = 0, sticky = 'w')
    row += 1
    self.filter_type = ft.variable
    ft.add_callback(self.filter_type_changed_cb)
    
    ws = Hybrid.Scale(parent, 'Width ', 1.0, 10.0, 0.0, 1.0)
    ws.frame.grid(row = row, column = 0, sticky = 'ew')
    row += 1
    ws.callback(self.filter_parameter_changed_cb)
    ws.entry.bind('<KeyPress-Return>', self.filter_cb)
    self.sdev = ws
    Hybrid.Balloon_Help(ws.label, 'Width is one standard deviation.',
                        delay = 0.5)
    fw.append((self.gaussian, ws.frame))
    
    mi = Hybrid.Scale(parent, 'Iterations ', 0, 5, 1, 1, 2)
    mi.frame.grid(row = row, column = 0, sticky = 'ew')
    row += 1
    mi.callback(self.filter_parameter_changed_cb)
    mi.entry.bind('<KeyPress-Return>', self.filter_cb)
    self.median_iterations = mi
    fw.append((self.median, mi.frame))

    bs = Hybrid.Entry(parent, 'Bin size', 5, '2')
    bs.frame.grid(row = row, column = 0, sticky = 'w')
    row += 1
    self.binsize = bs.variable
    bs.entry.bind('<KeyPress-Return>', self.filter_cb)
    fw.append((self.bin, bs.frame))

    sf = Tkinter.Frame(parent)
    sf.grid(row = row, column = 0, sticky = 'w')
    row += 1
    fw.append((self.scale, sf))

    sh = Hybrid.Entry(sf, 'Shift', 5, '0')
    sh.frame.grid(row = 0, column = 0, sticky = 'w')
    self.shift = sh.variable
    sh.entry.bind('<KeyPress-Return>', self.filter_cb)

    sc = Hybrid.Entry(sf, 'Scale', 5, '1')
    sc.frame.grid(row = 0, column = 1, sticky = 'w')
    self.scale_factor = sc.variable
    sc.entry.bind('<KeyPress-Return>', self.filter_cb)

    vt = Hybrid.Option_Menu(sf, 'Value type', 'same', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'float32', 'float64')
    vt.frame.grid(row = 0, column = 2, sticky = 'w')
    self.value_type = vt.variable

    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')
 
    sr = Hybrid.Checkbutton(opf, 'Displayed subregion only', True)
    sr.button.grid(row = orow, column = 0, sticky = 'w')
    orow += 1
    self.use_subregion = sr.variable

    ss = Hybrid.Checkbutton(opf, 'Displayed subsampling only', False)
    ss.button.grid(row = orow, column = 0, sticky = 'w')
    orow += 1
    self.use_step = ss.variable

    ta = Hybrid.Checkbutton(opf, 'Adjust threshold for constant volume', True)
    ta.button.grid(row = orow, column = 0, sticky = 'w')
    orow += 1
    self.adjust_thresholds = ta.variable

    iu = Hybrid.Checkbutton(opf, 'Immediate update', False)
    iu.button.grid(row = orow, column = 0, sticky = 'w')
    orow += 1
    self.immediate_update = iu.variable

    self.filter_type_changed_cb()
    self.set_scale_range(initial = True)
Esempio n. 14
0
    def fillInUI(self, parent):

        self.toplevel_widget = parent.winfo_toplevel()
        self.toplevel_widget.withdraw()

        parent.columnconfigure(0, weight=1)
        row = 0

        import Tkinter
        from CGLtk import Hybrid
        from chimera import widgets

        from SurfaceColor import colorable_surface_models
        sm = widgets.ModelOptionMenu(parent,
                                     labelpos='w',
                                     label_text='Color surface ',
                                     listFunc=colorable_surface_models,
                                     command=self.surface_menu_cb)
        sm.grid(row=row, column=0, sticky='w')
        self.surface_menu = sm
        row = row + 1

        from SurfaceColor import coloring_methods
        methods = [cm.menu_name for cm in coloring_methods]
        csm = Hybrid.Option_Menu(parent, 'by ', *methods)
        csm.frame.grid(row=row, column=0, sticky='w')
        self.color_source_menu = csm.variable
        csm.add_callback(self.color_source_changed_cb)
        row = row + 1

        from VolumeViewer import Volume_Menu
        vm = Volume_Menu(parent, 'file', open_button='browse...')
        vm.frame.grid(row=row, column=0, sticky='w')
        self.volume_menu = vm
        row += 1

        oaf = Tkinter.Frame(parent)
        oaf.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.origin_axis_frame = oaf

        oe = Hybrid.Entry(oaf, 'origin ', 8, '0 0 0')
        oe.frame.grid(row=0, column=0, sticky='w')
        self.origin_variable = oe.variable
        oe.entry.bind('<KeyPress-Return>', self.settings_changed_cb)

        cb = Tkinter.Button(oaf, text='center', command=self.set_center_cb)
        cb.grid(row=0, column=1, sticky='w')

        ae = Hybrid.Entry(oaf, 'axis ', 8, '0 0 1')
        ae.frame.grid(row=0, column=2, sticky='w')
        self.axis_frame = ae.frame
        self.axis_variable = ae.variable
        ae.entry.bind('<KeyPress-Return>', self.settings_changed_cb)

        cg = Colorwell_GUI(parent, 5, self.settings_changed_cb)
        cg.set_color_palette('rainbow')
        self.colormap_gui = cg
        self.colormap_gui.frame.grid(row=row, column=0, sticky='w')
        row = 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='ne')

        cf = Tkinter.Frame(opf)
        cf.grid(row=orow, column=0, sticky='w')
        orow += 1

        color_counts = ('2', '3', '5', '10', '15', '20')
        cc = Hybrid.Option_Menu(cf, 'Colors ', *color_counts)
        cc.frame.grid(row=0, column=0, sticky='w')
        self.color_count = cc.variable
        self.color_count.set('5')
        cc.add_callback(self.change_color_count_cb)

        cpat = ('Rainbow', 'Gray', 'Red-Blue', 'Cyan-Maroon')
        cp = Hybrid.Option_Menu(cf, 'Palette', *cpat)
        cp.frame.grid(row=0, column=1, sticky='w')
        self.palette = cp.variable
        cp.add_callback(self.change_color_palette_cb)

        rc = Tkinter.Button(cf, text='Reverse', command=self.reverse_colors_cb)
        rc.grid(row=0, column=2, sticky='w')

        ckb = Tkinter.Button(opf,
                             text="Create color key",
                             command=self.colormap_gui.color_key_cb)
        ckb.grid(row=orow, column=0, sticky='w')
        orow += 1

        dcf = Tkinter.Frame(opf)
        dcf.grid(row=orow, column=0, sticky='w')
        orow += 1

        db = Tkinter.Button(dcf,
                            text='Set',
                            command=self.show_default_colormap_values)
        db.grid(row=0, column=0, sticky='w')

        dt = Tkinter.Label(dcf, text=' full range of surface values')
        dt.grid(row=0, column=1, sticky='w')

        so = Hybrid.Entry(opf, 'Surface offset ', 5, '1.4')
        so.frame.grid(row=orow, column=0, sticky='w')
        self.surface_offset = so.variable
        self.surface_offset_frame = so.frame
        orow += 1
        so.entry.bind('<KeyPress-Return>', self.settings_changed_cb)

        ocf = Tkinter.Frame(opf)
        ocf.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.outside_color_frame = ocf

        ocl = Tkinter.Label(ocf, text='Color outside volume')
        ocl.grid(row=0, column=0, sticky='w')

        outside_color = (.5, .5, .5, 1)
        from CGLtk.color import ColorWell
        cw = ColorWell.ColorWell(ocf)
        cw.showColor(outside_color)
        cw.grid(row=0, column=1, sticky='w')
        self.outside_color = cw

        co = Hybrid.Checkbutton(opf, 'Only color sliced surface face', 0)
        co.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.color_caps_only = co.variable

        ppc = Hybrid.Checkbutton(opf, 'Per-pixel coloring', False)
        ppc.button.grid(row=orow, column=0, sticky='w')
        orow += 1
        self.per_pixel_color = ppc.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

        # Show current coloring if one already exists from session restore.
        self.surface_menu_cb()

        # Show axix, origin, volume widgets if appropriate.
        self.color_source_changed_cb()
Esempio n. 15
0
    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()
Esempio n. 16
0
  def fillInUI(self, parent):

    self.default_radius = 1
    self.default_color = (1,0.6,0.8,.5)      # Pink eraser
    
    t = parent.winfo_toplevel()
    self.toplevel_widget = t
    t.withdraw()

    parent.columnconfigure(0, weight = 1)
    row = 0

    import Tkinter
    from CGLtk import Hybrid

    sh = Hybrid.Checkbutton(parent, 'Show volume-erasing sphere ', True)
    sh.button.grid(row = row, column = 0, sticky = 'w')
    row = row + 1
    self.show_sphere_var = sh.variable
    sh.callback(self.show_sphere_cb)

    crf = Tkinter.Frame(parent)
    crf.grid(row = row, column = 0, sticky = 'ew')
    crf.columnconfigure(2, weight = 1)
    row = row + 1

    cl = Tkinter.Label(crf, text = 'Color')
    cl.grid(row = 0, column = 0, sticky = 'w')
    
    from CGLtk.color import ColorWell
    sc = ColorWell.ColorWell(crf, color = self.default_color,
                             callback = self.change_sphere_color_cb)
    sc.grid(row = 0, column = 1, sticky = 'w')
    self.sphere_color = sc

    rs = Hybrid.Scale(crf, ' Radius ', 0, 30, .1, 2)
    rs.frame.grid(row = 0, column = 2, sticky = 'ew')
    row = row + 1
    rs.callback(self.change_radius_cb)
    rs.entry.bind('<KeyPress-Return>', self.change_radius_cb)
    self.sphere_radius_scale = rs
    
    mmf = Tkinter.Frame(parent)
    mmf.grid(row = row, column = 0, sticky = 'w')
    row = row + 1

    mb = Hybrid.Option_Menu(mmf, 'Use mouse ',
                            'button 1', 'button 2', 'button 3',
                            'ctrl button 1', 'ctrl button 2', 'ctrl button 3')
    mb.variable.set('button 2')
    mb.frame.grid(row = 0, column = 0, sticky = 'w')
    mb.add_callback(self.bind_mouse_button_cb)
    self.mouse_button = mb

    mbl = Tkinter.Label(mmf, text = ' to move sphere')
    mbl.grid(row = 0, column = 1, sticky = 'w')

    ka = Tkinter.Label(parent, text = 'Erase using keyboard accelerator "es".')
    ka.grid(row = row, column = 0, sticky = 'w')
    row = row + 1

    from Accelerators import add_accelerator
    add_accelerator('es', 'Erase volume data inside sphere', self.Erase)
    add_accelerator('eo', 'Erase volume data outside sphere',
                    self.erase_outside_sphere)
Esempio n. 17
0
    def fillInUI(self, parent):

        self.phantom_device = None
        self.cursor_model = None
        self.phantom_handler = None
        self.gradient_force = None
        self.phantom_button_down = 0
        self.last_phantom_transform = None
        self.last_roll = None
        self.key_callback_registered = None
        self.mode = 'cursor'  # 'cursor', 'move models', 'zoom',
        # 'contour level', 'move marker'
        self.command_list_shown = False

        import Tkinter
        from CGLtk import Hybrid

        row = 0

        po = Hybrid.Checkbutton_Row(parent, 'Enable',
                                    ('cursor', 'forces', 'key commands'))
        po.frame.grid(row=row, column=0, sticky='w')
        row = row + 1
        self.phantom_on, self.force_field, self.commands = \
            [c.variable for c in po.checkbuttons]
        self.phantom_on.add_callback(self.settings_changed_cb)
        self.force_field.add_callback(self.settings_changed_cb)
        self.commands.add_callback(self.toggle_commands_cb)

        cf = Tkinter.Frame(parent)
        cf.grid(row=row, column=0, sticky='w')
        row = row + 1

        cs = Hybrid.Option_Menu(cf, 'Cursor shape ', 'cross', 'jack', 'sphere',
                                'volume crosshair')
        cs.frame.grid(row=0, column=0, sticky='nw')
        row = row + 1
        cs.variable.set('jack')
        cs.add_callback(self.settings_changed_cb)
        self.cursor_shape = cs.variable

        from VolumeViewer import active_volume
        v = active_volume()
        if v:
            csize = '%.3g' % (10 * max(v.data.step))
        else:
            csize = '1'
        cs = Hybrid.Entry(cf, ' size ', 5, csize)
        cs.frame.grid(row=0, column=1, sticky='w')
        cs.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.cursor_size = cs.variable

        cl = Tkinter.Label(cf, text=' color ')
        cl.grid(row=0, column=2, sticky='w')

        from CGLtk.color import ColorWell
        cc = ColorWell.ColorWell(cf, callback=self.settings_changed_cb)
        self.cursor_color = cc
        cc.showColor((0, 0.5, 1), doCallback=0)
        cc.grid(row=0, column=3, sticky='w')

        sp = Hybrid.Popup_Panel(parent)
        spf = sp.frame
        spf.grid(row=row, column=0, sticky='news')
        spf.grid_remove()
        spf.columnconfigure(0, weight=1)
        self.settings_panel = sp.panel_shown_variable
        row += 1
        srow = 0

        cb = sp.make_close_button(spf)
        cb.grid(row=srow, column=1, sticky='e')

        pr = Hybrid.Entry(spf, 'Phantom physical range (mm) ', 5, '200')
        pr.frame.grid(row=srow, column=0, sticky='w')
        srow += 1
        pr.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.phantom_range = pr.variable

        mf = Hybrid.Entry(spf, 'Maximum force (lbs) ', 5, '.4')
        mf.frame.grid(row=srow, column=0, sticky='w')
        srow += 1
        mf.entry.bind('<KeyPress-Return>', self.settings_changed_cb)
        self.maximum_force = mf.variable

        af = Hybrid.Checkbutton(spf, 'Auto-adjust force constant', 1)
        af.button.grid(row=srow, column=0, sticky='w')
        srow += 1
        self.auto_adjust_force_constant = af.variable
        self.force_field.add_callback(self.settings_changed_cb)

        fc = Hybrid.Logarithmic_Scale(spf, 'Force constant ', .0001, 100, 1,
                                      '%.2g')
        fc.frame.grid(row=srow, column=0, sticky='ew')
        srow += 1
        fc.set_value(1)
        fc.callback(self.force_constant_changed_cb)
        fc.entry.bind('<KeyPress-Return>', self.force_constant_changed_cb)
        self.force_constant = fc

        vf = Tkinter.Frame(spf)
        vf.grid(row=srow, column=0, sticky='ew')
        srow += 1

        self.label_row(vf, 0, ('', 'x', 'y', 'z'))
        pl = self.label_row(vf, 1, ('Phantom position', '', '', ''))
        self.phantom_position_labels = pl[1:]
        cpl = self.label_row(vf, 2, ('Chimera position', '', '', ''))
        self.chimera_position_labels = cpl[1:]
        vpl = self.label_row(vf, 3, ('Volume position', '', '', ''))
        self.volume_position_labels = vpl[1:]
        vil = self.label_row(vf, 4, ('Volume index', '', '', ''))
        self.volume_index_labels = vil[1:]
        gl = self.label_row(vf, 5, ('Gradient', '', '', ''))
        self.gradient_labels = gl[1:]
        fl = self.label_row(vf, 6, ('Force', '', '', ''))
        self.force_labels = fl[1:]
        dvl = self.label_row(vf, 7, ('Data value', ''))
        self.data_value_label = dvl[1]
    def fillInUI(self, parent):

        self.averaging_interval = 1  # seconds
        self.target_fps = 10.0  # frames per second
        self.standard_window_size = (512, 512)
        self.initial_size = 32

        self.frame_rate_timer = Frame_Rate_Timer(self.report_actual_frame_rate,
                                                 self.averaging_interval)

        hb = self.buttonWidgets['Halt']
        self.halt_button = hb
        hb['state'] = 'disabled'

        rs = self.buttonWidgets['Report Scores']
        self.report_button = rs
        rs['state'] = 'disabled'

        import Tkinter
        from CGLtk import Hybrid

        row = 0
        parent.columnconfigure(0, weight=1)

        rt = Hybrid.Scrollable_Text(parent, None, 15, horizontal_scroll=False)
        rt.text['width'] = 50
        rt.text['wrap'] = 'word'
        self.results_box = rt.text
        rt.frame.grid(row=row, column=0, sticky='news')
        parent.rowconfigure(row, weight=1)
        row = row + 1

        descrip = (
            'Running benchmarks takes 5-10 minutes to complete.\n\n' +
            'Measure graphics card and CPU performance ' +
            'for volume data rendering.  The scores ' +
            'give the edge size of a cubic volume data ' +
            'array such that rendering or contouring or recoloring ' +
            'can be performed %.0f ' % self.target_fps +
            'times per second.\n\n' +
            'The surface and mesh benchmarks measure the ' +
            'rendering rates for triangles and lines respectively.  ' +
            'The contour benchmark measures ' +
            'CPU and memory performance.  ' +
            'The solid benchmark measures 2 dimensional texture ' +
            'mapping performance.  The recolor benchmark measures ' +
            'bandwidth to the graphics card.\n\n' +
            'The frame rate buttons give the redraw ' +
            'rate for your currently displayed view ' +
            'reported at one second intervals.\n\n' +
            'The molecule benchmark measures and reports frames per '
            'second when displaying different representations of molecules, '
            'and operations per second for the Ops call.\n\n'
            'For an accurate benchmark, please do not use the CPU for other '
            'tasks while benchmarks are running, and leave the entire Chimera '
            'graphics window visible.\n\n')
        self.show_result(descrip)
        self.results_box.see('1.0')

        frf = Tkinter.Frame(parent)
        frf.grid(row=row, column=0, sticky='w')
        row = row + 1

        mr = Hybrid.Checkbutton(frf, 'Measure frame rate continuously or ',
                                False)
        mr.button.grid(row=0, column=0, sticky='w')
        self.monitor_frame_rate = mr.variable
        self.monitor_frame_rate.add_callback(self.monitor_cb)

        frb = Tkinter.Button(frf,
                             text='one time',
                             command=self.actual_frame_rate)
        frb.grid(row=0, column=1, sticky='w')

        it = Hybrid.Checkbutton(parent, 'Show individual test controls', False)
        it.button.grid(row=row, column=0, sticky='w')
        row = row + 1

        itf = Tkinter.Frame(parent)
        itf.grid(row=row, column=0, sticky='w')
        row = row + 1
        trow = 0

        it.popup_frame(itf)
        it.popup_frame_cb()  # Hide panel

        bmb = Hybrid.Button_Row(itf, 'Run',
                                (('molecule', self.molSphere_benchmark),
                                 ('surface', self.surface_benchmark),
                                 ('mesh', self.mesh_benchmark),
                                 ('contour', self.contour_benchmark),
                                 ('solid', self.solid_benchmark),
                                 ('recolor', self.recolor_benchmark)))
        bmb.frame.grid(row=trow, column=0, sticky='w')
        trow += 1

        smf = Tkinter.Frame(itf)
        smf.grid(row=trow, column=0, sticky='w')
        trow += 1

        sml = Hybrid.Entry(smf, 'Show standard model, size ', 4,
                           repr(self.initial_size))
        sml.frame.grid(row=0, column=0, sticky='w')
        self.standard_model_size_var = sml.variable

        smb = Hybrid.Button_Row(smf, ', ', (
            ('surface', self.standard_surface),
            ('mesh', self.standard_mesh),
            ('solid', self.standard_solid),
        ))
        smb.frame.grid(row=0, column=1, sticky='w')

        sv = Hybrid.Button_Row(itf, 'Set standard view', (
            ('camera', self.set_standard_camera_parameters),
            ('window size', self.set_standard_window_size),
        ))
        sv.frame.grid(row=trow, column=0, sticky='w')
        trow += 1

        sf = Tkinter.Frame(parent)
        sf.grid(row=row, column=0, sticky='w')
        row += 1

        sb = Tkinter.Button(sf, text='Show', command=self.show_scores_web_page)
        sb.grid(row=0, column=0, sticky='w')

        sl = Tkinter.Label(sf, text=' scores reported by others')
        sl.grid(row=0, column=1, sticky='w')
Esempio n. 19
0
    def fillInUI(self, parent):
        from chimera.widgets import MoleculeScrolledListBox
        self.molList = MoleculeScrolledListBox(parent,
                                               labelpos='w',
                                               listbox_selectmode="extended",
                                               label_text="Solvate:    ")
        self.molList.grid(row=0, column=0, sticky="nsew")
        self.solvateMethod = Pmw.RadioSelect(parent,
                                             buttontype='radiobutton',
                                             command=self.changeMethod,
                                             labelpos='w',
                                             label_text="Solvate method:")
        self.solvateMethod.add("Box")
        self.solvateMethod.add("Cap")
        self.solvateMethod.add("Oct")
        self.solvateMethod.add("Shell")
        self.solvateMethod.setvalue("Box")
        self.solvateMethod.grid(row=1, column=0, sticky="nsew")
        self.method = "Box"
        rcf1 = Tkinter.Frame(parent)
        rcf1.grid(row=2, column=0, sticky="nsew")
        self.solvent = prefs[SOLVENT_MODEL]

        from Solvate import ValidSolventModels
        self.solventModel = Pmw.OptionMenu(rcf1,
                                           label_text="Solvent Model:",
                                           labelpos='w',
                                           items=ValidSolventModels,
                                           initialitem=self.solvent,
                                           command=self.changeSolvent)
        self.solventModel.grid(row=0, column=0)

        rcf2 = Tkinter.Frame(rcf1)
        rcf2.grid(row=0, column=1)
        rcf1.columnconfigure(1, weight=1)
        self.extentLabel = Tkinter.Label(rcf2, text="Box size:")
        self.extentLabel.grid(row=0, column=0)

        self.extentValue = Hybrid.StringVariable(rcf2)
        ev = Tkinter.Entry(rcf2,
                           width=5,
                           textvariable=self.extentValue.tk_variable)
        ev.grid(row=0, column=1)

        rcf3 = Tkinter.Frame(parent)
        rcf3.grid(row=3, column=0)
        self.centerLabel = Tkinter.Label(rcf3,
                                         text="Cap center (in ambmask):",
                                         state='disabled')
        self.centerLabel.grid(row=0, column=0)

        self.centerValue = Hybrid.StringVariable(rcf3)
        self.centerEntry = Tkinter.Entry(
            rcf3,
            width=5,
            textvariable=self.centerValue.tk_variable,
            state='disabled')
        self.centerEntry.grid(row=0, column=1)

        self.removeExisting = Hybrid.Checkbutton(
            parent, "Remove existing ions/solvent", True)
        self.removeExisting.button.grid(row=4, column=0)

        parent.rowconfigure(0, weight=1)
        parent.columnconfigure(0, weight=1)