def guiCallback(self):
     """called each time the 'read ->AutoGrid' sequence is pressed"""
     objList = []
     if len(self.vf.grids.keys()) == 0:
         t = "no grids currently in viewer"
         self.warningMsg(t)
         return
     for item in self.vf.grids.keys():
         if item not in objList:
             objList.append(item)
     if len(objList) == 0:
         gridName = objList[0]
     else:
         # NEED TO PICK THE GRID....
         ifd2 = InputFormDescr(title="Choose Grid")
         ifd2.append(
             {
                 "widgetType": "ListChooser",
                 "name": "gridObjs",
                 "entries": objList,
                 "wcfg": {"title": "Pick grid", "mode": "single"},
                 "lbwcfg": {"height": 4},
                 "gridcfg": {"sticky": "wens", "column": 100, "rowspan": 10},
             }
         )
         val = self.vf.getUserInput(ifd2)
         if val is not None and len(val) > 0 and len(val["gridObjs"]) > 0:
             gridName = val["gridObjs"][0]
         else:
             return
     return self.doitWrapper(gridName, redraw=0)
 def guiCallback(self):
     """called each time the 'read ->AutoGrid' sequence is pressed"""
     objList=[]
     if len(self.vf.grids.keys())==0:
         t='no grids currently in viewer'
         self.warningMsg(t)
         return
     for item in self.vf.grids.keys():
         if item not in objList:
             objList.append(item)
     if len(objList)==0:
         gridName = objList[0]
     else:
         #NEED TO PICK THE GRID....
         ifd2 = InputFormDescr(title='Choose Grid')
         ifd2.append({'widgetType':'ListChooser',
             'name':'gridObjs',
             'entries':objList,
             'wcfg':{'title':'Pick grid',
                     'mode':'single'},
             'lbwcfg':{'height':4},
             'gridcfg':{'sticky':'wens', 'column':100,
                      'rowspan':10}})
         val = self.vf.getUserInput(ifd2)
         if val is not None and len(val)>0 and len(val['gridObjs'])>0:
             gridName = val['gridObjs'][0]
         else:
             return
     return self.doitWrapper(gridName, redraw=0)
 def guiCallback(self):
     objList = []
     if len(self.vf.grids.keys()) == 0:
         t = "no grids currently in viewer"
         self.warningMsg(t)
         return
     for item in self.vf.grids.keys():
         if item not in objList and not self.vf.grids[item].srf:
             objList.append(item)
     if not hasattr(self, "ifd"):
         self.buildForm()
     else:
         self.form.deiconify()
     if len(objList) > 0:
         # NEED TO PICK THE GRID....
         ifd2 = InputFormDescr(title="Choose Grid")
         ifd2.append(
             {
                 "widgetType": "ListChooser",
                 "name": "gridObjs",
                 "entries": objList,
                 "wcfg": {"title": "Pick grid", "mode": "single"},
                 "lbwcfg": {"height": 4},
                 "gridcfg": {"sticky": "wens", "column": 100, "rowspan": 10},
             }
         )
         val = self.vf.getUserInput(ifd2)
         if val is not None and len(val) > 0 and len(val["gridObjs"]) > 0:
             filename = val["gridObjs"][0]
             grid = self.vf.grids[filename]
             return self.doitWrapper(filename, redraw=1)
    def buildInputFormDescr(self):
        """to be implemented by sub-class"""

	ifd=InputFormDescr()
        ifd.title = "bond picker"
        ifd.append({'widgetType':Tkinter.Label,
                    'name':'event',
                    'wcfg':{'text':'event: '+self.event},
                    'gridcfg':{'sticky':Tkinter.W} })
        
        ifd.append({'widgetType':Pmw.EntryField,
                    'name':'Atom1',
                    'wcfg':{'labelpos':'w',
                            'label_text':'Atom 1: ',
                            'validate':None},
                    'gridcfg':{'sticky':'we'}})
        ifd.append({'widgetType':Pmw.EntryField,
                    'name':'Atom2',
                    'wcfg':{'labelpos':'w',
                            'label_text':'Atom 2: ',
                            'validate':None},
                    'gridcfg':{'sticky':'we'}})
        ifd.append({'widgetType':Pmw.EntryField,
                    'name':'BondOrder',
                    'wcfg':{'labelpos':'w',
                            'label_text':'BondOrder: ',
                            'validate':None},
                    'gridcfg':{'sticky':'we'}})

        if self.numberOfObjects==None:
            ifd.append({'widgetType':Tkinter.Button,
                             'wcfg':{'text':'Done'},
                             'command': self.stop})

        return ifd
 def guiCallback(self):
     objList=[]
     if len(self.vf.grids.keys())==0:
         t='no grids currently in viewer'
         self.warningMsg(t)
         return
     for item in self.vf.grids.keys():
         if item not in objList and not self.vf.grids[item].srf:
             objList.append(item)
     if not hasattr(self, 'ifd'):
         self.buildForm()
     else:
         self.form.deiconify()
     if len(objList)>0:
         #NEED TO PICK THE GRID....
         ifd2 = InputFormDescr(title='Choose Grid')
         ifd2.append({'widgetType':'ListChooser',
             'name':'gridObjs',
             'entries':objList,
             'wcfg':{'title':'Pick grid',
                     'mode':'single'},
             'lbwcfg':{'height':4},
             'gridcfg':{'sticky':'wens', 'column':100,
                      'rowspan':10}})
         val = self.vf.getUserInput(ifd2)
         if val is not None and len(val)>0 and len(val['gridObjs'])>0:
             filename = val['gridObjs'][0]
             grid = self.vf.grids[filename]
             return self.doitWrapper(filename, redraw=1)
Beispiel #6
0
def test_scrolledText():
    descr = InputFormDescr(title="Testing ScrolledText")
    descr.append({
        'widgetType': Pmw.ScrolledText,
        'name': 'sText',
        'defaultValue': """DEFAULT TEXT""",
        'wcfg': {
            'labelpos': 'n',
            'label_text': 'ScrolledText with headers',
            'usehullsize': 1,
            'hull_width': 400,
            'hull_height': 300,
            'text_wrap': 'none',
            'text_padx': 4,
            'text_pady': 4,
        },
        'gridcfg': {
            'sticky': 'wens'
        }
    })

    form = InputForm(master, root, descr, modal=0, blocking=0)
    values = form.testForm()
    if not values['sText'] == 'DEFAULT TEXT\n':
        raise RuntimeError
    form.destroy()
def test_thumbwheel():
    def tw_cb(event=None):
        pass
    from mglutil.gui.BasicWidgets.Tk.thumbwheel import ThumbWheel
    descr = InputFormDescr(title = 'Testing InputForm')
    descr.append({'name':'thumbwheel',
                  'widgetType':ThumbWheel,
                  'tooltip':"""Right click on the widget will display the control
                  panel and you can type a value manually""",
                  'defaultValue':100,
                  'wcfg':{'text':None,
                          'showLabel':1, 'width':100,
                          'min':0,
                          'lockBMin':1,
                          'lockBMax':1,
                          'lockBIncrement':1,
                          'value':40,
                          'oneTurn':1000,
                          'type':'int',
                          'increment':2,
                          'canvascfg':{'bg':'red'},
                          'wheelLabcfg1':{'font':(ensureFontCase('times'),14,'bold')},
                          'wheelLabcfg2':{'font':(ensureFontCase('times'),14,'bold')},
                          'callback':tw_cb,
                          'continuous':1, 'wheelPad':1, 'height':20},
                  'gridcfg':{'sticky':'e','row':-1}})
    
    form = InputForm(master, root, descr)
    value = form.testForm()
    assert value['thumbwheel']==100
    form.destroy() 
Beispiel #8
0
    def buildFormDescr(self, formName):
        if formName == "Vectfield":
            ifd = InputFormDescr(title="Choose Vect Field")
            vectList = []
            for key in self.vf.vectfield.keys():
                vectList.append((key, None))
            ifd.append({
                'widgetType': ListChooser,
                'name': 'vectObj',
                'wcfg': {
                    'title': 'Pick grid',
                    'entries': vectList,
                    'mode': 'single',
                    'lbwcfg': {
                        'height': 4
                    },
                },
                'gridcfg': {
                    'sticky': 'wens',
                    'column': 100,
                    'rowspan': 10
                }
            })

            return ifd
    def buildFormDescr(self, formName):
        if formName=='saveViewsToFile':
            if self.vf.commands.has_key("viewsPanel"):
                if len(self.vf.viewsPanel.views) == 0:
                    return
            else:
                return
            idf = InputFormDescr(title="Save Views to file")
            idf.append({'name':'filename',
                        'widgetType':Pmw.EntryField,
                   'tooltip':"Enter the filename, a 'filename_oprient.py' (saves orientation)\nand 'filename_repr.db'(saves representation) will be created.",
                        'wcfg':{'label_text':'Filename:',
                                'labelpos':'w'},
                        'gridcfg':{'sticky':'we'},
                        })

            idf.append({'widgetType':SaveButton,
                        'name':'filebrowse',
                        'wcfg':{'buttonType':Tkinter.Button,
                                'title':'Save In File ...',
                                'types':[('Views orientation','*_orient.py'),
                                         ('Views representation', '*_repr.db'),
                                         ("", '*')],
                                'callback':self.setEntry_cb,
                                'widgetwcfg':{'text':'BROWSE'}},
                        'gridcfg':{'row':-1, 'sticky':'we'}})

            return idf
Beispiel #10
0
 def getInt(self):
     idf = InputFormDescr(title='Choose a value')
     idf.append({'widgetType':IntThumbWheel,
                 'name':'tw',
                 'wcfg':{'width':125, 'height':30, 'nblines':30}})
     form  = InputForm(master=self.widget.master, root = None, descr=idf)
     values = form.go()
     return values['tw']
 def buildFormDescr(self, formName):
     if formName == 'display':
         idf =  InputFormDescr(title = self.name)
         idf.append({'name':'display',
                     'widgetType':Pmw.RadioSelect,
                     'listtext':['display','display only', 'undisplay'],
                     'defaultValue':'display',
                     'wcfg':{'orient':'horizontal',
                             'buttontype':'radiobutton'},
                     'gridcfg':{'sticky': 'we'}})
         return idf
def test_inputform_groupwidgetsdefault():
    descr = InputFormDescr(title = 'Testing InputForm')
    descr.append({'name':'group',
                  'widgetType':Tkinter.Radiobutton,
                  'listtext':['rb1', 'rb2', 'rb3'],
                  'defaultValue':'rb3',
                  'gridcfg':{'sticky':'w'}})
    
    form = InputForm(master, root, descr)
    value = form.testForm()
    assert value['group']=='rb3'
    form.destroy() 
Beispiel #13
0
 def getInt(self):
     idf = InputFormDescr(title='Choose a value')
     idf.append({
         'widgetType': IntThumbWheel,
         'name': 'tw',
         'wcfg': {
             'width': 125,
             'height': 30,
             'nblines': 30
         }
     })
     form = InputForm(master=self.widget.master, root=None, descr=idf)
     values = form.go()
     return values['tw']
Beispiel #14
0
 def buildInputFormDescr(self):
     ifd = InputFormDescr()
     all = self.allChoices()
     if len(all)>0:
         ifd.append({'widgetType':'ListChooser',
                          'name':'AllObjects',
                          'entries':all,
                          'title':'All objects',
                          'wcfg':{'mode':'multiple'},
                          })
     if self.numberOfObjects==None:
         ifd.append({'widgetType':Tkinter.Button,
                          'wcfg':{'text':'Done'},
                          'command': self.stop})
     return ifd
 def buildFormDescr(self,formName):
     if formName == "enterName":
         ifd  =InputFormDescr(title = "Pick Vect Name")
         vectNames = self.vf.vectfield.keys()
         ifd.append({'widgetType':Pmw.ComboBox,
                     'name':'vectName',
                     'required':1,
                     'tooltip': "Please type-in a new name or chose one from the list below\n '_' are not accepted",
                     'wcfg':{'labelpos':'nw',
                             'label_text':'VectField Name: ',
                             'entryfield_validate':self.entryValidate,
                             'scrolledlist_items':vectNames,
                             },
                     'gridcfg':{'sticky':'we'}})
         return ifd
    def buildFormDescr(self,formName):
        if formName == "Vectfield":
           ifd  =InputFormDescr(title = "Choose Vect Field")
           vectList = []
           for key in self.vf.vectfield.keys():
               vectList.append((key,None))
           ifd.append({'widgetType':ListChooser,
                       'name':'vectObj',
                       'wcfg':{'title':'Pick grid',
                               'entries':vectList,
                               'mode':'single',
                               'lbwcfg':{'height':4},},
                       'gridcfg':{'sticky':'wens', 'column':100,
                                  'rowspan':10}})   
 
           return ifd
Beispiel #17
0
 def buildFormDescr(self, formName):
     if formName == 'display':
         idf = InputFormDescr(title=self.name)
         idf.append({
             'name': 'display',
             'widgetType': Pmw.RadioSelect,
             'listtext': ['display', 'display only', 'undisplay'],
             'defaultValue': 'display',
             'wcfg': {
                 'orient': 'horizontal',
                 'buttontype': 'radiobutton'
             },
             'gridcfg': {
                 'sticky': 'we'
             }
         })
         return idf
Beispiel #18
0
    def buildFormDescr(self, formName):
        if formName == 'saveViewsToFile':
            if self.vf.commands.has_key("viewsPanel"):
                if len(self.vf.viewsPanel.views) == 0:
                    return
            else:
                return
            idf = InputFormDescr(title="Save Views to file")
            idf.append({
                'name': 'filename',
                'widgetType': Pmw.EntryField,
                'tooltip':
                "Enter the filename, a 'filename_oprient.py' (saves orientation)\nand 'filename_repr.db'(saves representation) will be created.",
                'wcfg': {
                    'label_text': 'Filename:',
                    'labelpos': 'w'
                },
                'gridcfg': {
                    'sticky': 'we'
                },
            })

            idf.append({
                'widgetType': SaveButton,
                'name': 'filebrowse',
                'wcfg': {
                    'buttonType':
                    Tkinter.Button,
                    'title':
                    'Save In File ...',
                    'types': [('Views orientation', '*_orient.py'),
                              ('Views representation', '*_repr.db'),
                              ("", '*')],
                    'callback':
                    self.setEntry_cb,
                    'widgetwcfg': {
                        'text': 'BROWSE'
                    }
                },
                'gridcfg': {
                    'row': -1,
                    'sticky': 'we'
                }
            })

            return idf
def test_inputForm_notebook():
    descr = InputFormDescr(title = 'Testing InputForm')
    descr.append({'widgetType':Pmw.NoteBook,
                  'name':'notebook',
                  'container':{'Page1':"w.page('Page1')",
                               'Page2':"w.page('Page2')",
                               'Page3':"w.page('Page3')"},
                  'wcfg':{'borderwidth':3},
                  'componentcfg':[{'name':'Page1', 'cfg':{}},
                                  {'name':'Page2', 'cfg':{}},
                                  {'name':'Page3', 'cfg':{}}],
                  'gridcfg':{'sticky':'wnse'}
                  })

    entries = [('Chocolate',None), ('Vanilla', None), ('Strawberry', None),
               ('Coffee',None), ('Pistachio', None), ('Rasberry',None),
               ]

    descr.append({'name':'listchooser',
                  'parent':'Page1',
                  'widgetType':ListChooser,
                  'defaultValue':'Chocolate',
                  'wcfg':{'entries':entries},
                  'gridcfg':{'sticky':'w'}
                  })
    
    descr.append({'name':'radioselect2',
                  'widgetType':Pmw.RadioSelect,
                  'parent':'Page2',
                  'listtext':['rb1', 'rb2', 'rb3','rb4', 'rb5', 'rb6',
                              'rb7', 'rb8', 'rb9','rb10', 'rb11', 'rb12'],
                  'wcfg':{'labelpos':'n',
                          'label_text':'Radiobuttons: ',
                          'orient':'horizontal',
                          'buttontype':'radiobutton'},
                  'gridcfg':{'sticky':'w'} })

    descr.append({'name':'radioselect',
                  'widgetType':Pmw.RadioSelect,
                  'parent':'Page3',
                  'defaultValue':'rb5',
                  'listtext':['rb1', 'rb2', 'rb3','rb4', 'rb5', 'rb6',
                              'rb7', 'rb8', 'rb9','rb10', 'rb11', 'rb12'],
                  'wcfg':{'labelpos':'n',
                          'label_text':'Radiobuttons: ',
                          'orient':'vertical',
                          'buttontype':'radiobutton'},
                  'gridcfg':{'sticky':'w'} })
    form = InputForm(master, root, descr, modal=0, blocking=0)
    values = form.testForm(container='Page3')
    assert values['radioselect']=='rb5'
    form.destroy() 
    def doit(self, trajFile, ask=True):
        """creates a Trajectory object, uses its parser to read the trajectory file,
        adds created Trajectory object to self.vf.Trajectories dictionary"""
        
        name = os.path.split(trajFile)[1]
        trajnames = self.vf.Trajectories.keys()
        if name in trajnames:
            if ask:
                from mglutil.gui.InputForm.Tk.gui import InputFormDescr
                ifd = InputFormDescr(title = '')
                ifd.append({'widgetType':Pmw.EntryField,
                            'name':'newtraj',
                            'required':1,
                            'wcfg':{'labelpos':'w',
                                    'label_text': "Trajectory %s exists.\nEnter new name:"%(name,),
                                    'validate':None},
                            'gridcfg':{'sticky':'we'}
                            })

                vals = self.vf.getUserInput(ifd)
                if len(vals)>0:
                    assert not vals['newtraj'] in trajnames
                    name = vals['newtraj']
                else:
                    return None
            else:
                name = name+str(len(trajnames))
        trj = Trajectory(trajFile)
        if trj.parser:
            trj.readTrajectory()

            self.vf.Trajectories[name] = trj
            if self.vf.commands.has_key("playTrajectory"):
                if self.vf.playTrajectory.ifd:
                    cb = self.vf.playTrajectory.ifd.entryByName['trs']['widget']
                    sl = cb.component('scrolledlist')
                    trajnames = self.vf.Trajectories.keys()
                    sl.setlist(trajnames)
                    cb.selectitem(name)
            return name
        else: return None
Beispiel #21
0
    def doit(self, trajFile, ask=True):
        """creates a Trajectory object, uses its parser to read the trajectory file,
        adds created Trajectory object to self.vf.Trajectories dictionary"""
        
        name = os.path.split(trajFile)[1]
        trajnames = self.vf.Trajectories.keys()
        if name in trajnames:
            if ask:
                from mglutil.gui.InputForm.Tk.gui import InputFormDescr
                ifd = InputFormDescr(title = '')
                ifd.append({'widgetType':Pmw.EntryField,
                            'name':'newtraj',
                            'required':1,
                            'wcfg':{'labelpos':'w',
                                    'label_text': "Trajectory %s exists.\nEnter new name:"%(name,),
                                    'validate':None},
                            'gridcfg':{'sticky':'we'}
                            })

                vals = self.vf.getUserInput(ifd)
                if len(vals)>0:
                    assert not vals['newtraj'] in trajnames
                    name = vals['newtraj']
                else:
                    return None
            else:
                name = name+str(len(trajnames))
        trj = Trajectory(trajFile)
        if trj.parser:
            trj.readTrajectory()

            self.vf.Trajectories[name] = trj
            if self.vf.commands.has_key("playTrajectory"):
                if self.vf.playTrajectory.ifd:
                    cb = self.vf.playTrajectory.ifd.entryByName['trs']['widget']
                    sl = cb.component('scrolledlist')
                    trajnames = self.vf.Trajectories.keys()
                    sl.setlist(trajnames)
                    cb.selectitem(name)
            return name
        else: return None
def test_scrolledText():
    descr = InputFormDescr(title = "Testing ScrolledText")
    descr.append({'widgetType':Pmw.ScrolledText,
                  'name':'sText',
                  'defaultValue':"""DEFAULT TEXT""",
                  'wcfg':{'labelpos':'n',
                          'label_text':'ScrolledText with headers',
                          'usehullsize': 1,
                          'hull_width': 400,
                          'hull_height': 300,
                          'text_wrap':'none',
                          'text_padx': 4,
                          'text_pady': 4,
                          },
                  'gridcfg':{'sticky':'wens'}})
    
    form = InputForm(master, root, descr, modal=0, blocking=0)
    values = form.testForm()
    if not values['sText'] == 'DEFAULT TEXT\n':
        raise RuntimeError
    form.destroy() 
Beispiel #23
0
 def buildFormDescr(self, formName):
     if formName == "enterName":
         ifd = InputFormDescr(title="Pick Vect Name")
         vectNames = self.vf.vectfield.keys()
         ifd.append({
             'widgetType': Pmw.ComboBox,
             'name': 'vectName',
             'required': 1,
             'tooltip':
             "Please type-in a new name or chose one from the list below\n '_' are not accepted",
             'wcfg': {
                 'labelpos': 'nw',
                 'label_text': 'VectField Name: ',
                 'entryfield_validate': self.entryValidate,
                 'scrolledlist_items': vectNames,
             },
             'gridcfg': {
                 'sticky': 'we'
             }
         })
         return ifd
 def buildFormDescr(self, formName):
     
     if formName=='chooseCitation':
         idf = InputFormDescr(title="Choose Package")
         pname = self.citations.keys()
         #pname.sort()
         idf.append({'name':'packList',
                     'widgetType':Pmw.ScrolledListBox,
                     'wcfg':{'items':pname,
                             'listbox_exportselection':0,
                             'labelpos':'nw','usehullsize': 1,
                             'hull_width':100,'hull_height':150,
                             'listbox_height':5,
                              'listbox_width':150,
                             'label_text':'Select a package:',
                             'selectioncommand':self.displayCitation_cb,
                             },
                     'gridcfg':{'sticky':'wesn'}})
         
         idf.append({'name':'citation',
                     'widgetType':Pmw.ScrolledText,
                     'wcfg':{'labelpos':'nw',
                             'text_width':60,
                             'text_height':10},
                     'gridcfg':{'sticky':'wens'}
                     })
         idf.append({'name':'dismiss',
                     'widgetType':Tkinter.Button,
                     'wcfg':{'text':'DISMISS','command':self.dismiss_cb,
                             },
                     'gridcfg':{'sticky':'wens'}})
         return idf
    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)
Beispiel #26
0
 def buildInputFormDescr(self):
     ifd = InputFormDescr()
     all = self.allChoices()
     if len(all) > 0:
         ifd.append({
             'widgetType': 'ListChooser',
             'name': 'AllObjects',
             'entries': all,
             'title': 'All objects',
             'wcfg': {
                 'mode': 'multiple'
             },
         })
     if self.numberOfObjects == None:
         ifd.append({
             'widgetType': Tkinter.Button,
             'wcfg': {
                 'text': 'Done'
             },
             'command': self.stop
         })
     return ifd
Beispiel #27
0
    def buildFormDescr(self, formName):

        if not formName == 'showCmds': return
        idf = InputFormDescr(title='Show Commands and Documentation')
        from ViewerFramework.basicCommand import commandslist
        cname = commandslist
        cname.sort()

        idf.append({
            'name': 'cmdList',
            'widgetType': kbScrolledListBox,
            'wcfg': {
                'items': cname,
                'listbox_exportselection': 0,
                'labelpos': 'nw',
                'label_text': 'Loaded commands:',
                'selectioncommand': self.displayCmds_cb,
            },
            'gridcfg': {
                'sticky': 'wesn',
                'columnspan': 1,
                'weight': 20
            }
        })

        idf.append({
            'name': 'doclist',
            'widgetType': kbScrolledListBox,
            'wcfg': {
                'items': [],
                'listbox_exportselection': 0,
                #'listbox_selectmode':'extended',
                'labelpos': 'nw',
                'labelmargin': 0,
                'label_text': 'DOCUMENTATION',
                'listbox_width': 30
            },
            'gridcfg': {
                'sticky': 'wesn',
                'row': -1,
                'columnspan': 1,
                'weight': 20
            }
        })

        idf.append({
            'name': 'dismiss',
            'widgetType': Tkinter.Button,
            'wcfg': {
                'text': 'DISMISS',
                'command': self.dismiss_cb,
            },
            'gridcfg': {
                'sticky': 'ew',
                'columnspan': 3
            }
        })

        return idf
Beispiel #28
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)
    def buildFormDescr(self, formName):
        #from Pmv.selectionCommands import sets__
        #if not sets__.keys():
        if not self.vf.sets.keys():
            self.warningMsg("No sets defined!")
            return

        ifd = InputFormDescr(title = 'Select Sets')

        gridrow = 0
        #for k in sets__.keys():
        for k in self.vf.sets.keys():
            ifd.append({'name': k,
                    'widgetType':Tkinter.Checkbutton,
                    'wcfg':{ 'text': k,
                             'variable': Tkinter.IntVar(),
                             'command': None},
                    'gridcfg':{'sticky':Tkinter.W,'row':gridrow,'column':0,
                               'columnspan':2},
                    })
            gridrow = gridrow + 1
        return ifd
Beispiel #30
0
    def doit(self):
        import thread

        idf = InputFormDescr("Viewerframework server connection!")
        idf.append({'widgetType':Tkinter.Entry,
                    'name': 'host','defaultValue':'localhost',
                    'wcfg':{'label':'Host name or IP'}, 
                    'gridcfg':{'sticky':Tkinter.E}
                   })
        idf.append({'widgetType':Tkinter.Entry,
                    'name': 'port','defaultValue':'50000',
                    'wcfg':{'label':"Server's Port"}, 
                    'gridcfg':{'sticky':Tkinter.E}
                    })
        self.idf = idf
        val = self.vf.getUserInput(idf)
        self.vf.socketComm.connectToServer(val['host'], int(val['port']),
                                           self.vf.server_cb)

        # create a threadsafe command queue
        from Queue import Queue
        self.vf.cmdQueue = Queue(-1) # infinite size
        self.vf.GUI.ROOT.after(10, self.vf.runServerCommands)
Beispiel #31
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)
Beispiel #32
0
    def buildInputFormDescr(self):
        """to be implemented by sub-class"""

        ifd = InputFormDescr()
        ifd.title = "MSMSsel picker"
        ifd.append({
            'widgetType': Tkinter.Label,
            'name': 'event',
            'wcfg': {
                'text': 'event: ' + self.event
            },
            'gridcfg': {
                'sticky': Tkinter.W
            }
        })
        ifd.append({
            'widgetType': Pmw.EntryField,
            'name': 'Surface',
            'wcfg': {
                'labelpos': 'w',
                'label_text': 'Surface name: ',
                'validate': None
            },
            'gridcfg': {
                'sticky': 'we'
            }
        })
        ifd.append({
            'widgetType': Tkinter.Button,
            'name': 'Cancel',
            'wcfg': {
                'text': 'Cancel',
                'command': self.Cancel
            }
        })

        if self.numberOfObjects == None:
            ifd.append({
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'Done'
                },
                'command': self.stop
            })
        return ifd
Beispiel #33
0
    def buildFormDescr(self, formName):

        if not formName == 'Show MailingLists':
            return
        idf = InputFormDescr(title='Show MailingLists')
        self.mailinglists_pages = ["Login Page", "Archive Page"]
        idf.append({
            'name': 'pmvlist',
            'widgetType': kbScrolledListBox,
            'wcfg': {
                'items': self.mailinglists_pages,
                'listbox_exportselection': 0,
                'labelpos': 'nw',
                'label_text': 'Pmv Mailing List',
                'selectioncommand': self.mailCmds_cb,
                'listbox_height': 3,
                #'hscrollmode':'dynamic',
            },
            'gridcfg': {
                'sticky': 'wesn',
                'columnspan': 1
            }
        })

        idf.append({
            'name': 'visionlist',
            'widgetType': kbScrolledListBox,
            'wcfg': {
                'items': self.mailinglists_pages,
                'listbox_exportselection': 0,
                'labelpos': 'nw',
                'label_text': 'Vision Mailing List',
                'selectioncommand': self.mailCmds_cb,
                'listbox_height': 3,
                #'hscrollmode':'dynamic',
            },
            'gridcfg': {
                'sticky': 'wesn',
                'columnspan': 1
            }
        })
        idf.append({
            'name': 'dismiss',
            'widgetType': Tkinter.Button,
            'wcfg': {
                'text': 'DISMISS',
                'command': self.dismiss_cb,
            },
            'gridcfg': {
                'sticky': 'ew',
                'columnspan': 3
            }
        })
        return idf
Beispiel #34
0
    def buildFormDescr(self, formName):

        if formName == 'chooseCitation':
            idf = InputFormDescr(title="Choose Package")
            pname = self.citations.keys()
            #pname.sort()
            idf.append({
                'name': 'packList',
                'widgetType': Pmw.ScrolledListBox,
                'wcfg': {
                    'items': pname,
                    'listbox_exportselection': 0,
                    'labelpos': 'nw',
                    'usehullsize': 1,
                    'hull_width': 100,
                    'hull_height': 150,
                    'listbox_height': 5,
                    'listbox_width': 150,
                    'label_text': 'Select a package:',
                    'selectioncommand': self.displayCitation_cb,
                },
                'gridcfg': {
                    'sticky': 'wesn'
                }
            })

            idf.append({
                'name': 'citation',
                'widgetType': Pmw.ScrolledText,
                'wcfg': {
                    'labelpos': 'nw',
                    'text_width': 60,
                    'text_height': 10
                },
                'gridcfg': {
                    'sticky': 'wens'
                }
            })
            idf.append({
                'name': 'dismiss',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'DISMISS',
                    'command': self.dismiss_cb,
                },
                'gridcfg': {
                    'sticky': 'wens'
                }
            })
            return idf
    def buildFormDescr(self, formName):
        if formName == 'readViews':
            idf = InputFormDescr(title="Read Views")
            idf.append({'name':'orientfile',
                        'required':1,
                        'widgetType':Pmw.EntryField,
                        'tooltip':"Please type in the path to the _orient.py file \nor click on the BROWSE button to open a file browser",
                        'wcfg':{'labelpos':'w',
                                'label_text':"Orientations Filename",
                                },
                        'gridcfg':{'sticky':'w'}})

            idf.append({'widgetType':LoadButton,
                        'name':'browseOrient',
                        'wcfg':{'buttonType':Tkinter.Button,
                                'title':'Open views orientation file',
                                'types':[('Views orient','*_orient.py')],
                                'callback':self.setOrientEntry_cb,
                                'widgetwcfg':{'text':'BROWSE'}},
                        'gridcfg':{'row':-1, 'sticky':'we'}})
            idf.append({'name':'reprfile',
                        'required':1,
                        'tooltip':"Please type in the path to the _repr.db file\nor click on the BROWSE button to open a file browser",
                        'widgetType':Pmw.EntryField,
                        'wcfg':{'labelpos':'w',
                                'label_text':"Representations Filename",
                                },
                        'gridcfg':{'sticky':'w'}})

            idf.append({'widgetType':LoadButton,
                        'name':'browseRepr',
                        'wcfg':{'buttonType':Tkinter.Button,
                                'title': 'Open views representation file',
                                'types':[('Views orient','*_repr.db')],
                                'callback':self.setReprEntry_cb,
                                'widgetwcfg':{'text':'BROWSE'}},
                        'gridcfg':{'row':-1, 'sticky':'we'}})

            return idf
def createDescr():
    descr = InputFormDescr(title = 'Testing InputForm')
    descr.append({'name':'checkbutton',
                  'widgetType':Tkinter.Checkbutton,
                  'wcfg':{'text':'Checkbutton',
                          'variable':Tkinter.IntVar()},
                  'gridcfg':{'sticky':'w'}})
    

    descr.append({'name':'radioselect',
                'widgetType':Pmw.RadioSelect,
                'listtext':['rb1', 'rb2', 'rb3','rb4', 'rb5', 'rb6',
                            'rb7', 'rb8', 'rb9','rb10', 'rb11', 'rb12'],
                'wcfg':{'labelpos':'n',
                        'label_text':'Radiobuttons: ',
                        'orient':'vertical',
                        'buttontype':'radiobutton'},
                'gridcfg':{'sticky':'w'} })

    descr.append({'name':'radioselect2',
                'widgetType':Pmw.RadioSelect,
                'listtext':['rb1', 'rb2', 'rb3','rb4', 'rb5', 'rb6',
                            'rb7', 'rb8', 'rb9','rb10', 'rb11', 'rb12'],
                'wcfg':{'labelpos':'n',
                        'label_text':'Radiobuttons: ',
                        'orient':'horizontal',
                        'buttontype':'radiobutton'},
                'gridcfg':{'sticky':'w'} })
    entries = [('Chocolate',None), ('Vanilla', None), ('Strawberry', None),
               ('Coffee',None), ('Pistachio', None), ('Rasberry',None),
               ]

    descr.append({'name':'listchooser',
                  'widgetType':ListChooser,
                  'wcfg':{'entries':entries},
                  'gridcfg':{'sticky':'w'}
                  })
    
    return descr
    def buildFormDescr(self, formName):
        
        if not formName == 'showCmds': return
        idf = InputFormDescr(title='Show Commands and Documentation')
        from ViewerFramework.basicCommand import commandslist
        cname = commandslist
        cname.sort()
        
        

        idf.append({'name':'cmdList',
                    'widgetType':kbScrolledListBox,
                    'wcfg':{'items':cname,
                            'listbox_exportselection':0,
                            'labelpos':'nw',
                            'label_text':'Loaded commands:',
                            'selectioncommand':self.displayCmds_cb,
                            
                            },
                    'gridcfg':{'sticky':'wesn','columnspan':1, 'weight':20}})

        
        idf.append({'name':'doclist',
                    'widgetType':kbScrolledListBox,
                    'wcfg':{'items':[],
                            'listbox_exportselection':0,
                            #'listbox_selectmode':'extended',
                            'labelpos':'nw',
                            'labelmargin':0,
                            'label_text':'DOCUMENTATION',
                            'listbox_width':30                                                        
                            },
                    'gridcfg':{'sticky':'wesn','row':-1,'columnspan':1,  'weight':20}})
        
        idf.append({'name':'dismiss',
                    'widgetType':Tkinter.Button,
                    'wcfg':{'text':'DISMISS',
                            'command':self.dismiss_cb,
                            },
                    'gridcfg':{'sticky':'ew','columnspan':3}})
        
        

        return idf
 def buildFormDescr(self, formName):
     
     
     if not formName == 'Show MailingLists': 
         return
     idf = InputFormDescr(title='Show MailingLists')
     self.mailinglists_pages=["Login Page","Archive Page"] 
     idf.append({'name':'pmvlist',
                 'widgetType':kbScrolledListBox,
                 'wcfg':{'items':self.mailinglists_pages,
                         'listbox_exportselection':0,
                         'labelpos':'nw',
                         'label_text':'Pmv Mailing List',
                         'selectioncommand':self.mailCmds_cb,
                         'listbox_height':3 ,
                         #'hscrollmode':'dynamic',
                         },
                 'gridcfg':{'sticky':'wesn','columnspan':1}})
     
     idf.append({'name':'visionlist',
                 'widgetType':kbScrolledListBox,
                 'wcfg':{'items':self.mailinglists_pages,
                         'listbox_exportselection':0,
                         'labelpos':'nw',
                         'label_text':'Vision Mailing List',
                         'selectioncommand':self.mailCmds_cb,
                         'listbox_height':3,
                         #'hscrollmode':'dynamic',
                         },
                 'gridcfg':{'sticky':'wesn','columnspan':1}})
     idf.append({'name':'dismiss',
                 'widgetType':Tkinter.Button,
                 'wcfg':{'text':'DISMISS',
                         'command':self.dismiss_cb,
                         },
                 'gridcfg':{'sticky':'ew','columnspan':3}})
     return idf
Beispiel #39
0
    def editShader(self):
		self.shader_edited= True
		shname = self.form.descr.entryByName['pigment']['widget'].get()	
		shaderP = self.shadDic[shname]
		idf = InputFormDescr(title =shname)
		k=0
		for i in shaderP : 
			W=4
			tmp=i.replace("\"","").split(",")
			P=tmp[0].split(" ")
			V=tmp[1]
			if P[0] == "string" : 
				P[0]="str"
				W=16
			else :	V=eval(V)	
			idf.append({	'name':P[1],
                    			'widgetType':Pmw.EntryField,
                    			'type':eval(P[0]),
                    			'wcfg':{'labelpos':'w',
                        		'label_text':tmp[0],
                            		'validate':'real',
                            		'value':V,
                            		'entry_width':W},
                    			'gridcfg':{'column':0, 'row':k, 'sticky':'w'}})
			k=k+1
      		idf.append({'name':'Set',
                    'widgetType':Tkinter.Button,
                    'wcfg':{'text':'ApplyChange','command': self.SetShader},
                    'gridcfg':{'column':0,
                               'row':k,'sticky':'ew'}})
	        idf.append({'name':'help',
                    'widgetType':Tkinter.Button,
                    'defaultValue':0,
                    'wcfg':{'text':'Help','command': self.helpShader},
                    'gridcfg':{'column':1, 'row':k,'sticky':'ew'}})

		self.formS = self.vf.getUserInput(idf, modal = 0, blocking = 0)
Beispiel #40
0
    def buildFormDescr(self, formName):
        if formName == 'citationHelp':
            idf = InputFormDescr(title="Choose Package")
            citeKeys = self.vf.showCitation.citations.keys()

            txt = """
 This widget helps you cite the use of appropriate packages in your publication. 
 Based on the information we collected, please cite the following publications:   """

            idf.append({
                'name': 'help',
                'widgetType': Tkinter.Label,
                'wcfg': {
                    'text': txt,
                    'justify': Tkinter.LEFT
                },
                'gridcfg': {
                    'sticky': 'wens',
                    'columnspan': 2
                }
            })

            txt = """ADT/PMV/ViewerFramework:
    Michel F. Sanner. Python: A Programming Language for
    Software Integration and Development. J. Mol. Graphics
    Mod., 1999, Vol 17, February. pp57-61
"""
            #this is the part where we find out which packages are used
            MSMS = False
            isocontour = False
            volRen = False
            APBS = False
            PROSS = False
            if hasattr(self.vf, 'Mols'):
                for mol in self.vf.Mols:
                    if 'secondarystructure' in mol.geomContainer.geoms.keys():
                        PROSS = True
                    if 'MSMS-MOL' in mol.geomContainer.geoms.keys():
                        MSMS = True
            for gridName in self.vf.grids3D:
                if '.potential.dx' in gridName:
                    APBS = True
                grid = self.vf.grids3D[gridName]
                if hasattr(grid, 'isoBarNumber') and grid.isoBarNumber > 0:
                    isocontour = True
                if hasattr(grid, 'volRenGrid'):
                    volRen = True
            if MSMS:
                txt += """
MSMS:                
    Sanner, M.F., Spehner, J.-C., and Olson, A.J. (1996) Reduced
    surface: an efficient way to compute molecular surfaces.
    Biopolymers, Vol. 38, (3),305-320.               
"""
            if APBS:
                txt += """
APBS:           
    Baker NA, Sept D, Joseph S, Holst MJ, McCammon JA. Electrostatics 
    of nanosystems: application to microtubules and the ribosome. 
    /Proc. Natl. Acad. Sci. USA/ *98*, 10037-10041 2001 
"""
            if isocontour:
                txt += """
IsoContour:                
    Bajaj, C, Pascucci, V., Schikore, D., (1996), Fast IsoContouring
    for Improved Interactivity, Proceedings of  ACM Siggraph/IEEE
    Symposium on Volume Visualization, ACM Press, 1996, pages 39 - 46,
    San Francisco, CA      
"""
            if volRen:
                txt += """
Volume Rendering:           
    Bajaj, C, Park, S., Thane, A., (2002), A Parallel Multi-PC
    Volume Rendering System, ICES and CS Technical Report, University
    of Texas, 2002. 
"""
            if PROSS:
                txt += """
Secondary Structure:           
    Srinivasan R, Rose GD. (1999) A physical basis for protein 
    secondary structure. Proc. Natl. Acad. Sci. USA  96, 14258-63.
"""
            idf.append({
                'name': 'citation',
                'widgetType': Pmw.ScrolledText,
                'defaultValue': txt,
                'gridcfg': {
                    'sticky': 'wens',
                    'columnspan': 2
                }
            })

            idf.append({
                'name': 'save',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'Save As',
                    'command': self.save,
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 2,
                    'column': 0
                }
            })

            idf.append({
                'name': 'dismiss',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'DISMISS',
                    'command': self.dismiss_cb,
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 2,
                    'column': 1
                }
            })
            return idf
    def buildFormDescr(self, formName):
        if formName=='addPairs':
            # CREATE PAIRS GROUP
            idf = InputFormDescr(title="Superimpose")
            idf.append({'name':"mode",
                        'widgetType':Pmw.Group,
                        'container':{'mode':'w.interior()'},
                        'wcfg':{'tag_text':"Create Reference Nodes and Mobile Nodes Lists"},
                        'gridcfg':{'sticky':'wnse'}
                        })
            idf.append({'widgetType':Tkinter.Label,
                        'parent':'mode',
                        'wcfg':{'text':'By String'},
                        'gridcfg':{'sticky':'we'}}
                       )
            idf.append({'widgetType':Tkinter.Checkbutton,
                        'name':'string',
                        'parent':'mode',
                        #'tooltip':'Use the string selector to create refnode-mobnodes pairs',
                        'wcfg':{'text':'on/off','command':self.string_cb},
                        'gridcfg':{'sticky':'we','row':-1}})

            idf.append({'widgetType':Tkinter.Label,
                        'parent':'mode',
                        'wcfg':{'text':'By Picking'},
                        'gridcfg':{'sticky':'we', 'row':-1}}
                       )

            idf.append({'widgetType':Tkinter.Checkbutton,
                        'name':'pick',
                        'tooltip':'Use the picking event to create refnode-mobnodes pairs',
                        'parent':'mode',
                        'wcfg':{'text':'on/off','command':self.pick_cb},
                        'gridcfg':{'sticky':'we','row':-1}})
            
            
            ###############################################################
            ## EDIT REF/MOB NODES
            ###############################################################
            idf.append({'name':"editnodes",
                        'widgetType':Pmw.Group,
                        'container':{'editnodes':'w.interior()'},
                        'wcfg':{'tag_text':"Edit Reference Nodes and Mobile Nodes Lists:"},
                        'gridcfg':{'sticky':'wnse'}
                        })

            idf.append({'name':'refremove',
                        'parent':'editnodes',
                        'widgetType':Tkinter.Button,
                        'tooltip':""" Remove the selected entry from the
commands to be applied to the object when loaded in the application""",
                        'wcfg':{'text':'REMOVE','width':10,
                               'command':self.refremove_cb},
                        'gridcfg':{'sticky':'we', 'row':0, 'column':0}})

            idf.append({'name':'refoneup',
                        'parent':'editnodes',
                        'widgetType':Tkinter.Button,
                        'tooltip':"""Move the selected entry up one entry""",
                        'wcfg':{'text':'Move up','width':10,
                                'command':self.refmoveup_cb},
                        'gridcfg':{'sticky':'we', 'row':1, 'column':0}})

            idf.append({'name':'refonedown',
                        'parent':'editnodes',
                        'widgetType':Tkinter.Button,
                        'tooltip':"""Move the selected entry down one entry""",
                        'wcfg':{'text':'Move down','width':10,
                                'command':self.refmovedown_cb},
                        'gridcfg':{'sticky':'we', 'row':2, 'column':0}})


            
            # RefNodes listchooser
            idf.append({'widgetType':ListChooser,
                        'name':'refnodes',
                        'parent':'editnodes',
                        'tooltip':"""list of the reference nodes""",
                        'wcfg':{'entries':[],
                                'mode':'single',
                                'lbwcfg':{'exportselection':0},
                                'title':'Reference Nodes'},
                        'gridcfg':{'sticky':'we', 
                                   'row':0, 'column':1,'rowspan':3}})


            # MobNodes listchooser
            idf.append({'widgetType':ListChooser,
                        'name':'mobnodes',
                        'parent':'editnodes',
                        'tooltip':"""list of the mobile nodes""",
                        'wcfg':{'entries':[],
                                'mode':'single',
                                'lbwcfg':{'exportselection':0},
                                'title':'Mobile Nodes'},
                        'gridcfg':{'sticky':'we', 
                                   'row':0, 'column':2, 'rowspan':3}})

            
            idf.append({'name':'mobremove',
                        'parent':'editnodes',
                        'widgetType':Tkinter.Button,
                        'tooltip':""" Remove the selected mobile node""",
                        'wcfg':{'text':'REMOVE','width':10,
                               'command':self.mobremove_cb},
                        'gridcfg':{'sticky':'we','row':0, 'column':3}})

            idf.append({'name':'moboneup',
                        'parent':'editnodes',
                        'widgetType':Tkinter.Button,
                        'tooltip':"""Move the selected entry up one entry""",
                        'wcfg':{'text':'Move up','width':10,
                                'command':self.mobmoveup_cb},
                        'gridcfg':{'sticky':'we','row':1, 'column':3}})

            idf.append({'name':'mobonedown',
                        'parent':'editnodes',
                        'widgetType':Tkinter.Button,
                        'tooltip':"""Move the selected entry down one entry""",
                        'wcfg':{'text':'Move down','width':10,
                                'command':self.mobmovedown_cb},
                        'gridcfg':{'sticky':'we','row':2, 'column':3}})

            ###############################################################
            ## FILTERS
            ###############################################################
            
            idf.append({'name':"filter",
                        'widgetType':Pmw.Group,
                        'container':{'filters':'w.interior()'},
                        'wcfg':{'tag_text':"Apply Filters To The Ref/Mob nodes lists:"},
                        'gridcfg':{'sticky':'wnse'}
                        })
                                         
            idf.append({'widgetType':Pmw.ComboBox,
                        'name':'choice',
                        'parent':'filters',
                        'tooltip':"""This filter allows the user to choose
which atom to consider from the ref node or mob nodes sets to create the atom pairs""",
                        'defaultValue':self.defaultFilter,
                        'wcfg':{ 'scrolledlist_items': self.filters.keys(),
                                'selectioncommand':self.setDefault},
                        'gridcfg':{'sticky':'w'}})

            
            # If sets not of the same length:
            idf.append({'widgetType':Pmw.ComboBox,
                        'name':'slice',
                        'parent':'filters',
                        'defaultValue':'Beginning',
                        'tooltip':"""When the two sets of atoms are not of
the same length the user can chose what subset of the longest set to take,
beginning, the end or half and half""",
                        'wcfg':{'scrolledlist_items':['Beginning',
                                               'End',
                                               'Half/Half'],
                         },
                        'gridcfg':{'sticky':'w', 'row':-1}})


            return idf
            
        elif formName == 'pairs':
            idf = InputFormDescr(title="Pairwise Superimposition")


            # EDIT PAIRS GROUP
            idf.append({'name':"edit",
                        'widgetType':Pmw.Group,
                        'container':{'edit':'w.interior()'},
                        'wcfg':{'tag_text':"Edit Atom Pairs"},
                        'gridcfg':{'sticky':'wnse'}
                        })
                                         
            
            entries = map(lambda x: (x, None), self.newPairs.keys())
            idf.append({'widgetType':ListChooser,
                        'name':'newpairs',
                        'parent':'edit',
                        'wcfg':{'mode':'extended',
                                'entries':entries,
                                'lbwcfg':{'exportselection':1},
                                'title':'Reference Atoms    --    Mobile Atoms'},
                        'gridcfg':{'sticky':'wens', 'columnspan':2}})
            

            idf.append({'widgetType':Tkinter.Button,
                        'name': 'delete',
                        'parent':'edit',
                        'wcfg':{'width':15,'text': 'Add Pairs',
                                'command':self.add_cb},
                        'gridcfg':{'sticky':'we'}})

            idf.append({'widgetType':Tkinter.Button,
                        'name': 'delete',
                        'parent':'edit',
                        'wcfg':{'width':15,'text': 'Delete Pairs',
                                'command':self.delete_cb},
                        'gridcfg':{'sticky':'we', 'row':-1}})
            
            idf.append({'name':"superimpose",
                        'widgetType':Pmw.Group,
                        'container':{'superimpose':'w.interior()'},
                        'wcfg':{'tag_text':"Superimposation parameters"},
                        'gridcfg':{'sticky':'wnse'}
                        })
            # Continuous Superimposition
            idf.append({'widgetType':Tkinter.Checkbutton,
                        'name':'continuous',
                        'parent':'superimpose',
                        'wcfg':{'variable':Tkinter.IntVar(),
                                'text':'Continuous',
                                'command':self.continuous_cb,
                                'padx':10,'pady':10},
                        'gridcfg':{'sticky':'w'}})

                                         
            # Reset & SuperImpose button.
            idf.append({'widgetType':Tkinter.Button,
                        'name':'final',
                        'parent':'superimpose',
                        'wcfg':{'width':15,'text':'Superimpose',
                                'command':self.superimpose_cb},
                        'gridcfg':{'sticky':'we', 'row':-1}})

            idf.append({'widgetType':Tkinter.Button,
                        'parent':'superimpose',
                        'name':'reset',
                        'wcfg':{'text':'Reset', 'command':self.reset_cb},
                        'gridcfg':{'sticky':'we', 'row':-1}})


            idf.append({'widgetType':Tkinter.Button,
                        'name': 'dismiss',
                        'wcfg':{'text': 'DISMISS',
                                'command':self.dismiss_cb},
                        'gridcfg':{'sticky':'we', 'columnspan':2}})
            

            return idf

        elif formName == 'editString':

            idf = InputFormDescr(title = 'Get Nodes From String')
            
            idf.append({'name':"refgroup",
                        'widgetType':Pmw.Group,
                        'container':{'refgroup':'w.interior()'},
                        'wcfg':{'tag_text':"Reference Nodes:"},
                        'gridcfg':{'sticky':'wnse'}
                        })

            idf.append({'name':"mobgroup",
                        'widgetType':Pmw.Group,
                        'container':{'mobgroup':'w.interior()'},
                        'wcfg':{'tag_text':"Mobile Nodes:"},
                        'gridcfg':{'sticky':'wnse', 'row':-1}
                        })


            idf.append({ 'widgetType':StringSelectorGUI,
                         'parent':'refgroup',
                         'name':'srefNodes',
                         #'defaultValue':self.vf.Mols[0].name+", , , ",
                         'tooltip':'Please select the reference nodes set. By default the ref nodes will be the first molecule loaded in the viewer',
                         'wcfg':{ 'molSet': self.vf.Mols,
                                  'vf': self.vf,
                                  'all':1,
                                  'crColor':(1.,0.,0.),
                                  'forceEmpty':1,
                                  },
                         'gridcfg':{'sticky':'we' }})

            idf.append({ 'widgetType':StringSelectorGUI,
                         'parent':'mobgroup',
                         #'defaultValue':self.vf.Mols[1].name+", , , ",
                         'tooltip':'Please select the mobile nodes set. By default the mobile nodes will be the second molecule loaded in the viewer',
                         'name':'smobNodes',
                         'wcfg':{ 'molSet': self.vf.Mols,
                                  'vf': self.vf,
                                  'all':1,
                                  'crColor':(0.,0.,1.),'forceEmpty':1,
                                  },
                         'gridcfg':{'row':-1, 'sticky':'we' }})
            return idf
    def buildFormDescr(self, formName='default'):
        if formName == 'default': 
            # create the form descriptor
            formTitle = "Label" + self.vf.ICmdCaller.level.value.__name__ +\
                        " by properties"
            idf = InputFormDescr(title = formTitle)
            #val = self.nameDict[self.vf.ICmdCaller.level.value]
            val = self.level
            idf.append({'name':'display',
                        'widgetType':Pmw.RadioSelect,
                        'listtext':['label','label only', 'unlabel'],
                        'defaultValue':'label',
                        'wcfg':{'orient':'horizontal',
                                'buttontype':'radiobutton'},
                        'gridcfg':{'sticky': 'we','columnspan':3}})

            idf.append({'widgetType':Tkinter.Label,
                        'wcfg':{'text':'________________________________________________________',
                                },
                        'gridcfg':{'columnspan':3}})

            idf.append({'widgetType':Pmw.RadioSelect,
                        'name':'level',
                        'listtext':['Atom','Residue','Chain','Molecule'],
                        'listoption':self.leveloption,#listoption,
                        'defaultValue':val,
                        'wcfg':{'label_text':'Change the PCOM level:',
                                'labelpos':'nw',
                                'command':self.update_cb,
                                },
                        'gridcfg':{'sticky':'we','columnspan':3}})

            if len(self.properties)>0:
                propertyNames = map(lambda x: (x[0], None), self.properties)
                propertyNames.sort()

            idf.append({'name':'properties',
                        'widgetType':ListChooser,
                        'defaultValue':'name',
                        'wcfg':{'entries': propertyNames,
                                'title':'Choose one or more properties:',
                                'lbwcfg':{'exportselection':0},
                                'mode':'multiple','withComment':0},
                        'gridcfg':{'sticky':'we', 'rowspan':4, 'padx':5}})

            self.textColor = (1.,1.,1.)
            idf.append({'widgetType':Tkinter.Button,
                        'name':'textcolor',
                        'wcfg':{'text':'Choose Label Color:',
                                'command':self.chooseColor_cb, 
                                'bg':'white', 'activebackground':'white',
                                'borderwidth':4,
                                },
                        'gridcfg':{'sticky':'w','row':3, 'column':1}})

            idf.append({'name':'Labels settings',
                        'widgetType':Tkinter.Button,
                        'wcfg':{'text': 'Labels settings',
                                'command':self.labelsSettings_cb
                                },
                        'gridcfg':{'row':4,'column':1, 'sticky':'we'}})

            location = ['First','Center' ,'Last']
            idf.append({'widgetType':Pmw.ComboBox,
                        'name':'location',
                        'defaultValue':'Center',
                        'wcfg':{'label_text':'Label location: ',
                                'labelpos':'nw',
                                'scrolledlist_items': location},
                        'gridcfg':{'sticky':'w','row':5,'column':1}})
            formats = ['%d','%4.2f','%f','None']
            idf.append({'widgetType':Pmw.ComboBox,
                        'name':'format',
                        'defaultValue' : 'None',
                        'wcfg':{'label_text':'Label format: ',
                                'labelpos':'nw',
                                'scrolledlist_items': formats},
                        'gridcfg':{'sticky':'w','row':6,'column':1}})

            return idf

        elif formName=='chooser':
            idf = InputFormDescr(title = 'Choose Color')

            idf.append({'widgetType':ColorChooser,
                        'name':'colors',
                        'wcfg':{'commands':self.configureButton,
                                'exitFunction':self.dismiss_cb},
                        'gridcfg':{'sticky':'wens', 'columnspan':3,
                                   }
                        })
            return idf
    def buildFormDescr(self, formName='default'):
        if formName == 'default':
            # Create the form descriptor:
            formTitle = "Label by expression"
            idf = InputFormDescr(title = formTitle)

            idf.append({'name':'display',
                        'widgetType':Pmw.RadioSelect,
                        'listtext':['label','label only', 'unlabel'],
                        'defaultValue':'label',
                        'wcfg':{'orient':'horizontal',
                                'buttontype':'radiobutton'},
                        'gridcfg':{'sticky': 'we','columnspan':3}})

            idf.append({'widgetType':Tkinter.Label,
                        'wcfg':{'text':'________________________________________________________',
                                },
                        'gridcfg':{'columnspan':3}})
            #val = self.nameDict[self.vf.ICmdCaller.level.value]
            val = self.level
            idf.append({'widgetType':Pmw.RadioSelect,
                        'name':'level',
                        'listtext':['Atom','Residue','Chain','Molecule'],
                        'defaultValue':val,'listoption':self.leveloption,#listoption,
                        'wcfg':{'label_text':'Select the property level:',
                                'labelpos':'nw',
                                'command':self.update_cb,
                                },
                        'gridcfg':{'sticky':'we','columnspan':3}})
            
            idf.append({'name':'functiontype',
                        'widgetType':Pmw.RadioSelect,
                        'listtext':['lambda function', 'function'],
                        'defaultValue':'lambda function',
                        'wcfg':{'label_text':'Choose Expression type:',
                                'labelpos':'nw','orient':'horizontal',
                                'buttontype':'radiobutton',
                                'command':self.updateInfo_cb,
                                },
                        'gridcfg':{'sticky': 'we'}})

            self.textContent = self.mapText
            self.textLabel = self.mapLabel
            idf.append({'name':'function',
                        'widgetType':LoadOrSaveText,
                        'defaultValue': self.textContent,
                        'wcfg':{'textwcfg':{'labelpos':'nw',
                                            'label_text': self.textLabel,
                                            'usehullsize':1,
                                            'hull_width':500,
                                            'hull_height':280,
                                            'text_wrap':'none'},
                                },
                        'gridcfg':{'sticky': 'we','rowspan':4, 'padx':5}})

            idf.append({'widgetType':Tkinter.Label,
                        'wcfg':{'text':""},
                        'gridcfg':{'row':-1}})

            self.textColor = (1.,1.,1.)
            idf.append({'widgetType':Tkinter.Button,
                        'name':'textcolor',
                        'wcfg':{'text':'Choose Label Color:',
                                'command':self.chooseColor_cb,'borderwidth':4,
                                'bg':'white', 'activebackground':'white',
                                },
                        'gridcfg':{'sticky':'w','row':4,'column':1}})

            idf.append({'widgetType':Pmw.ComboBox,
                        'name':'font',
                        'defaultValue':GlfLabels.fontList[0],
                        'wcfg':{'label_text':'   Label font:',
                                'labelpos':'nw',
                                'scrolledlist_items': GlfLabels.fontList},
                        'gridcfg':{'sticky':'we','row':5,'column':1 }})

            location = ['First','Center' ,'Last']
            idf.append({'widgetType':Pmw.ComboBox,
                        'name':'location',
                        'defaultValue':'Center',
                        'wcfg':{'label_text':'Label location: ',
                                'labelpos':'nw',
                                'scrolledlist_items': location},
                        'gridcfg':{'sticky':'w','row':6,'column':1}})
            formats = ['%d','%4.2f','%f', 'None']
            idf.append({'widgetType':Pmw.ComboBox,
                        'name':'format',
                        'defaultValue': 'None',
                        'wcfg':{'label_text':'Label format: ',
                                'labelpos':'nw',
                                'scrolledlist_items': formats},
                        'gridcfg':{'sticky':'w','row':7,'column':1}})

            return idf

        elif formName=='chooser':
            idf = InputFormDescr(title = 'Choose Color')

            idf.append({'widgetType':ColorChooser,
                        'name':'colors',
                        'wcfg':{'commands':self.configureButton,
                                'exitFunction':self.dismiss_cb},
                        'gridcfg':{'sticky':'wens', 'columnspan':3}
                        })
            return idf
Beispiel #44
0
    def buildFormDescr(self, formName):
        if formName == 'infoForm':
            idf = InputFormDescr(title='Command Description')
            idf = InputFormDescr('Documentation')
            idf.append({
                'name': 'cmdDoc',
                'widgetType': Pmw.ScrolledText,
                'wcfg': {
                    'labelpos': 'nw',
                    'label_text': 'command documentation:',
                    'text_width': 50,
                    'text_height': 5
                },
                'gridcfg': {
                    'sticky': 'we'
                }
            })

            idf.append({
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'Dismiss',
                    'command': self.dismissDoc_cb
                },
                'gridcfg': {
                    'sticky': 'we'
                }
            })
            return idf
        elif formName == 'searchForm':
            idf = InputFormDescr(title='Search For Commands')

            idf.append({
                'name': 'searchGroup',
                'widgetType': Pmw.Group,
                'container': {
                    'searchGroup': "w.interior()"
                },
                'wcfg': {
                    'tag_text': 'Search Options'
                },
                'gridcfg': {
                    'sticky': 'wnse',
                    'columnspan': 2
                }
            })

            idf.append({
                'name': 'searchString',
                'widgetType': Pmw.EntryField,
                'parent': 'searchGroup',
                'wcfg': {
                    'label_text': 'Search String',
                    'labelpos': 'w',
                },
                'gridcfg': {
                    'sticky': 'wnse',
                    'columnspan': 2
                }
            })

            idf.append({
                'name': 'caseSensitive',
                'widgetType': Tkinter.Checkbutton,
                'parent': 'searchGroup',
                'wcfg': {
                    'text': 'Case sensitive',
                    'variable': Tkinter.IntVar(),
                },
                'gridcfg': {
                    'sticky': 'w'
                },
            })

            idf.append({
                'name': 'matchGroup',
                'widgetType': Pmw.Group,
                'parent': 'searchGroup',
                'container': {
                    'matchGroup': "w.interior()"
                },
                'wcfg': {
                    'tag_text': 'Match search string to'
                },
                'gridcfg': {
                    'sticky': 'wnse',
                    'columnspan': 2
                }
            })

            idf.append({
                'name': 'matchModName',
                'widgetType': Tkinter.Checkbutton,
                'parent': 'matchGroup',
                'defaultValue': 1,
                'tooltip':
                "The Search String will be matched against the modules name",
                'wcfg': {
                    'text': 'Module Name',
                    'variable': Tkinter.IntVar()
                },
                'gridcfg': {
                    'sticky': 'w'
                },
            })

            idf.append({
                'name': 'matchCmdName',
                'widgetType': Tkinter.Checkbutton,
                'parent': 'matchGroup',
                'defaultValue': 1,
                'tooltip':
                "The Search String will be matched against the commands name",
                'wcfg': {
                    'text': 'Command Name',
                    'variable': Tkinter.IntVar()
                },
                'gridcfg': {
                    'sticky': 'w'
                },
            })

            idf.append({
                'name': 'matchDocString',
                'widgetType': Tkinter.Checkbutton,
                'parent': 'matchGroup',
                'defaultValue': 1,
                'tooltip':
                "The Search String will be matched against the content of the documentation string",
                'wcfg': {
                    'text': 'Documentation String',
                    'variable': Tkinter.IntVar()
                },
                'gridcfg': {
                    'sticky': 'w'
                },
            })

            idf.append({
                'name': 'choices',
                'widgetType': Pmw.RadioSelect,
                'parent': 'searchGroup',
                'defaultValue': 'Default Packages',
                'listtext': ['Default Packages', 'All Packages'],
                'tooltip':
                "Choose where to look for a command: \n- Default packages  \n-All packages on disk which is slower",
                'wcfg': {
                    'labelpos': 'nw',
                    'label_text': 'Search in:',
                    'buttontype': 'radiobutton'
                },
                'gridcfg': {
                    'sticky': 'w'
                }
            })

            idf.append({
                'name': 'search',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'SEARCH',
                    'command': self.searchCmd_cb
                },
                'gridcfg': {
                    'columnspan': 2
                }
            })

            idf.append({
                'name': 'resultGroup',
                'widgetType': Pmw.Group,
                'container': {
                    'resultGroup': "w.interior()"
                },
                'wcfg': {
                    'tag_text': 'Search Result'
                },
                'gridcfg': {
                    'sticky': 'wnse',
                    'columnspan': 2
                }
            })

            idf.append({
                'name': 'cmdFound',
                'widgetType': kbScrolledListBox,
                'parent': 'resultGroup',
                'tooltip':
                "This widget will list all the commands found with the search string.",
                'wcfg': {
                    'items': [],
                    'listbox_exportselection': 0,
                    'labelpos': 'nw',
                    'label_text': 'Found Commands:',
                    'dblclickcommand': self.loadCmd_cb
                },
                'gridcfg': {
                    'sticky': 'wesn',
                    'columnspan': 2
                }
            })

            idf.append({
                'name': 'info',
                'widgetType': Tkinter.Button,
                'parent': 'resultGroup',
                'tooltip':
                "Display the documentation string of the selected command.",
                'wcfg': {
                    'text': 'INFO',
                    'height': 1,
                    'command': self.info_cb
                },
                'gridcfg': {
                    'sticky': 'wesn'
                }
            })

            idf.append({
                'name': 'load',
                'widgetType': Tkinter.Button,
                'parent': 'resultGroup',
                'tooltip': "Show the selected commands in the application",
                'wcfg': {
                    'text': 'LOAD',
                    'height': 1,
                    'command': self.loadCmd_cb
                },
                'gridcfg': {
                    'sticky': 'wesn',
                    'row': -1
                }
            })

            ##         idf.append({'name':'cmdLoaded',
            ##                     'widgetType':kbScrolledListBox,
            ##                     'parent':'resultGroup',
            ##                     'tooltip':"This widget will list all the commands found with the search \nstring that have already been loaded in the application",
            ##                     'wcfg':{'items':[],
            ##                             'listbox_exportselection':0,
            ##                             'labelpos':'nw',
            ##                             'label_text':'Loaded Commands:',
            ##                             },
            ##                     'gridcfg':{'sticky':'wesn', 'rowspan':2,
            ##                                'column':2, 'row':0}})

            idf.append({
                'name': 'search',
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'DISMISS',
                    'command': self.dismiss_cb
                },
                'gridcfg': {
                    'columnspan': 2
                }
            })
            return idf
    def guiCallback(self, event=None):
        fileList = [] 
        fld_list = glob.glob('*.maps.fld')
        if not fld_list:
            tkMessageBox.showinfo("AutoLigand Info", "AutoLigand requires input AutoGrid maps. \nPlease click OK to select directory containing grid maps.")
            folder = tkFileDialog.askdirectory(title="Select A Folder")
            if folder:
                os.chdir(folder)
                fld_list = glob.glob('*.maps.fld')
            else:
                return
            
        for fld in fld_list:
            fileList.append(fld.split('.')[0])
        entryfield_value = ""
        if fileList:
            fileList.sort()
            entryfield_value = fileList[0]
    
        ifd = InputFormDescr(title="Run AutoLigand")
        ifd.append({'widgetType':Pmw.ComboBox,
                    'name':'FileBaseName',
                    'tooltip':'FileBaseName = just the name part from map files (FileBaseName.C.map)',
                    'wcfg':{'label_text':"File Base Name: ",
                            'dropdown':1,
                            'scrolledlist_items':fileList,
                            'entryfield_value':entryfield_value,
                            'selectioncommand':self.selectGrid,
                            'labelpos':'w',}
                    })
        ifd.append({'widgetType':Pmw.EntryField,
                    'name':'#_of_pts',
                    'tooltip':'#_of_pts =  number of fill points you want to use (int)',
                    'wcfg':{'label_text':"Number of Points:",
                            'labelpos':'w',
                            'value':'100',
                            'validate':{'validator':'integer'}
                            }
                    })

        ifd.append({'name':"StartLoc",
                    'widgetType':Pmw.Group,
                    'container':{'StartLoc':'w.interior()'},
                    'wcfg':{'tag_text':"Start Location"},
                    })        
        
        ifd.append({'widgetType':ExtendedSliderWidget,
                'name':'gridPointsX',
                'parent':'StartLoc',
                'wcfg':{'label':'X: ',
                        'width':190,
                        'immediate':1,
                        'command':self.changeCross,
                        'entrypackcfg':{'side':'left'},},
                })        
        ifd.append({'widgetType':ExtendedSliderWidget,
                'name':'gridPointsY',
                'parent':'StartLoc',
                'wcfg':{'label':'Y: ',
                        'width':190,
                        'immediate':1,
                        'command':self.changeCross,
                        'entrypackcfg':{'side':'left'},},
                })        
        ifd.append({'widgetType':ExtendedSliderWidget,
                'name':'gridPointsZ',
                'parent':'StartLoc',
                'wcfg':{'label':'Z: ',                    
                        'width':190,
                        'immediate':1,                        
                        'command':self.changeCross,                        
                        'entrypackcfg':{'side':'left'},},
                })        

        ifd.append({'name':"output",
                    'widgetType':Pmw.Group,
                    'container':{'output':'w.interior()'},
                    'wcfg':{'tag_text':"Output Options"},
                    })        
        ifd.append({'name':'pdbFile',
                    'tooltip':"""Creates PDB_fill_#Nout1.pdb file where #N is the number of fill points.""",
                    'parent':'output',
                    'widgetType':Tkinter.Checkbutton,
                    'defaultValue': 1,
                    'wcfg':{'text':'Create PDB of the Final Fill',
                            'state':'disabled',
                            
                            },
                    'gridcfg':{'sticky':'w'}
                    })        

        ifd.append({'name':'showProgress',
                    'parent':'output',
                    'tooltip':"""Save intermediate results in a file and open flood player when AutoLigand finishes.""",
                    'widgetType':Tkinter.Checkbutton,
                    'defaultValue': 0,
                    'wcfg':{'text':'Save Intermediate Results for Movie',
                            'variable':Tkinter.IntVar(),
                            },
                    'gridcfg':{'sticky':'w'}
                    })        
                
        def initselect(arg):
            self.selectGrid(entryfield_value)

        self.ifd = ifd
        self.save = self.vf.ICmdCaller.commands.value[None]
        self.vf.setICOM(self, topCommand=0)
        self.vf.setIcomLevel( Atom )
                
        val = self.vf.getUserInput(ifd,modal=0, blocking=1,
                                   initFunc=initselect)
        if self.save:
            self.vf.setICOM(self.save)
            self.save = None

        if val: 
            if not val['FileBaseName'][0]:
                msg = "AutoGrid files are missing.\n"
                msg += "Please generate grid maps and/or make sure \nthat they are in the current working directory."
                tkMessageBox.showerror("Error!", msg)
                return
            cmdString = [sys.executable, AutoLigandPath]
            cmdString.append(val['FileBaseName'][0])
            self.fileBaseName = val['FileBaseName'][0]
            cmdString.append(str(val['#_of_pts']))
            cmdString.append(str(val['gridPointsX']))
            cmdString.append(str(val['gridPointsY']))
            cmdString.append(str(val['gridPointsZ']))
            if sys.platform == "win32":
                self.cmdTxt = subprocess.list2cmdline(cmdString)
            else:
                self.cmdTxt = ' '.join(cmdString)            
            if val['showProgress']:
                self.cmdTxt += " -out-progress"
                self.showPlayer = True
            else:
                self.showPlayer = False
            self.cmd = SysCmdInThread(self.cmdTxt, shell=True)
            self.cmd.start()
            self.checkResults()
            
            self.N_of_pts = val['#_of_pts']            
        else:
            self.hideGeoms()
Beispiel #46
0
class MoleculeChooser:
    """presents user w/ a list of molecules currently loaded;
mode can be 'single', 'browse', 'multiple' or 'extended'.
Molecules can be selected from the list or by picking in the camera.

OK button returns a list of entries which have been selected.
Cancel returns an empty list. 
Typical usage is:
    ans = MoleculeChooser(self.vf).go()
    if ans !=[]:
        then get the value(s)
NB: this class doesn't grab the focus and binds picking w/
B1 to selecting the molecule in the MoleculeChooser. """
    def __init__(self, viewer, mode='single', title='Choose Molecule'):

        self.vf = viewer
        self.mode = mode
        self.ipf = InputFormDescr(title=title)

    def done_cb(self):
        self.ap.stop()
        self.ipf.form.destroy()
        self.ipf.form = None

    def go(self, modal=1, blocking=0, event="<ButtonRelease-1>"):
        """Start the form"""

        entries = []
        for i in range(len(self.vf.Mols)):
            mol = self.vf.Mols[i]
            molParser = mol.parser
            molStr = molParser.getMoleculeInformation()
            entries.append((mol.name, molStr))


##          self.ipf.insert(0,{'name': 'Molecule',
##                             'widgetType': 'ListChooser',
##                             'title' : 'select a molecule',
##                             'mode' : self.mode,
##                             'entries' : entries})

        self.ipf.insert(
            0, {
                'name': 'Molecule',
                'widgetType': ListChooser,
                'wcfg': {
                    'title': 'select a molecule',
                    'mode': self.mode,
                    'entries': entries
                },
                'gridcfg': {
                    'sticky': 'wens'
                }
            })

        if not (modal or blocking):
            self.ipf.append({
                'widgetType': Tkinter.Button,
                'wcfg': {
                    'text': 'Dismiss',
                    'command': self.done_cb
                },
                'gridcfg': {
                    'sticky': 'we'
                }
            })

        from Pmv.picker import AtomPicker
        self.ap = AtomPicker(self.vf,
                             None,
                             0,
                             callbacks=[self.onPick],
                             immediate=1)
        self.ap.go(modal=0)
        val = self.vf.getUserInput(self.ipf, modal=modal, blocking=blocking)
        if val:
            if modal or blocking:
                if len(val['Molecule']) == 1:
                    mols = self.vf.Mols.NodesFromName(val['Molecule'][0])
                    if self.mode == 'single': return mols[0]
                    return mols
                else:
                    molNames = ""
                    for m in val['Molecule']:
                        molNames = molNames + ',' + m
                    mols = self.vf.Mols.NodesFromName(molNames)
                    self.ap.stop()
                    if self.mode == 'single': return mols[0]
                    return mols
            else:
                self.form = val
                return val
        else:
            return val

    def getMolSet(self):
        """method to get currently selected molecules when the chooser is used
        in modal=0 and blocking=0 mode"""

        val = self.form.checkValues()
        if len(val['Molecule']) == 0:
            t = "Nothing selected!"
            self.vf.warningMsg(t, title="MoleculeChooser WARNING:")
            return None
        molNames = ""
        for m in val['Molecule']:
            # Create the list of names
            if molNames == "":
                molNames = m
            else:
                molNames = molNames + ";" + m
        mols = self.vf.Mols.NodesFromName(molNames)
        if self.mode == 'single': return mols[0]
        return mols

    def onPick(self, atoms):
        listChooser = self.ipf.entryByName['Molecule']['widget']
        tkListBox = listChooser.lb
        if atoms:
            pickedMol = atoms[0].top
            #then need to make pickedMol the selection in self.lc
            for i in range(len(listChooser.entries)):
                if pickedMol.name == listChooser.entries[i][0]:
                    self.pickedMolIndex = i
                    tkListBox.select_clear(0, 'end')
                    listChooser.select(i)
                    return
            print "error: %s not in mv.Mols" % pickedMol.name
Beispiel #47
0
class CenterChooser:
    """
    Class to allow a center to be defined (e.g. for the center of rotation
    for a list of docking transformations). Returns either `Center on Molecule',
    'Center on Selection', or a a list [x,y,z] specifying the center explicitly
    """
    def __init__(self, viewer):
        self.ifd = InputFormDescr(title='Choose Center of Rotation')
        self.vf = viewer

    def cancel_cb(self):
        self.form.destroy()

    def go(self, modal=1, blocking=0):
        self.ifd.append({
            'widgetType':
            Pmw.RadioSelect,
            'listtext':
            ['Center on Molecule', 'Center on Selection', 'Type in Center'],
            'defaultValue':
            'Type in Center',
            'wcfg': {
                'orient': 'vertical',
                'buttontype': 'radiobutton',
                'command': self.setButton,
            }
        })
        self.ifd.append({
            'widgetType': Pmw.EntryField,
            'name': 'X',
            'validator': 'real',
            'wcfg': {
                'label_text': 'X',
                'labelpos': 'w'
            },
            'gridcfg': {}
        })
        self.ifd.append({
            'widgetType': Pmw.EntryField,
            'name': 'Y',
            'wcfg': {
                'label_text': 'Y',
                'labelpos': 'w'
            },
            'gridcfg': {}
        })
        self.ifd.append({
            'widgetType': Pmw.EntryField,
            'name': 'Z',
            'wcfg': {
                'label_text': 'Z',
                'labelpos': 'w'
            },
            'gridcfg': {}
        })

        val = self.form = self.vf.getUserInput(self.ifd,
                                               modal=modal,
                                               blocking=blocking)
        if val:
            if not (val['X'] and val['Y'] and val['Z']):
                val = self.ifd[0]['widget'].selection
                if val == 'Type in Center':
                    val = 'Center on Molecule'
                print 'In CenterChooser: val =', val
                return val
            else:
                val = [float(val['X']), float(val['Y']), float(val['Z'])]
                return val

    def setButton(self, button):
        x = self.ifd.entryByName['X']
        y = self.ifd.entryByName['Y']
        z = self.ifd.entryByName['Z']
        if button == 'Type in Center':
            x['widget'].grid(x['gridcfg'])
            y['widget'].grid(y['gridcfg'])
            z['widget'].grid(z['gridcfg'])
        else:
            x['widget'].grid_forget()
            y['widget'].grid_forget()
            z['widget'].grid_forget()
    def buildFormDescr(self, formName):
        if formName == 'choosecmd':
            cmdNames = filter(lambda x, self=self: self.vf.commands[x].flag &
                              self.objArgOnly,
                              self.vf.commands.keys())
            cmdNames.sort()
            cmdEntries = map(lambda x: (x, None), cmdNames)

            onAddCmds = map(lambda x: x[0], self.vf.onAddObjectCmds)
            cmdToApplyNames = []
            cmdToApplyNames = filter(lambda x, vf=self.vf, onAddCmds=onAddCmds:
                                     vf.commands[x] in onAddCmds,
                                     cmdNames)

            cmdtoapply = map(lambda x: (x, None), cmdToApplyNames)
            idf = InputFormDescr(title="Cmds called after adding an object")
            idf.append({
                'name': 'cmdlist',
                'widgetType': ListChooser,
                'tooltip': """list of the commands loaded so far in the
application which can be applied to the object
when loaded in the application""",
                'wcfg': {
                    'entries': cmdEntries,
                    'mode': 'extended',
                    'lbwcfg': {
                        'exportselection': 0
                    },
                    'title': 'Available commands'
                },
                'gridcfg': {
                    'sticky': 'wens',
                    'row': 0,
                    'column': 0,
                    'rowspan': 3
                }
            })

            idf.append({
                'name': 'add',
                'widgetType': Tkinter.Button,
                'tooltip': """ Add the selected command from to the list
of commands to be applied to the object when loaded in the application""",
                'wcfg': {
                    'text': '>>',
                    'command': self.add_cb
                },
                'gridcfg': {
                    'row': 0,
                    'column': 1,
                    'rowspan': 3
                }
            })

            idf.append({
                'name': 'cmdtoapply',
                'widgetType': ListChooser,
                'tooltip': """list of the commands the user chose to
apply to the object when loaded in the application""",
                'wcfg': {
                    'entries': cmdtoapply,
                    'mode': 'single',
                    'lbwcfg': {
                        'exportselection': 0
                    },
                    'title': 'Commands to be applied'
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 0,
                    'column': 2,
                    'rowspan': 3
                }
            })

            idf.append({
                'name': 'remove',
                'widgetType': Tkinter.Button,
                'tooltip': """ Remove the selected entry from the
commands to be applied to the object when loaded in the application""",
                'wcfg': {
                    'text': 'REMOVE',
                    'width': 10,
                    'command': self.remove_cb
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 0,
                    'column': 3
                }
            })

            idf.append({
                'name': 'oneup',
                'widgetType': Tkinter.Button,
                'tooltip': """Move the selected entry up one entry""",
                'wcfg': {
                    'text': 'Move up',
                    'width': 10,
                    'command': self.moveup_cb
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 1,
                    'column': 3
                }
            })

            idf.append({
                'name': 'onedown',
                'widgetType': Tkinter.Button,
                'tooltip': """Move the selected entry down one entry""",
                'wcfg': {
                    'text': 'Move down',
                    'width': 10,
                    'command': self.movedown_cb
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 2,
                    'column': 3
                }
            })

            return idf
Beispiel #49
0
    def buildFormDescr(self, formName):
        ifd = InputFormDescr(title = "AutoGrid/AutoDock Web Services")
        #Web Services Login
        ifd.append({'name':"LoginGroup", 'widgetType':Pmw.Group,
                     'container':{'LoginGroup':'w.interior()'},
                     'wcfg':{'tag_text':'Web Services Location'},
                     'gridcfg':{'sticky':'nswe'}
                    })
        ifd.append({'widgetType':Pmw.ComboBox, 'name':'WS_address',
                    'parent':'LoginGroup',
                    'wcfg':{'scrolledlist_items':
                            ('http://ws.nbcr.net/opal2/services',),
                            'listheight':50, 'dropdown':1, 'history':1, 
                            'autoclear':1},
                     'gridcfg':{'sticky':'ew', 'row':0, 'column':0,
                                'columnspan':3}
                     })

#        ifd.append({'widgetType':Tkinter.Label, 'name':'New_User',
#                    'parent':'LoginGroup', 'wcfg':{'text':'   New Users?',
#                                           'fg':'Blue','cursor':'hand1'},
#                    'gridcfg':{'sticky':'w', 'row':1, 'column':0}
#                    })
#        ifd.append({'widgetType':Tkinter.Label, 'name':'UserName_Label',
#                    'parent':'LoginGroup', 'wcfg':{'text':'User Name'},
#                    'gridcfg':{'sticky':'e', 'row':1, 'column':1}
#                    })
#        ifd.append({'widgetType':Tkinter.Entry, 'name':'UserName_Entry',
#                    'parent':'LoginGroup','wcfg':{},
#                    'gridcfg':{'sticky':'ew', 'row':1, 'column':2}
#                    })
#        ifd.append({'widgetType':Tkinter.Label, 'name':'Password_Label',
#                    'parent':'LoginGroup', 'wcfg':{'text':'Password'},
#                    'gridcfg':{'sticky':'e', 'row':2, 'column':1}
#                    })
#        ifd.append({'widgetType':Tkinter.Entry, 'name':'Password_Entry',
#                    'parent':'LoginGroup', 'wcfg':{'show':'*'},
#                    'gridcfg':{'sticky':'ew', 'row':2, 'column':2}
#                    })
#        ifd.append({'widgetType':Tkinter.Label, 'name':'Remember_Label',
#                    'parent':'LoginGroup',
#                    'wcfg':{'text':'Remember User Name and Password'},
#                    'gridcfg':{'sticky':'e', 'row':3, 'column':0,'columnspan':2}
#                    })
#        self.RememberLogin_var = Tkinter.BooleanVar()
#        ifd.append({'widgetType':Tkinter.Checkbutton, 'name':'Remember_Checkbutton',
#                    'parent':'LoginGroup', 'variable':self.RememberLogin_var,
#                    'gridcfg':{'sticky':'w', 'row':3, 'column':2}
#                    })       
        #AutoGrid group
        ifd.append({'name':"AutoGrid", 'widgetType':Pmw.Group,
                    'container':{'AutoGrid':'w.interior()'},
                    'wcfg':{'tag_text':'AutoGrid'},
                    'gridcfg':{'sticky':'nswe'}
                    })
        
        ifd.append({'widgetType':Tkinter.Button, 'name':'Run_autogrid',
                    'parent':'AutoGrid', 
                    'wcfg':{'text':'Run AutoGrid ',
                            'command':self.startAutogrid},
                    'gridcfg':{'sticky':'w', 'row':0, 'column':0}
                    })

        ifd.append( {'name': 'gpf_entry', 'parent':'AutoGrid',
                     'widgetType':Tkinter.Entry, 
                     'wcfg':{'width':30,'textvariable':self.gpf},
                     'gridcfg':{'sticky':'w','row':0,'column':1}
                     })

        ifd.append({'name': 'browse_gpf', 'widgetType': Tkinter.Button,
                    'parent':'AutoGrid', 'text':'Browse',
                    'command':self.browse_gpf,
                    'gridcfg':{'sticky':'w','row':0, 'column':2}
                    })
        #AutoDock group
        ifd.append({'name':"AutoDock", 'widgetType':Pmw.Group,
                    'container':{'AutoDock':'w.interior()'},
                    'wcfg':{'tag_text':'AutoDock'},
                    'gridcfg':{'sticky':'nswe'}
                    })

        ifd.append({'widgetType':Tkinter.Button, 'name':'Run_autodock',
                    'parent':'AutoDock', 
                    'wcfg':{'text':'Run AutoDock',
                            'command':self.startAutodock},
                    'gridcfg':{'sticky':'w', 'row':0, 'column':0}
                    })

        ifd.append( {'name': 'dpf_entry', 'parent':'AutoDock',
                     'widgetType':Tkinter.Entry, 
                     'wcfg':{'width':30,'textvariable':self.dpf},
                     'gridcfg':{'sticky':'w','row':0,'column':1}
                     })

        ifd.append({'name': 'browse_dpf', 'widgetType': Tkinter.Button,
                    'parent':'AutoDock', 'text':'Browse',
                    'command':self.browse_dpf,
                    'gridcfg':{'sticky':'w','row':0, 'column':2}
                    })

        ifd.append({'name': 'ag_local', 'widgetType': Tkinter.Radiobutton,
                    'parent':'AutoDock', 'text':'Use local grids',
                    'tooltip':"This option sends locally stored grid files with Web Services request",
                    'wcfg':{'variable':self.ad_radio,'value':0},
                    'gridcfg':{'sticky':'w','row':1, 'column':0,'columnspan':2}
                    })

#        ifd.append({'name': 'ag_before', 'widgetType': Tkinter.Radiobutton,
#                    'parent':'AutoDock', 'text':'Run AutoGrid first',
#                    'tooltip':"This option runs AutoGrid Web Services and uses resulting map files for AutoDock",
#                    'wcfg':{'variable':self.ad_radio,'value':1,'state':'disabled'},
#                    'gridcfg':{'sticky':'w','row':2, 'column':0,'columnspan':2}
#                    })

        ifd.append({'name': 'use_remote', 'widgetType': Tkinter.Radiobutton,
                    'parent':'AutoDock', 'text':'Use grids from server directory',
                    'tooltip':"This option copies map files from previous AutoGrid run",
                    'wcfg':{'variable':self.ad_radio,'value':2,},
                    'gridcfg':{'sticky':'w','row':3, 'column':0,'columnspan':2}
                    })

        ifd.append( {'name': 'remote_dir', 'parent':'AutoDock',
                     'widgetType':Tkinter.Entry, 
                     'wcfg':{'width':23,'textvariable':self.prev_dir},
                     'gridcfg':{'sticky':'e','row':3,'column':1,'columnspan':2}
                     })

        #Status
        ifd.append({'name':"StatusGroup", 'widgetType':Pmw.Group,
                    'container':{'StatusGroup':'w.interior()'},
                    'wcfg':{'tag_text':'Web Services Status'},
                    'gridcfg':{'sticky':'nswe'}
                    })
        
        ifd.append({'widgetType':Tkinter.Label, 'name':'status0',
                    'parent':'StatusGroup', 
                    'wcfg':{'text':'   ',},
                    'gridcfg':{'sticky':'w', 'row':0, 'column':0}
                    })

        ifd.append({'widgetType':Tkinter.Label, 'name':'status1',
                    'parent':'StatusGroup', 
                    'wcfg':{'text':'   ',},
                    'gridcfg':{'sticky':'w', 'row':1, 'column':0}
                    })

        ifd.append({'name':'WS_ProgressBar', 'widgetType':Tkinter.Frame,
                    'parent':'StatusGroup', 'wcfg':{'height':30},
                     'gridcfg':{'sticky':'ew', 'row':2,'column':0}
                    })
        
        ifd.append({'widgetType':Tkinter.Label, 'name':'down_label',
                    'parent':'StatusGroup', 
                    'wcfg':{'text':'   ',},
                    'gridcfg':{'sticky':'w', 'row':3, 'column':0}
                    })
        
        return ifd
Beispiel #50
0
    def showForm(self):
        """create formdescr for setAnim
        form to set the animation:
        each frame is a list of geom to display
        """

        entryFrame = []
        for i in range(len(self.framelist)):
            val = 'frame_' + str(i)
            entryFrame.append((val, ))

        if not hasattr(self, 'form_Setanim'):
            ifd = InputFormDescr(title="SetAnimation")
            ifd.append({
                'widgetType': ListChooser,
                'name': 'availableGeom',
                'tooltip': 'geom available in viewer',
                'wcfg': {
                    'mode': 'extended',
                    'lbwcfg': {
                        'exportselection': 1
                    },
                    'command': [(self.toggleExpansion, '<Double-Button-1>')],
                    'commandEvent': None,
                    'title': 'availableGeom'
                },
                'gridcfg': {
                    'row': 0,
                    'column': 0,
                    'sticky': 'wens',
                    'rowspan': 3
                }
            })
            ifd.append({
                'name': 'newframe',
                'widgetType': Tkinter.Button,
                'tooltip': """ Add an empty frame to the animation""",
                'wcfg': {
                    'text': 'NewFrame',
                    'command': self.addframe_cb
                },
                'gridcfg': {
                    'row': 0,
                    'column': 1,
                    'rowspan': 1
                }
            })

            ifd.append({
                'name': 'add',
                'widgetType': Tkinter.Button,
                'tooltip': """ Add the selected geom to selected frame""",
                'wcfg': {
                    'text': 'AddGeom',
                    'command': self.add_cb
                },
                'gridcfg': {
                    'row': 1,
                    'column': 1,
                    'rowspan': 1
                }
            })

            ifd.append({
                'name': 'geomtoload',
                'widgetType': ListChooser,
                'tooltip': """list of frame  the user chose to
                        apply to the pattern""",
                'wcfg': {
                    'entries': entryFrame,
                    'mode': 'extended',
                    'lbwcfg': {
                        'exportselection': 0
                    },
                    'title': 'Frame(geom) to be display'
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 0,
                    'column': 2,
                    'rowspan': 3
                }
            })
            ifd.append({
                'name': 'remove',
                'widgetType': Tkinter.Button,
                'tooltip': """ Remove the selected entry from the
                        commands to be applied to the object when loaded in the application""",
                'wcfg': {
                    'text': 'REMOVE',
                    'width': 10,
                    'command': self.remove_cb
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 0,
                    'column': 3
                }
            })

            ifd.append({
                'name': 'oneup',
                'widgetType': Tkinter.Button,
                'tooltip': """Move the selected entry up one entry""",
                'wcfg': {
                    'text': 'Move up',
                    'width': 10,
                    'command': self.moveup_cb
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 1,
                    'column': 3
                }
            })

            ifd.append({
                'name': 'onedown',
                'widgetType': Tkinter.Button,
                'tooltip': """Move the selected entry down one entry""",
                'wcfg': {
                    'text': 'Move down',
                    'width': 10,
                    'command': self.movedown_cb
                },
                'gridcfg': {
                    'sticky': 'we',
                    'row': 2,
                    'column': 3
                }
            })

            self.form_Setanim = InputForm(self.master,
                                          None,
                                          descr=ifd,
                                          scrolledFrame=0)

            self.lc = self.form_Setanim.descr.entryByName['availableGeom'][
                'widget']
            self.lc2 = self.form_Setanim.descr.entryByName['geomtoload'][
                'widget']
            self.addObject(self.viewer.rootObject, None)
            val = self.form_Setanim.go()
            if val:
                self.assign()
                self.form_Setanim.withdraw()
        else:
            self.form_Setanim.deiconify()
            val = self.form_Setanim.go()
            if val:
                self.assign()
                self.form_Setanim.withdraw()
    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)
Beispiel #52
0
    def buildForm(self):
        ifd = InputFormDescr(title=self.ftitle)
        ifd.append({
            'widgetType': ListChooser,
            'name': 'availableGeom',
            'tooltip': 'geom available in viewer',
            'wcfg': {
                'mode': 'extended',
                'lbwcfg': {
                    'exportselection': 1
                },
                'command': [(self.toggleExpansion, '<Double-Button-1>')],
                'commandEvent': None,
                'title': 'availableGeom'
            },
            'gridcfg': {
                'row': 0,
                'column': 0,
                'sticky': 'wens',
                'rowspan': 3
            }
        })

        ifd.append({
            'name': 'add',
            'widgetType': Tkinter.Button,
            'tooltip': """ Add the selected geom to selected frame""",
            'wcfg': {
                'text': '>>',
                'command': self.add_cb
            },
            'gridcfg': {
                'row': 1,
                'column': 1,
                'rowspan': 1
            }
        })

        ifd.append({
            'name': 'remove',
            'widgetType': Tkinter.Button,
            'tooltip': """ remove the selected geom to selected """,
            'wcfg': {
                'text': '<<',
                'command': self.remove_cb
            },
            'gridcfg': {
                'row': 2,
                'column': 1,
                'rowspan': 1
            }
        })

        ifd.append({
            'name': 'toload',
            'widgetType': ListChooser,
            'tooltip': """list of geom  the user chose to
                    apply to the pattern""",
            'wcfg': {
                'mode': 'extended',
                'lbwcfg': {
                    'exportselection': 0
                },
                'title': self.lc2title
            },
            'gridcfg': {
                'sticky': 'we',
                'row': 0,
                'column': 2,
                'rowspan': 3
            }
        })
        ifd.append({
            'name': 'clear',
            'widgetType': Tkinter.Button,
            'tooltip': """ Clear entry """,
            'wcfg': {
                'text': 'Clear',
                'width': 10,
                'command': self.clear_cb
            },
            'gridcfg': {
                'sticky': 'we',
                'row': 0,
                'column': 3
            }
        })
        ifd.append({
            'name': 'remove',
            'widgetType': Tkinter.Button,
            'tooltip': """ remove the selected geom to selected """,
            'wcfg': {
                'text': '<<',
                'command': self.remove_cb
            },
            'gridcfg': {
                'row': 2,
                'column': 1,
                'rowspan': 1
            }
        })
        return ifd
Beispiel #53
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)
Beispiel #54
0
    def buildFormDescr(self, formName):
        if formName == 'readViews':
            idf = InputFormDescr(title="Read Views")
            idf.append({
                'name': 'orientfile',
                'required': 1,
                'widgetType': Pmw.EntryField,
                'tooltip':
                "Please type in the path to the _orient.py file \nor click on the BROWSE button to open a file browser",
                'wcfg': {
                    'labelpos': 'w',
                    'label_text': "Orientations Filename",
                },
                'gridcfg': {
                    'sticky': 'w'
                }
            })

            idf.append({
                'widgetType': LoadButton,
                'name': 'browseOrient',
                'wcfg': {
                    'buttonType': Tkinter.Button,
                    'title': 'Open views orientation file',
                    'types': [('Views orient', '*_orient.py')],
                    'callback': self.setOrientEntry_cb,
                    'widgetwcfg': {
                        'text': 'BROWSE'
                    }
                },
                'gridcfg': {
                    'row': -1,
                    'sticky': 'we'
                }
            })
            idf.append({
                'name': 'reprfile',
                'required': 1,
                'tooltip':
                "Please type in the path to the _repr.db file\nor click on the BROWSE button to open a file browser",
                'widgetType': Pmw.EntryField,
                'wcfg': {
                    'labelpos': 'w',
                    'label_text': "Representations Filename",
                },
                'gridcfg': {
                    'sticky': 'w'
                }
            })

            idf.append({
                'widgetType': LoadButton,
                'name': 'browseRepr',
                'wcfg': {
                    'buttonType': Tkinter.Button,
                    'title': 'Open views representation file',
                    'types': [('Views orient', '*_repr.db')],
                    'callback': self.setReprEntry_cb,
                    'widgetwcfg': {
                        'text': 'BROWSE'
                    }
                },
                'gridcfg': {
                    'row': -1,
                    'sticky': 'we'
                }
            })

            return idf