当前位置: 首页>>代码示例>>Python>>正文


Python InputFormDescr.insert方法代码示例

本文整理汇总了Python中mglutil.gui.InputForm.Tk.gui.InputFormDescr.insert方法的典型用法代码示例。如果您正苦于以下问题:Python InputFormDescr.insert方法的具体用法?Python InputFormDescr.insert怎么用?Python InputFormDescr.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mglutil.gui.InputForm.Tk.gui.InputFormDescr的用法示例。


在下文中一共展示了InputFormDescr.insert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MoleculeChooser

# 需要导入模块: from mglutil.gui.InputForm.Tk.gui import InputFormDescr [as 别名]
# 或者: from mglutil.gui.InputForm.Tk.gui.InputFormDescr import insert [as 别名]
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]
#.........这里部分代码省略.........
开发者ID:jackygrahamez,项目名称:DrugDiscovery-Home,代码行数:103,代码来源:guiTools.py


注:本文中的mglutil.gui.InputForm.Tk.gui.InputFormDescr.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。