示例#1
0
    def addProp(self, prop):
        if self.propWidgets.has_key(prop):
            return

        l = Tkinter.Label(self.propWidgetMaster, text=prop)
        l.grid(padx=2,
               pady=2,
               row=len(self.propWidgets) + 1,
               column=0,
               sticky='e')

        if prop in self.booleanProps:
            var = Tkinter.IntVar()
            var.set(0)
            cb = CallBackFunction(self.setBoolean, (prop, var))
            widget = Tkinter.Checkbutton(self.propWidgetMaster,
                                         variable=var,
                                         command=cb)
            self.propWidgets[prop] = (widget, var)
            self.setBoolean((prop, var))
        else:
            items = self.choiceProps[prop]
            var = None
            cb = CallBackFunction(self.setChoice, (prop, ))
            widget = Pmw.ComboBox(self.propWidgetMaster,
                                  entryfield_entry_width=15,
                                  scrolledlist_items=items,
                                  selectioncommand=cb)
            self.propWidgets[prop] = (widget, var)
            self.setChoice((prop, ), items[0])

        widget.grid(row=len(self.propWidgets), column=1, sticky='w')
示例#2
0
    def updateFastLibs(self):
        from CADD.nodeLibrariesCADD import libraries
        for key, value in libraries.items():
            try:
                if hasattr(self, 'fastLibsMenu'):
                    self.fastLibsMenu.index(key)
            except:
                if len(value) == 2:
                    func = CallBackFunction(self.loadLibModule,
                                            value[0],
                                            dependents=value[1])
                else:
                    func = CallBackFunction(self.loadLibModule, value)
                if hasattr(self, 'fastLibsMenu'):
                    self.fastLibsMenu.add_command(label=key, command=func)

            try:
                if hasattr(self, 'fastLibsMenu2'):
                    self.fastLibsMenu2.index(key)
            except:
                if len(value) == 2:
                    func = CallBackFunction(self.loadLibModule,
                                            value[0],
                                            dependents=value[1])
                else:
                    func = CallBackFunction(self.loadLibModule, value)
                if hasattr(self, 'fastLibsMenu2'):
                    self.fastLibsMenu2.add_command(label=key, command=func)
示例#3
0
 def addViewButton(self, name, icon=True):
     """ Creates an image button ."""
     viewsContainer = self.idf.entryByName['viewsContainer']['widget']
     if self.allViews == 0:
         self.viewsBalloon.bind(
             viewsContainer._ring,
             "Right click on view's image\nto display its menu")
     if icon == True:
         self.form.master.lift()
         photo = self.vf.GUI.VIEWER.GUI.getButtonIcon()
         b = Tkinter.Button(master=viewsContainer.interior(),
                            compound='left',
                            image=photo,
                            command=CallBackFunction(
                                self.activateView, name))
         b.photo = photo
     else:
         b = Tkinter.Button(master=viewsContainer.interior(),
                            text=name,
                            width=4,
                            height=3,
                            wraplength=50)
         b.configure(command=CallBackFunction(self.activateView, name, b))
     self.viewsBalloon.bind(b, name)
     b.name = name
     #print "row=", 1+(len(self.views)-1)/5, "column=", (len(self.views)-1)%5
     b.grid(row=1 + (len(self.views) - 1) / 5,
            column=(len(self.views) - 1) % 5,
            sticky='w')
     self.form.autoSize()
     b.bind('<Button-3>', CallBackFunction(self.showViewMenu_cb, name))
     self.allViews = self.allViews + 1
示例#4
0
 def renameView(self, name):
     """Give a new name to the selected view. """
     from tkSimpleDialog import askstring
     viewsContainer = self.idf.entryByName['viewsContainer'][
         'widget'].interior()
     newname = askstring("Rename %s" % name,
                         "Enter new name:",
                         initialvalue=name,
                         parent=viewsContainer)
     if newname != None and newname != name:
         if self.views.has_key(newname):
             from tkMessageBox import showwarning
             showwarning("Warning",
                         "View name %s already exists" % newname,
                         parent=viewsContainer)
             return
         #find cooresponding button, rename it and update the bindings:
         for b in viewsContainer.grid_slaves():
             if hasattr(b, "name"):
                 if b.name == name:
                     b.name = newname
                     b.configure(command=CallBackFunction(
                         self.activateView, newname))
                     b.bind('<Button-3>',
                            CallBackFunction(self.showViewMenu_cb, newname))
                     self.viewsBalloon.bind(b, newname)
                     view = self.views.pop(name)
                     self.views[newname] = view
                     dr = self.viewsDirectors.pop(name)
                     self.viewsDirectors[newname] = dr
                     if dr.gui != None:
                         dr.gui.root.title(newname)
                     repr = self.representations.pop(name)
                     self.representations[newname] = repr
                     break
示例#5
0
    def guiCallback(self):
        ifd = InputFormDescr(title='Show/Hide VFGUI components ')
        for name in ['infoBar', 'MESSAGE_BOX']:
            w = self.getWidget(name)
            var = Tkinter.IntVar()
            self.tkvarDict[name] = var
            cb = CallBackFunction(self.callback, name, var)
            ifd.append({
                'widgetType': Tkinter.Checkbutton,
                'name': name,
                'wcfg': {
                    'text': name,
                    'command': cb,
                    'variable': var,
                },
                'defaultValue': w.winfo_ismapped(),
                'gridcfg': {
                    'sticky': Tkinter.W
                }
            })

        posy = 0
        for name in self.vf.GUI.menuBars.keys():
            w = self.getWidget(name)
            var = Tkinter.IntVar()
            self.tkvarDict[name] = var
            cb = CallBackFunction(self.callback, name, var)
            ifd.append({
                'widgetType': Tkinter.Checkbutton,
                'name': name,
                'wcfg': {
                    'text': name,
                    'command': cb,
                    'variable': var,
                },
                'defaultValue': w.winfo_ismapped(),
                'gridcfg': {
                    'sticky': Tkinter.W,
                    'column': 1,
                    'row': posy
                }
            })
            posy = posy + 1

        ifd.append({
            'widgetType': Tkinter.Button,
            'name': 'dismiss',
            'wcfg': {
                'text': 'dismiss',
                'command': self.dismiss_cb
            },
            'gridcfg': {
                'columnspan': 2
            },
        })
        self.ifd = ifd
        val = self.vf.getUserInput(ifd, modal=0)
示例#6
0
 def __init__(self, parent, buttonType = Tkinter.Checkbutton,
              callback=None,
              buttonwcfg={'text':'function'},textwcfg = {}):
     buttonwcfg['command'] = CallBackFunction(self.buildText,parent,
                                              textwcfg,
                                              buttonwcfg)
     self.button = apply(buttonType,(parent,),buttonwcfg)
     self.callback = callback
示例#7
0
 def showViewMenu_cb(self, name, event=None):
     edit = self.viewMenu.index("Edit")
     rn = self.viewMenu.index("Rename")
     rm = self.viewMenu.index("Remove")
     update = self.viewMenu.index("Update icon")
     self.viewMenu.entryconfigure(edit,
                                  command=CallBackFunction(
                                      self.editView, name))
     self.viewMenu.entryconfigure(rn,
                                  command=CallBackFunction(
                                      self.renameView, name))
     self.viewMenu.entryconfigure(rm,
                                  command=CallBackFunction(
                                      self.removeView, name))
     self.viewMenu.entryconfigure(update,
                                  command=CallBackFunction(
                                      self.updateViewIcon, name))
     self.viewMenu.post(event.x_root, event.y_root)
示例#8
0
 def __init__(self, root, buttonType = Tkinter.Button,
              widgetwcfg={'text':'Save'},
              title='Save In File ',
              idir = None, ifile = None, types = [('All types', '*.*')],
              callback=None):
     widgetwcfg['command']= CallBackFunction(
         self.save_cb, title, idir, ifile, types, callback)
     self.button = apply(buttonType, (root,), widgetwcfg)
     #self.master = master
     self.root = root
     self.filename = None
    def initICOM(self, modifier):
        # set the callback of continuousPicking to label the picked node
        # 1- get a handle on the cbManager
        cbManager = self.vf.startContinuousPicking.cbManager
        # 2- Save the existing callbacks
        #self.oldCallBacks = cbManager.callbacks
        # 3- Set to the new callback
        cbManager.SetCallback(CallBackFunction(self.labelByName))

        self.vf.startContinuousPicking()
        self.supcb = 0
示例#10
0
 def showMenu_cb(self, maa, event=None):
     """
     configure callback of menu entried with the current orientation and post
     menu
     """
     menu = Tkinter.Menu(self.master, title="Animation")
     from Scenario2 import addTargetsToMenu
     addTargetsToMenu(menu, maa)
     menu.add_command(label="Delete",
                      command=CallBackFunction(self.clipboard.removeMaa,
                                               maa))
     menu.add_command(label="Dismiss")
     menu.post(event.x_root, event.y_root)
示例#11
0
 def configure(self,
               title='',
               idir=None,
               ifile=None,
               types=[('All types', '*.*')],
               callback=None):
     newcb = CallBackFunction(self.save_cb,
                              title=title,
                              idir=idir,
                              ifile=ifile,
                              types=types,
                              callback=callback)
     self.button.configure(command=newcb)
示例#12
0
 def prepareQuickKeys(self):
     import Tkinter
     from mglutil.util.callback import CallBackFunction
     #prepare the QuickKeys one for the root, one for the handler
     self.vf.GUI.VIEWER.GUI.showHideQuickKeysVar.set(1)
     xform = 'Object'
     root = self.vf.GUI.VIEWER.rootObject
     cbroot = CallBackFunction(self.vf.GUI.VIEWER.GUI.quickKey_cb, xform,
                               root, 1)
     cbhandler = CallBackFunction(self.vf.GUI.VIEWER.GUI.quickKey_cb, xform,
                                  self.geom, 0)
     label = "Xform Scene"
     labelHandler = "Xform Handler"
     # create a button and add it to the Quick Keys panel
     button = Tkinter.Button(self.vf.GUI.VIEWER.GUI.QuickKeysFrame,
                             text=label,
                             command=cbroot)
     button.pack(side='top', expand=1, fill='y')
     # create a button and add it to the Quick Keys panel
     button = Tkinter.Button(self.vf.GUI.VIEWER.GUI.QuickKeysFrame,
                             text=labelHandler,
                             command=cbhandler)
     button.pack(side='top', expand=1, fill='y')
 def __init__(self,
              root,
              buttonType=tkinter.Button,
              widgetwcfg={'text': 'Load'},
              title='Load File',
              idir=None,
              ifile=None,
              types=[('All types', '*.*')],
              callback=None):
     self.root = root
     widgetwcfg['command'] = CallBackFunction(self.load_cb, title, idir,
                                              ifile, types, callback)
     self.button = buttonType(*(root, ), **widgetwcfg)
     #self.master = master
     self.filename = None
示例#14
0
    def initICOM(self, modifier):
        # Create the form if not existing yet
        form = self.showForm(formName = 'superimpose', modal=0, blocking=0)
        self.firstLabel = form.descr.entryByName['firstNode']['widget']
        self.secondLabel = form.descr.entryByName['secondNode']['widget']

        self.contVar = form.descr.entryByName['continuous']['wcfg']['variable']
        self.pairForm = None

        # set the callback of continuousPicking to label the picked node
        # 1- get a handle on the cbManager
        cbManager  = self.vf.startContinuousPicking.cbManager
        # 2- Save the existing callbacks
        self.oldCallBacks = cbManager.callbacks
        # 3- Set to the new callback
        cbManager.SetCallback(CallBackFunction(self.labelByName))
        
        self.vf.startContinuousPicking()
        self.supcb = 0
示例#15
0
    def _addMAA(self, maa):
        """
         Create an entry for a MAA
         """

        master = self.MAAContainer.interior()

        self.maaw[maa] = frame = Tkinter.Frame(master)

        b = Tkinter.Button(master=frame,
                           compound='left',
                           text=maa.name,
                           command=maa.run,
                           width=25,
                           height=2)

        b.name = maa.name
        # create the button menu
        b.bind('<Button-3>', CallBackFunction(self.showMenu_cb, maa))

        b.pack(side='top')
        frame.pack()
示例#16
0
    def guiCallback(self):
        molNames = []
        for mol in self.vf.Mols:
            if hasattr(mol, 'spaceGroup'):
                molNames.append(mol.name)
        if not molNames:
            tkMessageBox.showinfo(
                "Crystal Info is Needed",
                "No Molecule in the Viewer has Crystal Info.")
            return
        ifd = InputFormDescr(title='Crystal Info')
        ifd.append({
            'name': 'moleculeList',
            'widgetType': Pmw.ScrolledListBox,
            'tooltip': 'Select a molecule with Crystal Info.',
            'wcfg': {
                'label_text': 'Select Molecule: ',
                'labelpos': 'nw',
                'items': molNames,
                'listbox_selectmode': 'single',
                'listbox_exportselection': 0,
                'usehullsize': 1,
                'hull_width': 100,
                'hull_height': 150,
                'listbox_height': 5
            },
            'gridcfg': {
                'sticky': 'nsew',
                'row': 1,
                'column': 0
            }
        })
        val = self.vf.getUserInput(ifd, modal=1, blocking=1)
        if val:
            molecule = self.vf.getMolFromName(val['moleculeList'][0])
            matrices = instanceMatricesFromGroup(molecule)
            geom = molecule.geomContainer.geoms['master']
            geom.Set(instanceMatrices=matrices)
            if not molecule.geomContainer.geoms.has_key('Unit Cell'):
                fractCoords = ((1, 1, 0), (0, 1, 0), (0, 0, 0), (1, 0, 0),
                               (1, 1, 1), (0, 1, 1), (0, 0, 1), (1, 0, 1))
                coords = []
                coords = molecule.crystal.toCartesian(fractCoords)
                box = Box('Unit Cell', vertices=coords)
                self.vf.GUI.VIEWER.AddObject(box, parent=geom)
                molecule.geomContainer.geoms['Unit Cell'] = box
            ifd = InputFormDescr(title='Crystal Options')
            visible = molecule.geomContainer.geoms['Unit Cell'].visible
            if visible:
                showState = 'active'
            else:
                showState = 'normal'
            ifd.append({
                'name': 'Show Cell',
                'widgetType': Tkinter.Checkbutton,
                'text': 'Hide Unit Cell',
                'state': showState,
                'gridcfg': {
                    'sticky': Tkinter.W
                },
                'command': CallBackFunction(self.showUnitCell, molecule)
            })

            ifd.append({
                'name': 'Show Packing',
                'widgetType': Tkinter.Checkbutton,
                'text': 'Hide Packing',
                'state': 'active',
                'gridcfg': {
                    'sticky': Tkinter.W
                },
                'command': CallBackFunction(self.showPacking, molecule)
            })

            val = self.vf.getUserInput(ifd, modal=0, blocking=1)
            if not val:
                geom.Set(instanceMatrices=[numpy.eye(4, 4)])
                molecule.geomContainer.geoms['Unit Cell'].Set(visible=False)
示例#17
0
    def guiCallback(self):
        idf = InputFormDescr(title="Set User Preferences")

        categoryList = ['General']
        for value in self.vf.userpref.values():
            if not value['category'] in categoryList:
                categoryList.append(value['category'])

        widgetType = {
            'widgetType': Pmw.NoteBook,
            'name': 'prefNotebook',
            'container': {},
            'wcfg': {
                'borderwidth': 2
            },
            'componentcfg': [],
            'gridcfg': {
                'sticky': 'we'
            },
        }
        for item in categoryList:
            widgetType['container'][item] = "w.page('" + item + "')"
            widgetType['componentcfg'].append({'name': item, 'cfg': {}})

        idf.append(widgetType)
        for item in categoryList:
            idf.append({
                'name': item + "Group",
                'widgetType': Pmw.Group,
                'parent': item,
                'container': {
                    item + 'Group': 'w.interior()'
                },
                'wcfg': {
                    'tag_text': item
                },
                'gridcfg': {
                    'sticky': 'wne'
                }
            })
        for key, value in self.vf.userpref.items():
            if not self.updateGUI in self.vf.userpref[key]['callbackFunc']:
                self.vf.userpref.addCallback(key, self.updateGUI)
            # put a label to have more space between the widget Maybe
            # could replace it by using the options padx and pady.
            group = value['category'] + "Group"
            idf.append({
                'widgetType': Tkinter.Label,
                'parent': group,
                'wcfg': {
                    'text': ''
                },
                'gridcfg': {
                    'sticky': 'we',
                    'columnspan': 3
                }
            })

            if value.has_key('validValues') and value['validValues']:
                idf.append({
                    'widgetType': Pmw.ComboBox,
                    'parent': group,
                    'name': key,
                    'defaultValue': value['value'],
                    'wcfg': {
                        'label_text': key,
                        'labelpos': 'n',
                        'scrolledlist_items': value['validValues']
                    },
                    'gridcfg': {
                        'sticky': 'wens'
                    }
                })
            else:

                if value.has_key('validateFunc') and value['validateFunc']:

                    def valid(value, func=value['validateFunc']):
                        test = func(value)
                        if test == 1:
                            return Pmw.OK
                        else:
                            return Pmw.PARTIAL

                    idf.append({
                        'widgetType': Pmw.EntryField,
                        'parent': group,
                        'name': key,
                        'wcfg': {
                            'label_text': key,
                            'labelpos': 'n',
                            'value': value['value'],
                            'validate': {
                                'validator': valid
                            }
                        },
                        'gridcfg': {
                            'sticky': 'wens'
                        }
                    })
                else:
                    idf.append({
                        'widgetType': Pmw.EntryField,
                        'parent': group,
                        'name': key,
                        'wcfg': {
                            'label_text': key,
                            'labelpos': 'n'
                        },
                        'gridcfg': {
                            'sticky': 'wens'
                        }
                    })

            idf.append({
                'widgetType': Tkinter.Button,
                'parent': group,
                'wcfg': {
                    'bitmap': 'info',
                    'width': 50,
                    'height': 40,
                    'padx': 10,
                    'command': CallBackFunction(self.info_cb, value['doc'])
                },
                'gridcfg': {
                    'row': -1,
                    'sticky': 'wens'
                }
            })

            idf.append({
                'widgetType': Tkinter.Button,
                'parent': group,
                'wcfg': {
                    'text': 'Make \nDefault',
                    'padx': 10,
                    'command': CallBackFunction(self.default_cb, key)
                },
                'gridcfg': {
                    'row': -1,
                    'sticky': 'wens'
                }
            })

            idf.append({
                'widgetType': Tkinter.Button,
                'parent': group,
                'wcfg': {
                    'text': 'Set',
                    'padx': 10,
                    'height': 2,
                    'width': 5,
                    'command': CallBackFunction(self.set_cb, key)
                },
                'gridcfg': {
                    'row': -1,
                    'sticky': 'wens'
                }
            })

        idf.append({
            'widgetType': Tkinter.Button,
            'wcfg': {
                'text': 'Dismiss',
                'command': self.dismissForm
            },
            'gridcfg': {
                'sticky': 'we',
                'columnspan': 4
            }
        })

        self.form = self.vf.getUserInput(idf, modal=0, blocking=0)
示例#18
0
 def getIfd(self, atNames):
     #cylinders
     if not hasattr(self, 'ifd'):
         ifd = self.ifd = InputFormDescr(
             title='Show Hydrogen Bonds as Cylinders')
         ifd.append({
             'name': 'hbondLabel',
             'widgetType': Tkinter.Label,
             'wcfg': {
                 'text':
                 str(len(atNames)) +
                 ' Atoms in hbonds:\n(1=visible, 0 not visible)'
             },
             'gridcfg': {
                 'sticky': 'wens',
                 'columnspan': 2
             }
         })
         ifd.append({
             'name': 'atsLC',
             'widgetType': ListChooser,
             'wcfg': {
                 'entries': atNames,
                 'mode': 'multiple',
                 'title': '',
                 'command': CallBackFunction(self.showHBondLC, atNames),
                 'lbwcfg': {
                     'height': 5,
                     'selectforeground': 'red',
                     'exportselection': 0,
                     'width': 30
                 },
             },
             'gridcfg': {
                 'sticky': 'wens',
                 'row': 2,
                 'column': 0,
                 'columnspan': 2
             }
         })
         ifd.append({
             'name': 'radii',
             'widgetType': ExtendedSliderWidget,
             'wcfg': {
                 'label': 'radii',
                 'minval': .01,
                 'maxval': 1.0,
                 'immediate': 1,
                 'init': .2,
                 'width': 250,
                 'command': self.update,
                 'sliderType': 'float',
                 'entrypackcfg': {
                     'side': 'right'
                 }
             },
             'gridcfg': {
                 'sticky': 'wens',
                 'columnspan': 2
             }
         })
         ifd.append({
             'name': 'length',
             'widgetType': ExtendedSliderWidget,
             'wcfg': {
                 'label': 'length',
                 'minval': .01,
                 'maxval': 5.0,
                 'immediate': 1,
                 'init': 1.0,
                 'width': 250,
                 'command': self.update,
                 'sliderType': 'float',
                 'entrypackcfg': {
                     'side': 'right'
                 }
             },
             'gridcfg': {
                 'sticky': 'wens',
                 'columnspan': 2
             }
         })
         ifd.append({
             'name': 'changeVertsBut',
             'widgetType': Tkinter.Button,
             'wcfg': {
                 'text': 'Set anchors',
                 'command': self.changeDVerts
             },
             'gridcfg': {
                 'sticky': 'wens'
             }
         })
         ifd.append({
             'name': 'changeColorBut',
             'widgetType': Tkinter.Button,
             'wcfg': {
                 'text': 'Change color',
                 'command': self.changeColor
             },
             'gridcfg': {
                 'sticky': 'wes',
                 'row': -1,
                 'column': 1
             }
         })
         ifd.append({
             'name': 'closeBut',
             'widgetType': Tkinter.Button,
             'wcfg': {
                 'text': 'Dismiss',
                 'command': self.dismiss_cb
             },
             'gridcfg': {
                 'sticky': 'wens',
                 'columnspan': 2
             }
         })
示例#19
0
    def changeDVerts(self, event=None):
        #for all residues in hbonds, pick new donorAttachment
        # and new acceptorAttachment
        entries = []
        ns = ['N', 'C', 'O', 'CA', 'reset']
        for n in ns:
            entries.append((n, None))

        if hasattr(self, 'form2'):
            self.form2.root.tkraise()
            return
        ifd2 = self.ifd2 = InputFormDescr(title='Set Anchor Atoms')
        ifd2.append({
            'name': 'datsLC',
            'widgetType': ListChooser,
            'wcfg': {
                'entries': entries,
                'mode': 'single',
                'title': 'Donor Anchor',
                'command': CallBackFunction(self.setDVerts, entries),
                'lbwcfg': {
                    'height': 5,
                    'selectforeground': 'red',
                    'exportselection': 0,
                    #'lbpackcfg':{'fill':'both', 'expand':1},
                    'width': 30
                },
            },
            'gridcfg': {
                'sticky': 'wens',
                'columnspan': 2
            }
        })
        ifd2.append({
            'name': 'aatsLC',
            'widgetType': ListChooser,
            'wcfg': {
                'entries': entries,
                'mode': 'single',
                'title': 'Acceptor Anchor',
                'command': CallBackFunction(self.setAVerts, entries),
                'lbwcfg': {
                    'height': 5,
                    'selectforeground': 'red',
                    #'lbpackcfg':{'fill':'both', 'expand':1},
                    'exportselection': 0,
                    'width': 30
                },
            },
            'gridcfg': {
                'sticky': 'wens',
                'columnspan': 2
            }
        })
        ifd2.append({
            'name': 'doneBut',
            'widgetType': Tkinter.Button,
            'wcfg': {
                'text': 'Done',
                'command': self.closeChangeDVertLC
            },
            'gridcfg': {
                'sticky': 'wens'
            }
        })
        self.form2 = self.vf.getUserInput(self.ifd2, modal=0, blocking=0)
        self.form2.root.protocol('WM_DELETE_WINDOW', self.closeChangeDVertLC)
示例#20
0
    def guiCallback(self):

        if self.form: return
        self.fileWritten = 0
        # get a list of povray include files
        inclist = os.listdir(self.PovrayIncDir)
        inclist.sort()

        # get a list of geometries
        self.geomList = {}
        self.properties = {}
        for m in self.vf.Mols:
            for g in m.geomContainer.geoms.values():
                if g.visible and g.__class__.__name__ != 'Geom':
                    name = '%s_%s' % (m.name, g.name)
                    self.geomList[name] = g
                    self.properties[name] = {
                        'pigment': '',
                        'finish': 'specular 1 roughness 0.001 ambient 0.3'
                    }

        for g in self.vf.GUI.VIEWER.rootObject.children:
            if g.visible and g.__class__.__name__ != 'Geom':
                name = g.name
                self.geomList[name] = g
                self.properties[name] = {
                    'pigment': '',
                    'finish': 'specular 1 roughness 0.001 ambient 0.3'
                }

        idf = InputFormDescr(title="PovRay")
        incEntries = map(lambda x: (x, None), inclist)
        idf.append({
            'name': 'includes',
            'widgetType': ListChooser,
            'wcfg': {
                'entries': incEntries,
                'title': 'Select include files',
                'mode': 'extended',
                'lbwcfg': {
                    'height': 5,
                    'exportselection': 0
                }
            },
            'gridcfg': {
                'rowspan': 4,
                'column': 0,
                'row': 0
            },
        })

        ##          idf.append({'name':'includes','title':'Select include files',
        ##                      'widgetType':'ListChooser',
        ##                      'entries': inclist,
        ##                      'mode':'extended',
        ##                      'gridcfg':{'rowspan':4,'column':0,'row':0},
        ##                      'lbwcfg':{'height':5}} )

        geomsEntries = map(lambda x: (x, None), self.geomList.keys())
        ##          idf.append({'name':'geometries',
        ##                      'widgetType':ListChooser,
        ##                      'wcfg':{'title':'Select geometries',
        ##                              'entries': geomsEntries,
        ##                              'lbwcfg':{'height':5}},
        ##                      'gridcfg':{'rowspan':4,'column':1,'row':0}}
        ##                       )
        ##          idf.append({'name':'geometries','title':'Select geometries',
        ##                      'widgetType':'ListChooser',
        ##                      'entries': self.geomList.keys(),
        ##                      'gridcfg':{'rowspan':4,'column':1,'row':0},
        ##                      'lbwcfg':{'height':5}} )

        ##          idf.append({'name':'AddIncButton',
        ##                      'widgetType':Tkinter.Button,
        ##                      'wcfg':{'text':'->',
        ##                              'command': CallBackFunction( self.addGeometry,
        ##                                                           (idf))},
        ##                      'gridcfg':{'column':2,'row':1}})

        ##          idf.append({'name':'RemoveIncButton',
        ##                      'widgetType':Tkinter.Button,
        ##                      'wcfg':{'text':'<-',
        ##                              'command': CallBackFunction( self.removeGeometry,
        ##                                                           (idf))},
        ##                      'gridcfg':{'column':2,'row':2}})

        ##          idf.append({'name':'selectedGeometries','title':'Selected geometries',
        ##                      'widgetType':'ListChooser',
        ##                      'entries': self.geomList.keys(),
        ##                      'lbwcfg':{'height':5},
        ##                      'gridcfg':{'rowspan':4, 'column':3, 'row':0}})
        idf.append({
            'name': 'selectedGeometries',
            'widgetType': ListChooser,
            'wcfg': {
                'title': 'Selected geometries',
                'entries': geomsEntries,
                'mode': 'single',
                'lbwcfg': {
                    'height': 5,
                    'exportselection': 0
                }
            },
            'gridcfg': {
                'rowspan': 4,
                'column': 3,
                'row': 0
            }
        })

        ##          idf.append({'name':'pigment','label':'Pigment   ',
        ##                      'widgetType':Tkinter.Entry, 'wcfg':{'width':40},
        ##                      'gridcfg':{'columnspan':2, 'column':0,
        ##                                 'row':4, 'sticky':'w'}})
        idf.append({
            'widgetType': Pmw.EntryField,
            'name': 'pigment',
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Pigment   ',
                'validate': None,
                'entry_width': 40
            },
            'gridcfg': {
                'columnspan': 2,
                'column': 0,
                'row': 4,
                'sticky': 'w'
            }
        })

        ##          idf.append({'name':'finish','label':'Finish      ',
        ##                      'widgetType':Tkinter.Entry, 'wcfg':{'width':40},
        ##                      'gridcfg':{'columnspan':2, 'column':0,
        ##                                 'row':5, 'sticky':'w'}})
        idf.append({
            'widgetType': Pmw.EntryField,
            'name': 'finish',
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Finish      ',
                'validate': None,
                'entry_width': 40
            },
            'gridcfg': {
                'columnspan': 2,
                'column': 0,
                'row': 5,
                'sticky': 'w'
            }
        })

        ##          idf.append({'name':'scaleLight',
        ##                      'label':'Light scale factor', 'type':float,
        ##                      'widgetType':Tkinter.Entry, 'wcfg':{'width':5},
        ##                      'defaultValue': '2.0',
        ##                      'gridcfg':{'column':3, 'row':4, 'sticky':'e'}})
        idf.append({
            'name': 'scaleLight',
            'widgetType': Pmw.EntryField,
            'type': float,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Light scale factor',
                'validate': 'real',
                'value': 2.0,
                'entry_width': 5
            },
            'gridcfg': {
                'column': 3,
                'row': 4,
                'sticky': 'e'
            }
        })

        ##          idf.append({'name':'scaleImage',
        ##                      'label':'scale Image', 'type':float,
        ##                      'widgetType':Tkinter.Entry, 'wcfg':{'width':5},
        ##                      'defaultValue': '1.0',
        ##                      'gridcfg':{'column':3, 'row':5, 'sticky':'e'}})
        idf.append({
            'name': 'scaleImage',
            'widgetType': Pmw.EntryField,
            'type': float,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'scale Image',
                'entry_width': 5,
                'validate': 'real',
                'value': 1.0
            },
            'gridcfg': {
                'column': 3,
                'row': 5,
                'sticky': 'e'
            }
        })

        ##          idf.append({'name':'bondRadius','label':'bond Radius', 'type':float,
        ##                      'widgetType':Tkinter.Entry, 'wcfg':{'width':5},
        ##                      'defaultValue': '0.15',
        ##                      'gridcfg':{'column':3, 'row':6, 'sticky':'e'}})
        idf.append({
            'name': 'bondRadius',
            'widgetType': Pmw.EntryField,
            'type': float,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'bond Radius',
                'entry_width': 5,
                'validate': 'real',
                'value': 0.15
            },
            'gridcfg': {
                'column': 3,
                'row': 6,
                'sticky': 'e'
            }
        })

        ##          idf.append({'name':'fileName','label':'File Name',
        ##                      'widgetType':Tkinter.Entry,
        ##                      'defaultValue':'test.pov',
        ##                      'wcfg':{'width':40},
        ##                      'gridcfg':{'columnspan':2,'column':0,'row':6,'sticky':'w'}})
        idf.append({
            'name': 'fileName',
            'widgetType': Pmw.EntryField,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'File Name',
                'entry_width': 40,
                'value': 'test.pov',
            },
            'gridcfg': {
                'columnspan': 2,
                'column': 0,
                'row': 6,
                'sticky': 'w'
            }
        })

        ##          idf.append({'name':'povrayBin','label':'Povray binary',
        ##                      'widgetType':Tkinter.Entry,
        ##                      'defaultValue':'povray',
        ##                      'wcfg':{'width':40},
        ##                      'gridcfg':{'columnspan':2,'column':0,'row':7,'sticky':'w'}})
        idf.append({
            'name': 'povrayBin',
            'widgetType': Pmw.EntryField,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Povray binary',
                'value': 'povray',
                'entry_width': 40
            },
            'gridcfg': {
                'columnspan': 2,
                'column': 0,
                'row': 7,
                'sticky': 'w'
            }
        })

        idf.append({
            'name': 'wbg',
            'widgetType': Tkinter.Checkbutton,
            'defaultValue': 1,
            'wcfg': {
                'text': 'White Background',
                'variable': Tkinter.IntVar()
            },
            'gridcfg': {
                'column': 3,
                'row': 7,
                'sticky': 'e'
            }
        })

        ##          idf.append({'name':'povrayArgs','label':'cmdline arguments',
        ##                      'widgetType':Tkinter.Entry,
        ##                      'defaultValue':'+D0 +P +X -V +FN +QR',
        ##                      'wcfg':{'width':40},
        ##                      'gridcfg':{'columnspan':2,'column':0,'row':8,'sticky':'w'}})
        idf.append({
            'name': 'povrayArgs',
            'widgetType': Pmw.EntryField,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'cmdline arguments',
                'value': '+D0',  # +P +X -V +FN +QR',
                'entry_width': 40
            },
            'gridcfg': {
                'columnspan': 2,
                'column': 0,
                'row': 8,
                'sticky': 'w'
            }
        })

        ##          idf.append({'name':'imageFile','label':'image file',
        ##                      'widgetType':Tkinter.Entry,
        ##                      'wcfg':{'width':40},
        ##                      'gridcfg':{'columnspan':2,'column':0,'row':9,'sticky':'w'}})
        idf.append({
            'name': 'imageFile',
            'widgetType': Pmw.EntryField,
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'image file',
                'entry_width': 40
            },
            'gridcfg': {
                'columnspan': 2,
                'column': 0,
                'row': 9,
                'sticky': 'w'
            }
        })

        idf.append({
            'name': 'WriteFile',
            'widgetType': Tkinter.Button,
            'wcfg': {
                'text': 'WriteFile',
                'command': self.writeFile
            },
            'gridcfg': {
                'columnspan': 1,
                'column': 0,
                'row': 10,
                'sticky': 'ew'
            }
        })

        idf.append({
            'name': 'Render',
            'widgetType': Tkinter.Button,
            'wcfg': {
                'text': 'Render',
                'command': CallBackFunction(self.runPovray, (idf))
            },
            'gridcfg': {
                'columnspan': 2,
                'column': 1,
                'row': 10,
                'sticky': 'ew'
            }
        })

        idf.append({
            'name': 'Dismiss',
            'widgetType': Tkinter.Button,
            'wcfg': {
                'text': 'Dismiss',
                'command': self.dismissCB
            },
            'gridcfg': {
                'column': 3,
                'row': 10,
                'sticky': 'ew'
            }
        })

        self.form = self.vf.getUserInput(idf, modal=0, blocking=0)
        lb = idf.entryByName['selectedGeometries']['widget'].lb
        lb.bind("<ButtonRelease-1>", self.updateProps, '+')

        e1 = idf.entryByName['pigment']['widget']
        e1.bind("<Return>", self.bindPigment)

        e2 = idf.entryByName['finish']['widget']
        e2.bind("<Return>", self.bindFinish)
示例#21
0
    def guiCallback(self):

        if self.form: return
        self.fileWritten = 0
        
        # get a list of geometries
        self.geomList = {}
        self.properties = {}
        for m in self.vf.Mols:
            for g in m.geomContainer.geoms.values():
                if g.visible and g.__class__.__name__ != 'Geom':
                    name = '%s_%s'%(m.name,g.name)
                    self.geomList[name] = g
                    self.properties[name] = {'pigment':'',
                                             'finish':''}

        for g in self.vf.GUI.VIEWER.rootObject.children:
            if g.visible and g.__class__.__name__ != 'Geom':
                name = g.name
                self.geomList[name] = g
                self.properties[name] = {'pigment':'',
                                         'finish':''}
            
        idf = InputFormDescr(title ="Gelato")

        geomsEntries = map(lambda x: (x,None),self.geomList.keys())
        idf.append({'name':'selectedGeometries',
                    'widgetType':ListChooser,
                    'wcfg':{'title':'Selected geometries',
                            'entries': geomsEntries,
                            'mode':'multiple',
                            'lbwcfg':{'height':5,'exportselection':0}},
                    'gridcfg':{'rowspan':4, 'column':0, 'row':0}})
	from DejaVu.gelato import Shader
	#shaderD = Shader.ShaderDic
	#shaderEntries = map(lambda x: (x,None),Shader.ShaderDic.keys())
	shaderEntries = Shader.ShaderDic.keys()

        idf.append({'widgetType':Pmw.ComboBox,
                    'name':'pigment',
                    'wcfg':{'labelpos':'w',
                            'label_text':'Shader',
                            'scrolledlist_items' : shaderEntries,
			    'scrolledlist_listbox_width':7,
			    #'width':40
                            },
                    'gridcfg':{'columnspan':2, 'column':0,
                               'row':4, 'sticky':'w'}})
        idf.append({'name':'Apply',
                    'widgetType':Tkinter.Button,
                    'wcfg':{'text':'ApplyToSelection','command': self.applyShader},
                    'gridcfg':{'column':1,
                               'row':4,'sticky':'w'}})

        idf.append({'name':'edit',
                    'widgetType':Tkinter.Button,
                    'defaultValue':0,
                    'wcfg':{'text':'Edit','command': self.editShader},
                    'gridcfg':{'column':2, 'row':4,'sticky':'w'}})

        idf.append({'widgetType':Pmw.EntryField,
                    'name':'finish',
                    'wcfg':{'labelpos':'w',
                            'label_text':'Finish      ',
                            'validate':None,
                            'entry_width':40},
                    'gridcfg':{'columnspan':2, 'column':0,
                               'row':5, 'sticky':'w'}})

        idf.append({'name':'scaleLight',
                    'widgetType':Pmw.EntryField,
                    'type':float,
                    'wcfg':{'labelpos':'w',
                            'label_text':'Light scale factor',
                            'validate':'real',
                            'value':2.0,
                            'entry_width':5},
                    'gridcfg':{'column':3, 'row':4, 'sticky':'e'}})

        idf.append({'name':'scaleImage',
                    'widgetType':Pmw.EntryField,
                    'type':float,
                    'wcfg':{'labelpos':'w',
                            'label_text':'scale Image', 
                            'entry_width':5,
                            'validate':'real',
                            'value':1.0},
                    'gridcfg':{'column':3, 'row':5, 'sticky':'e'}})

        idf.append({'name':'bondRadius',
                    'widgetType':Pmw.EntryField,
                    'type':float,
                    'wcfg':{'labelpos':'w',
                            'label_text':'bond Radius', 
                            'entry_width':5,
                            'validate':'real',
                            'value': 0.15},
                    'gridcfg':{'column':3, 'row':6, 'sticky':'e'}})

        idf.append({'name':'fileName',
                    'widgetType':Pmw.EntryField,
                    'wcfg':{'labelpos':'w',
                            'label_text':'File Name',
                            'entry_width':40,
                            'value':'test.pyg',},
                    'gridcfg':{'columnspan':2,'column':0,'row':6,'sticky':'w'}})

        idf.append({'name':'gelatoBin',
                    'widgetType':Pmw.EntryField,
                    'wcfg':{'labelpos':'w',
                            'label_text':'Gelato binary',
                            'value':'gelato',
                            'entry_width':40},
                    'gridcfg':{'columnspan':2,'column':0,
                               'row':7,'sticky':'w'}})

        idf.append({'name':'wbg',
                    'widgetType':Tkinter.Checkbutton,
                    'defaultValue':1,
                    'wcfg':{'text':'White Background',
                            'variable': Tkinter.IntVar()},
                    'gridcfg':{'column':3, 'row':7,'sticky':'e'}})

        idf.append({'name':'inter',
                    'widgetType':Tkinter.Checkbutton,
                    'defaultValue':0,
                    'wcfg':{'text':'catmull-clark',
                            'variable': Tkinter.IntVar()},
                    'gridcfg':{'column':3, 'row':8,'sticky':'e'}})


        idf.append({'name':'gelatoArgs',
                    'widgetType':Pmw.EntryField,
                    'wcfg':{'labelpos':'w',
                            'label_text':'cmdline arguments',
                            'value':'-iv',# +P +X -V +FN +QR',
                            'entry_width':40},
                    'gridcfg':{'columnspan':2,'column':0,
                               'row':8,'sticky':'w'}})

        idf.append({'name':'imageFile',
                    'widgetType':Pmw.EntryField,
                    'wcfg':{'labelpos':'w',
                            'label_text':'image file',
                            'entry_width':40},
                    'gridcfg':{'columnspan':2,'column':0,
                               'row':9,'sticky':'w'}})

        idf.append({'name':'WriteFile',
                    'widgetType':Tkinter.Button,
                    'wcfg':{'text':'WriteFile','command': self.writeFile},
                    'gridcfg':{'column':0,
                               'row':10,'sticky':'ew'}})

        idf.append({'name':'Render',
                    'widgetType':Tkinter.Button,
                    'wcfg':{'text':'Render',
                            'command': CallBackFunction( self.runGelato,
                                                         (idf))},
                    'gridcfg':{'column':1,
                               'row':10,'sticky':'ew'}})
	idf.append({'name':'help',
                    'widgetType':Tkinter.Button,
                    'defaultValue':0,
                    'wcfg':{'text':'Help','command': self.helpGelato},
                    'gridcfg':{'column':2, 'row':10,'sticky':'ew'}})

        idf.append({'name':'Dismiss',
                    'widgetType':Tkinter.Button,
                    'wcfg':{'text':'Dismiss',
                            'command':self.dismissCB},
                    'gridcfg':{'column':3, 'row':10,'sticky':'ew'}})

        self.form = self.vf.getUserInput(idf, modal = 0, blocking = 0)
        lb = idf.entryByName['selectedGeometries']['widget'].lb
        lb.bind("<ButtonRelease-1>", self.updateProps, '+')

        e1 = idf.entryByName['pigment']['widget']
        e1.bind("<Return>", self.bindPigment)
        
        e2 = idf.entryByName['finish']['widget']
        e2.bind("<Return>", self.bindFinish)
示例#22
0
    def buildForm(self):
        if self.node is None:
            return

        row = 0
        column = 0
        l1 = Tkinter.Label(  #group.interior(),
            self.gridFrame, text='Label Conf')
        l2 = Tkinter.Label(  #group.interior(),
            self.gridFrame, text='Widget Conf')
        l1.grid(row=0, column=0)
        l2.grid(row=0, column=1)

        row = row + 1
        for i in range(len(self.node().inputPorts)):
            port = self.node().inputPorts[i]
            if port.widget is None:
                continue
            widgetDescr = port.widget.getDescr()
            name = port.name

            group = Pmw.Group(
                self.gridFrame, tag_text='Widget '+\
                #widgetDescr['class']+\
                ' '+name)
            group.grid(row=row,
                       column=column,
                       columnspan=2,
                       padx=6,
                       pady=6,
                       sticky='wens')
            f1 = Tkinter.Frame(group.interior())
            f2 = Tkinter.Frame(group.interior())
            cb = CallBackFunction(self.ApplyToOneGrid, self.gridCounter)
            g1 = OneGrid(f1, port=port, label=True, callback=cb)
            g2 = OneGrid(f2, port=port, label=False, callback=cb)
            self.gridCounter += 1

            # append to self.grids
            self.grids.append((g1, g2))

            # get current grid_info and set gui accordingly
            # we do not use widgetDescr, because this might not be up do date!
            g1.set(port.widget.tklabel.grid_info())
            g1.set({
                'labelName': widgetDescr['labelCfg']['text'],
                'labelSide': widgetDescr['widgetGridCfg']['labelSide']
            })
            g2.set(port.widget.widgetFrame.grid_info())

            #l1.grid(row=0, column=0)
            f1.grid(row=2, column=0, padx=6, pady=6)

            #l2.grid(row=0, column=1)
            f2.grid(row=2, column=1, padx=6, pady=6)
            row = row + 1

        # add buttons
        ok = Tkinter.Button(self.buttonFrame, text='Ok', command=self.OK_cb)
        ok.pack(side='left', expand=1, fill='x')
        apply = Tkinter.Button(self.buttonFrame,
                               text='Apply',
                               command=self.Apply_cb)
        apply.pack(side='left', expand=1, fill='x')
        cancel = Tkinter.Button(self.buttonFrame,
                                text='Cancel',
                                command=self.Cancel_cb)
        cancel.pack(side='left', expand=1, fill='x')
示例#23
0
    def __init__(self, master=None, viewerGui=None):

        if master is None:
            self.master = Tkinter.Toplevel()
            self.master.withdraw()
            self.master.title('Selection Settings')
            self.master.protocol('WM_DELETE_WINDOW', self.master.withdraw)
        else:
            self.master = master

        self.mainFrame = Tkinter.Frame(self.master,
                                       relief='ridge',
                                       borderwidth=3)

        # CONTOUR WIDTH
        if DejaVu.enableSelectionContour is True:
            lLabel = Tkinter.Label(self.mainFrame, text='Contour width:')
            lLabel.grid(row=0, column=0, sticky='w')
            self.contourSizeSlider = Slider.Slider(self.mainFrame,
                                                   minval=0,
                                                   maxval=10,
                                                   immediate=1,
                                                   incr=1,
                                                   labelformat='%d',
                                                   cursortype='int')
            self.contourSizeSlider.frame.grid(row=0, column=1, columnspan=3)

            def setContourWidthSliderValue_cb(val):
                DejaVu.selectionContourSize = val
                viewerGui.viewer.Redraw()

            self.contourSizeSlider.AddCallback(setContourWidthSliderValue_cb)
        else:
            lLabel = Tkinter.Label(self.mainFrame,
                                   text='Contour selection is disabled')
            lLabel.grid(row=0, column=0, columnspan=3, sticky='w')

        # BACKGROUND COLOR
        lLabel = Tkinter.Label(self.mainFrame, text='Contour color:')
        lLabel.grid(row=1, column=0, sticky='w')
        lFunc = CallBackFunction(viewerGui.colorChooser.showColorChooser,
                                 'selection contour')
        self.contourColorButton = Tkinter.Button(
            self.mainFrame,
            #text='Contour color',
            width=7,
            background=TkColor(DejaVu.selectionContourColor),
            command=lFunc)
        self.contourColorButton.grid(row=1, column=1, columnspan=3)

        # PATTERN SIZE
        lLabel = Tkinter.Label(self.mainFrame, text='Pattern size:')
        lLabel.grid(row=2, column=0, sticky='w')

        def setPatternSizeSliderValue_cb(val):
            DejaVu.selectionPatternSize = val
            viewerGui.viewer.Redraw()

        self.patternSizeThumbwheel = ThumbWheel(
            self.mainFrame,
            width=70,
            height=16,
            type=int,
            value=DejaVu.selectionPatternSize,
            callback=setPatternSizeSliderValue_cb,
            continuous=True,
            oneTurn=10,
            wheelPad=2,
            min=0,
            max=50)
        self.patternSizeThumbwheel.grid(row=2, column=1, columnspan=3)

        self.mainFrame.pack(side='top')

        self.updateWidgets()
示例#24
0
文件: Forms.py 项目: lisarosalina/App
    def buildPanel(self):
        # prevent re-creation
        if self.panel is not None:
            self.panel.show()
            return
        
        root = self.panel = Tkinter.Toplevel()

        # add menu bar
        self.menuBar = Tkinter.Menu(root)
        self.optionsMenu = Tkinter.Menu(self.menuBar, tearoff=0)
        self.optionsMenu.add_command(label="Hide Search Options",
                                     command=self.showHideOptions_cb)

        self.menuBar.add_cascade(label="Options", menu=self.optionsMenu)
        root.config(menu=self.menuBar)
                
        frame = Tkinter.Frame(root, borderwidth=2, relief='sunken')
        frame.pack(side='top', expand=1, fill='both')

        # build infrastructure for search panes with scrolled canvas
        sFrame = Tkinter.Frame(frame)
        sFrame.pack(expand=1, fill='both')
        # add panes
        self.searchPane = Pmw.PanedWidget(sFrame, orient='horizontal',
                                   hull_relief='sunken',
                                   hull_width=120, hull_height=120,
                                   )
        self.searchPane.pack(expand=1, fill="both")

        searchPane = self.searchPane.add("SearchNodes", min=60)
        self.searchPane.configurepane("SearchNodes", min=10)
        usedPane = self.searchPane.add("UsedNodes", min=10)
        # this is the canvas we use to display found nodes
        self.searchCanvas = kbScrolledCanvas(
            searchPane,
            borderframe=1,
            #usehullsize=1, hull_width=60, hull_height=80,
            #vscrollmode='static',#hscrollmode='static',
            vertscrollbar_width=8,
            horizscrollbar_width=8,
            labelpos='n', label_text="Found Nodes",
            )
        self.searchCanvas.pack(side='left', expand=1, fill='both')

        self.editor.idToNodes[self.searchCanvas] = {}

        # this is the canvas we use to display nodes we have drag-and-dropped
        # to the network
        self.libCanvas = kbScrolledCanvas(
            usedPane,
            borderframe=1,
            #usehullsize=1, hull_width=60, hull_height=80,
            #vscrollmode='static',#hscrollmode='static',
            vertscrollbar_width=8,
            horizscrollbar_width=8,
            labelpos='n', label_text="Used Nodes",
            )
        self.libCanvas.pack(side='right', expand=1, fill='both')

        self.editor.idToNodes[self.libCanvas] = {}

        
        lowerFrame = Tkinter.Frame(frame)
        lowerFrame.pack() # no expand
        
        # add options buttons
        self.optionsGroup = Pmw.Group(lowerFrame, tag_text="Search Options")
        self.optionsGroup.grid(row=0,column=0, sticky='we',padx=6, pady=6)

        cb = Tkinter.Checkbutton(self.optionsGroup.interior(),
                                 text="Case sensitive", variable=self.cbVarTk)
        cb.grid(row=0, column=0, columnspan=2, sticky='we')

        for i in range(len(self.choices)):
            b = Tkinter.Radiobutton(
                self.optionsGroup.interior(),
                variable = self.choicesVarTk, value=self.choices[i])
            l = Tkinter.Label(self.optionsGroup.interior(),
                              text=self.choices[i])
            b.grid(row=i+1, column=0, sticky='we')
            l.grid(row=i+1, column=1, sticky='w')

        self.choicesVarTk.set(self.choices[1])

        # add Entry
        eFrame = Tkinter.Frame(lowerFrame)
        eFrame.grid(row=1, column=0, sticky='we')
        eLabel = Tkinter.Label(eFrame, text='Search string:')
        eLabel.pack(side='left', expand=1, fill='x')
        entry = Tkinter.Entry(eFrame, textvariable=self.entryVarTk)
        entry.bind('<Return>', self.search)
        entry.pack(side='right', expand=1, fill='x')
        
        # add buttons
        bFrame = Tkinter.Frame(lowerFrame)
        bFrame.grid(row=2, column=0, sticky='we')
        button1 = Tkinter.Button(bFrame, text="Search", relief="raised",
                                 command=self.Apply_cb)
        button2 = Tkinter.Button(bFrame, text="Dismiss", relief="raised",
                                 command=self.Cancel_cb)
        button1.pack(side='left', expand=1, fill='x')
        button2.pack(side='right', expand=1, fill='x')

        # Pmw Balloon
        self.balloons = Pmw.Balloon(master=None, yoffset=10)
        
        # Drag-and-Drop callback for searchCanvas
        cb = CallBackFunction(self.editor.startDNDnode, self.searchCanvas)
        self.searchCanvas.component('canvas').bind('<Button-1>', cb )
        # Drag-and-Drop callback for libCanvas
        cb = CallBackFunction(self.editor.startDNDnode, self.libCanvas)
        self.libCanvas.component('canvas').bind('<Button-1>', cb )
示例#25
0
 def buildMenu(self):
     self.menu = T.Menu(self.widget.master)
     for k in self.widget.keys():
         if k in self.optionWidgets.keys():
             cb = CallBackFunction(self.setOption_cb, k)
             self.menu.add_command(label=k, command=cb)
示例#26
0
def addTargetsToMenu(menu, maa):
    for name in _MAATargets.targetNames:
        cb = CallBackFunction(_MAATargets.addToTarget, name, maa)
        menu.add_command(label='Add to ' + name, command=cb)
示例#27
0
    def guiCallback(self):
        """called each time the 'Delete Selected Atoms' button is pressed"""
        z = self.vf.getSelection()
        hats = None
        if z:
            ats = z.findType(Atom)
            if ats:
                hats = ats.get(lambda x: x.element == 'H')
        else:
            self.vf.warningMsg('no atoms selected')
            return 'ERROR'
        if hats is None:
            self.vf.warningMsg('no hydrogens selected')
            return 'ERROR'

        #only get to this point if hats
        if self.vf.undoCmdStack == []:
            self.doitWrapper(hats, redraw=0)
        else:
            text = """WARNING: This command cannot be undone.
            if you choose to continue the undo list will be reset.
            Do you want to continue?"""

            idf = self.idf = InputFormDescr(title="WARNING")
            idf.append({
                'widgetType': Tkinter.Label,
                'wcfg': {
                    'text': text
                },
                'gridcfg': {
                    'columnspan': 2,
                    'sticky': 'w'
                }
            })

            idf.append({
                'name': 'continueBut',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'CONTINUE',
                    'command': CallBackFunction(self.continue_cb, hats)
                },
                'gridcfg': {
                    'sticky': 'we'
                }
            })

            idf.append({
                'name': 'cancelBut',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'CANCEL',
                    'command': self.cancel_cb
                },
                'gridcfg': {
                    'row': -1,
                    'sticky': 'we'
                }
            })

            self.form = self.vf.getUserInput(idf, modal=0, blocking=0)
            self.form.root.protocol('WM_DELETE_WINDOW', self.cancel_cb)