コード例 #1
0
    def set_color_count(self, n):

        if n == self.n:
            return

        if n > len(self.colorwells):
            # Add more color buttons
            for c in range(len(self.colorwells), n):
                from CGLtk.color import ColorWell
                cw = ColorWell.ColorWell(self.frame)
                cw.grid(row=2 * (c / 5), column=c % 5)
                self.colorwells.append(cw)
                from CGLtk import Hybrid
                e = Hybrid.Entry(self.frame, '', 5, '')
                e.frame.grid(row=2 * (c / 5) + 1, column=c % 5)
                e.entry.bind('<KeyPress-Return>', self.colormap_changed_cb)
                self.entry_fields.append(e)

        # Map additional colorwells
        for c in range(self.n, n):
            self.colorwells[c].grid()
            self.entry_fields[c].frame.grid()

        # Unmap extra colorwells
        for c in range(n, self.n):
            self.colorwells[c].grid_remove()
            self.entry_fields[c].frame.grid_remove()

        self.n = n
コード例 #2
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.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
コード例 #3
0
  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])
コード例 #4
0
    def fillInUI(self, parent):

        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

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

        ea = Hybrid.Entry(parent, 'Euler angles ', 25, '0 0 0')
        ea.frame.grid(row=row, column=0, sticky='e')
        row = row + 1
        self.euler_angles = ea.variable

        tr = Hybrid.Entry(parent, 'Shift ', 25, '0 0 0')
        tr.frame.grid(row=row, column=0, sticky='e')
        row = row + 1
        self.translation = tr.variable

        cas = Tkinter.Label(parent, text='', justify='left')
        cas.grid(row=row, column=0, sticky='w')
        self.cumulative = cas
        row = row + 1

        el = Tkinter.Label(
            parent,
            text=
            'Apply rotation and translation to atom coordinates\n using the molecule coordinate system.',
            justify='left')
        el.grid(row=row, column=0, sticky='w')
        row = row + 1

        self.show_cumulative_transform(None)
コード例 #5
0
    def fillInUI(self, parent):

        SaveModeless.fillInUI(self, parent)

        from CGLtk import Hybrid
        br = Hybrid.Entry(self.clientArea, 'Bit rate (Kb/sec):', 6,
                          self.default_bit_rate)
        br.frame.grid(row=0, column=0, sticky='w')
        self.bit_rate = br.variable
コード例 #6
0
 def _componentsCB(self, opt, update=True):
     cf = self.componentsFrame
     if hasattr(self, 'wells'):
         for well in self.wells:
             well.grid_forget()
             well.destroy()
         for label in self.labels:
             label.frame.grid_forget()
         self.reverseButton.grid_forget()
         self.reverseButton.destroy()
     else:
         Tkinter.Label(cf, text="Colors").grid(row=0)
         Tkinter.Label(cf, text="Labels").grid(row=0, column=1)
     if isinstance(opt, int):
         numComponents = opt
         self.numComponents.set(opt)
     else:
         numComponents = opt.get()
     wellSize = min(38, int((7 * 38) / numComponents))
     from CGLtk.color.ColorWell import ColorWell
     self.wells = []
     self.labels = []
     from CGLtk import Hybrid
     for i in range(numComponents):
         well = ColorWell(cf,
                          width=wellSize,
                          height=wellSize,
                          callback=self._keyChangeCB,
                          color='white')
         well.grid(row=i + 1)
         self.wells.append(well)
         label = Hybrid.Entry(cf, "", 10)
         label.variable.add_callback(self._keyTypingCB)
         label.frame.grid(row=i + 1, column=1, sticky='ew')
         self.labels.append(label)
     self.reverseButton = Tkinter.Button(cf,
                                         command=self.reverseKey,
                                         text="Reverse ordering of above",
                                         pady=0)
     self.reverseButton.grid(row=numComponents + 1, column=0, columnspan=2)
     self.notebook.setnaturalsize()
     if update:
         self._keyChangeCB()
コード例 #7
0
    def fillInUI(self, parent):

        subsample_size_text = '(%d,%d,%d)' % self.subsample_size
        size_text = '(%d,%d,%d)' % self.full_data_size
        step_ranges = map(lambda r: '%d-%d' % r, self.allowed_step_ranges)
        allowed_steps = '%s %s %s' % tuple(step_ranges)
        msg = ('There are multiple possible subsample cell sizes for\n' +
               '%s %s as subsamples of %s %s.\n' %
               (self.subsample_name, subsample_size_text, self.full_data_name,
                size_text) + 'Possibile cell sizes are %s.' % allowed_steps)

        import Tkinter
        lbl = Tkinter.Label(parent, text=msg, justify='left')
        lbl.grid(row=0, column=0, sticky='w')

        csize = '%d %d %d' % tuple(
            map(lambda r: r[1], self.allowed_step_ranges))
        from CGLtk import Hybrid
        cs = Hybrid.Entry(parent, 'Cell size ', 15, csize)
        cs.frame.grid(row=1, column=0, sticky='w')
        self.cell_size_var = cs.variable
コード例 #8
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()
コード例 #9
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]
コード例 #10
0
    def fillInUI(self, parent):

        self.default_radius = 100
        self.surface_model = None
        self.surface_piece = None

        self.toplevel_widget = parent.winfo_toplevel()
        self.toplevel_widget.withdraw()
        parent.columnconfigure(0, weight=1)

        row = 0

        import Tkinter
        from CGLtk import Hybrid

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

        # Interpolation factor between icosahedron and sphere
        sf = Hybrid.Scale(parent, 'Sphere factor ', 0, 1, .01, 0)
        sf.frame.grid(row=row, column=0, sticky='ew')
        row = row + 1
        sf.callback(self.sphere_factor_changed_cb)
        sf.entry.bind('<KeyPress-Return>', self.sphere_factor_changed_cb)
        self.sphere_factor = sf

        # Orientation menu
        self.orient_222 = 'xyz 2-fold axes'
        self.orient_222r = 'xyz 2-fold axes, alt'
        self.orient_2n3 = 'x 2-fold, z 3-fold'
        self.orient_2n3r = 'x 2-fold, z 3-fold, alt'
        self.orient_2n5 = 'x 2-fold, z 5-fold'
        self.orient_2n5r = 'x 2-fold, z 5-fold, alt'
        self.orient_n25 = 'y 2-fold, z 5-fold'
        self.orient_n25r = 'y 2-fold, z 5-fold, alt'
        io = Hybrid.Option_Menu(parent, 'Orientation ', self.orient_222,
                                self.orient_222r, self.orient_2n3,
                                self.orient_2n3r, self.orient_2n5,
                                self.orient_2n5r, self.orient_n25,
                                self.orient_n25r)
        io.frame.grid(row=row, column=0, sticky='w')
        io.add_callback(self.show_cb)
        row = row + 1
        self.orientation = io.variable

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

        sb = Hybrid.Entry(sf, 'Subdivision factor ', 5, '1')
        sb.frame.grid(row=0, column=0, sticky='w')
        self.subdivision_factor = sb.variable
        sb.entry.bind('<KeyPress-Return>', self.show_cb)

        sp = Tkinter.Label(sf, text='')
        sp.grid(row=0, column=1, sticky='w')
        self.subdivision_spacing = sp

        # Surface style: filled, mesh
        st = Hybrid.Radiobutton_Row(parent, 'Surface style: ',
                                    ('solid', 'mesh'), self.style_changed_cb)
        st.frame.grid(row=row, column=0, sticky='w')
        st.variable.set('mesh', invoke_callbacks=False)
        row = row + 1
        self.surface_style = st.variable

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

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

        initial_color = (.7, .7, .7, 1)
        from CGLtk.color import ColorWell
        cw = ColorWell.ColorWell(cf, callback=self.color_changed_cb)
        cw.showColor(initial_color)
        cw.grid(row=0, column=1, sticky='w')
        self.color = cw

        #
        # 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

        import SimpleSession
        chimera.triggers.addHandler(SimpleSession.SAVE_SESSION,
                                    self.save_session_cb, None)
コード例 #11
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)
コード例 #12
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
コード例 #13
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
コード例 #14
0
    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
        from VolumeViewer import Volume_Menu

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

        # Map selection (only Volumes)
        fm = Volume_Menu(ff, 'Map: ')
        fm.frame.grid(row=0, column=0, sticky='w')
        self.map_menu = fm

        # Resolution
        rs = Hybrid.Entry(ff, 'Resolution ', 5)
        rs.frame.grid(row=0, column=1, sticky='w')
        self.resolution = rs.variable

        # Cut-off
        co = Hybrid.Entry(ff, 'Cut-off level ', 10)
        co.frame.grid(row=0, column=2, sticky='w')
        self.cutoff = co.variable

        self.save_button = Tkinter.Button(ff,
                                          text="From Volume Viewer",
                                          font=self.arialBondF,
                                          height=1,
                                          command=self.get_cutoff)
        self.save_button.grid(row=0, column=3, sticky='w')

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

        # Space
        msg = Tkinter.Label(hf, anchor='w', justify='left')
        msg.grid(row=2, column=0, sticky='ew')
        row = row + 1
        self.message_label = msg

        # PDB's panel
        self.pdbs = Tkinter.Frame(parent)
        self.pdbs.grid(row=3, column=0, sticky='ew')
        self.pdbs.columnconfigure(1, weight=1)

        from chimera.widgets import MoleculeScrolledListBox, \
            ModelOptionMenu
        self.modelList = MoleculeScrolledListBox(
            self.pdbs,
            labelpos='nw',
            label_text="Target PDBs to be fitted:",
            listbox_selectmode='extended',
            listbox_height=11)
        self.modelList.grid(row=row, column=0, sticky='nsew')
        self.pdbs.rowconfigure(row, weight=1)
        self.pdbs.columnconfigure(0, weight=1)

        self.modelList1 = MoleculeScrolledListBox(
            self.pdbs,
            labelpos='nw',
            label_text="Target PDBs to be fixed:",
            listbox_selectmode='extended',
            listbox_height=11)
        self.modelList1.grid(row=row, column=1, sticky='nsew')
        self.pdbs.rowconfigure(row, weight=1)
        self.pdbs.columnconfigure(0, weight=1)
        row += 1

        # Disable Results panel at first
        self.results_button = self.buttonWidgets['Results']
        self.results_button['state'] = 'disabled'
コード例 #15
0
    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")
コード例 #16
0
    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
コード例 #17
0
  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()
コード例 #18
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)
コード例 #19
0
    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
コード例 #20
0
ファイル: attributes.py プロジェクト: minghao2016/segger
    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()
コード例 #21
0
    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')
コード例 #22
0
    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()