I am new to python and trying to write a small GUI which is called
from within pymol.  I am trying an example script out of my book,
which uses a Tkinter Variable within a Label & and Entry object.
The script works perfectly on its own, but when I try to run
the script within pymol, the variable does not get set.  This has
me baffled (and frustrated), and clearly there is some
relationship which I don't understand.   Please could some
experienced pymol programmer offer me some help.

To run this script on its own I type:
python leigh.py  (and I uncomment the "mainloop" line)
From within python I run this script by typing:
run leigh.py

In the first instance (without pymol), the label & entry get set on
initialisation to "hello". From within pymol, they are blank,
and typing in the entry field does set the label, but the values are not
passed on to the Tkinter variable.  It is as though I have
created 2 separate variables, one which is used by the Label & Entry,
and one which I have initialized to "hello".

Here is my small script, thanks in advance for any help.  Leigh Willard.

from Tkinter import *

class leigh:
    def __init__(self):
        root = Tk()
        frame = Frame(root)
        frame.pack()
        self.tv = StringVar()
        self.tv.set('hello')
        Label(frame, textvariable=self.tv).pack()
        self.entry = Entry(frame, textvariable=self.tv)
        self.entry.pack()

        print "variable name = ", self.entry.cget('textvariable')
        print self.tv.get()

me = leigh()
# uncomment the next line if running without pymol.  ie. python script.py
# mainloop()


Reply via email to