From: John Stone (johns_at_ks.uiuc.edu)
Date: Wed Aug 20 2008 - 22:59:53 CDT

Hi,
  The VMD 1.8.6 builds have a bug that prevented Python callbacks
from being triggered correctly. This has been fixed for
VMD 1.8.7. Your best bet would likely be to build
VMD 1.8.7 from source against your local Python installation,
unless you happen to be running a 64-bit Linux, in which case you
can try the test binaries I've made available already. I'm a bit
swamped presently, but I would be happy to work with you to get your
code up and running on the test build as I have time.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Wed, Aug 20, 2008 at 12:41:52PM +0100, James E. Magee wrote:
>
> 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)

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078