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/mvCommands.py. Here are the basic steps for that:
- Create mycommand.py file in Pmv folder.
- 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 myCommands.py"
for _dict in commandList:
viewer.addCommand(_dict['cmd'],_dict['name'],_dict['gui']) - Restart the PMV and use either
File → Browse Commandsor past this code in the Python shellself.browseCommands('mycommand', package='Pmv').
