计算化学公社

标题: pymol 插件的制作流程 [打印本页]

作者
Author:
数据挖掘    时间: 2016-7-19 18:48
标题: pymol 插件的制作流程
[size=1.2em]
pymol 插件的制作流程
step 1 定制你的插件
addmenuitem(menuName, itemType, statusHelp = '', traverseSpec = None, **kw)
Add a menu item to the menu menuName. The kind of menu item is given by itemType and may be one of command, separator, checkbutton, radiobutton or cascade (although cascade menus are better added using the addcascademenu() method).
Any keyword arguments present will be passed to the menu when creating the menu item.
See Tkinter.Menu for the valid options for each item type. In addition, a keyboard accelerator may be automatically given to the item, as described under hotkeys. When the mouse is moved over the menu item, the helpString will be displayed by the balloon's statuscommand.
def __init__(self):
    # Simply add the menu entry and callback
    self.menuBar.addmenu('DDDC','some text to comment the menu for
    coder')
    self.menuBar.addmenuitem('Wizard', 'command',
                                     'text to comment the menu',


                                     label = 'PDB Loader Service',
                                     command = lambda s=self :
                                     FetchPDB(s))






step2 定制你插件的界面
这里需要你熟悉tk的各种控件,以及布局。 这里以这个控件为例。
class FetchPDB:
    def __init__(self, app):
        import tkSimpleDialog
        import tkMessageBox
        import urllib
        import gzip

        import os
        import string

        pdbCode = tkSimpleDialog.askstring('PDB Loader Service',
                                                      'Please enter
                                                      a 4-digit pdb

                                                      code:',
                                                      parent=app.ro
                                                      ot)

        if pdbCode: # None is returned for user cancel
            pdbCode = string.upper(pdbCode)

            try:
                filename =
                urllib.urlretrieve('http://www.rcsb.org/pdb/files/'
                                              + pdbCode +
                                              '.pdb.gz')[0]
            except:

                tkMessageBox.showerror('Connection Error',
                                       'Can not access to the PDB
                                       database.\n'+
                                       'Please check your Internet
                                       access.',
                                       parent=app.root)






tkSimpleDialog 最简单的对话框,获得输入的内容
-tkSimpleDialog.askstring
当点击ok的时候就会回调上述函数。
参考





作者
Author:
pyscf    时间: 2019-5-15 06:20
tk都快老掉牙了 赶紧转pyqt去




欢迎光临 计算化学公社 (http://bbs.keinsci.com/) Powered by Discuz! X3.3