计算化学公社

 找回密码 Forget password
 注册 Register
Views: 10838|回复 Reply: 1
打印 Print 上一主题 Last thread 下一主题 Next thread

[程序/脚本开发] pymol 插件的制作流程

[复制链接 Copy URL]

44

帖子

0

威望

2624

eV
积分
2668

Level 5 (御坂)

跳转到指定楼层 Go to specific reply
楼主
[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.
  • 插件的位置(存放在哪个menu下面)
  • itmetype( command speractor checkbutton radiobutton cascade) 这里一般选用command,支持回调函数,弹出新的窗口
  • 插件的说明(鼠标悬停显示的文字)
    测试发现 menu 上的文字有显示,menuitem上没有显示
  • 插件上面显示的文字
  • comand 触发的回调函数
    回调函数可以是普通函数,或者是类的构造函数。通过该函数创建GUI。
    类的构造函数,方便创建复杂界面。
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
  • tkSimpleDialog.askinteger
  • tkSimpleDialog.askfloat
当点击ok的时候就会回调上述函数。
参考




评分 Rate

参与人数
Participants 2
eV +12 收起 理由
Reason
sobereva + 8
greatzdk + 4 赞!

查看全部评分 View all ratings

http://pymol.chenzhaoqiang.com/index.html

161

帖子

0

威望

628

eV
积分
789

Level 4 (黑子)

蓝卫兵

2#
发表于 Post on 2019-5-15 06:20:49 | 只看该作者 Only view this author
tk都快老掉牙了 赶紧转pyqt去
B样条插值
个人专栏https://zhuanlan.zhihu.com/p/21936803

本版积分规则 Credits rule

手机版 Mobile version|北京科音自然科学研究中心 Beijing Kein Research Center for Natural Sciences|京公网安备 11010502035419号|计算化学公社 — 北京科音旗下高水平计算化学交流论坛 ( 京ICP备14038949号-1 )|网站地图

GMT+8, 2025-8-18 04:50 , Processed in 1.335052 second(s), 21 queries , Gzip On.

快速回复 返回顶部 返回列表 Return to list