From: James E. Magee (j.magee_at_manchester.ac.uk)
Date: Wed Aug 20 2008 - 06:41:52 CDT

Hi,

I'm having some trouble getting the 'initialize_structure' callback
working in Python (please see test code below). VMD does not seem to
call the callback when molecules are created (loaded in) or deleted.
Does anyone have any suggestions?

On a side note, is it possible to make VMD automatically load in Python
plugins placed in (for eg)
{installdir}/plugins/noarch/python/pluginname/ ? Comments in
scripts/vmd/loadplugins.tcl suggest that this has been "turned off", is
there a way to safely turn it back on?

Cheers,

James Magee
http://personalpages.manchester.ac.uk/staff/j.magee/

Code follows:

from Tkinter import *
from VMD import *

# Kludged together from other test code...
class MyPlugin:
   def __init__(self):
     self.root = Tk()
     self.root.title("My Plugin Window")
     self.root.grid()
     vmdcallbacks.add_callback ('initialize_structure', self.change)

   def change (molid, adddel):
     print ('called!')
     if (adddel == 1):
       print ('you just loaded molecule number: ' + str(molid))
     elif (adddel == 0):
       print ('you just deleted molecule number: ' + str(molid))

def startMyPlugin():
   return MyPlugin().root

import VMD
VMD.registerExtensionMenu("myplugin", startMyPlugin)