Python modules which implement a Tk-based GUI are registered in the VMD "Extensions" menu by calling VMD.registerExtensionMenu("MyPluginTitle", startMyPlugin)
The example below is an extremely minmalistic Python script that creates a window when triggered by an appropriate selection in the VMD "Extensions" menu.
from Tkinter import *
# A minimal plugin class that just creates an empty window
class MyPlugin:
def __init__(self):
self.root = Tk()
self.root.title("My Plugin Window")
# Function to start the plugin. Must return the window handle.
def startMyPlugin():
return MyPlugin().root
if __name__=="__main__":
import VMD
# Register the plugin so that it's not actually created until the
# first request to open the window.
VMD.registerExtensionMenu("myplugin", startMyPlugin)
# Create the plugin now and add it to the Extensions menu.
# VMD.addExtensionMenu("myplugin", MyPlugin().root)
1.2.14 written by Dimitri van Heesch,
© 1997-2002