From: John Stone (johns_at_ks.uiuc.edu)
Date: Tue Aug 31 2004 - 15:26:21 CDT

Travis,
  Here's an example from a script that uses callbacks. I hope it
is a bit more helpful to you.

class MolChange:
    def __init__ (self):

...(later in the same code)

        VMDCallback.add_callback ('initialize_structure', self.change, self)

...(later in the same code)

    def change (self, args):
        if (args [1] == 1):
            print 'you just loaded molecule number: ', args[0]
        elif (args [1] == 0):
            print 'you just deleted molecule number: ', args [0]

        self.update(args[0], args [1])
        self.root.destroy()
        self.recreate()

...(later in the same code)

    def __del__(self):
        try:
            VMDCallback.del_callback ('initialize_structure', self.change, self)
        except:
            pass

On Mon, Aug 23, 2004 at 02:56:25PM -0700, Travis DePuy wrote:
> Hi all!
>
> I am having some trouble understanding the
> python callbacks. Does anyone have a working
> example of how to register and use a callback?
> I have been over the documentation a few times
> but it doesn't make much sense.
>
> Thanks for the support
> Travis
>

-- 
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