Personal tools
Document Actions

Add a menu to PMV

This How-to applies to: Any version.
This How-to is intended for: Developer

Step-by-step example on how-to create a PMV command
It is possible to add a menu to PMV using Tkinter commands alone, however its much cleaner and easier to use MVCommand class located in Pmv/ Here are the basic steps for that:
  1. Create file in Pmv folder.
  2. Add the following code to it:
    from ViewerFramework.VFCommand import CommandGUI
    from Pmv.mvCommand import MVCommand

    class MyCommand(MVCommand):
    "MyCommand class extends MVCommand, overwrites guiCallbak"
    def guiCallback(self):
    print "Hello World"

    MyCommand_GUI = CommandGUI()
    MyCommand_GUI.addMenuCommand('menuRoot', 'MyMenu', 'MyCommand')

    commandList = [{'name':' MyCommand','cmd': MyCommand(),'gui':MyCommand_GUI },]
    def initModule(viewer):
    "This is needed for Pmv to recognize"
    for _dict in commandList:
  3. Restart the PMV and use either File → Browse Commands or past this code in the Python shell self.browseCommands('mycommand', package='Pmv').
Read the doc string in Pmc/ for complete list of methods that MVCommand class has. See also HowTo write a PMV Command PowerPoint slides

by Sargis Dallakyan last modified 2007-06-12 17:34 Molecular Graphics Laboratory, TSRI

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: