_tkinter.TclError: can't set "PY_VAR0": invalid command name "-1210125972check"

Discussion in 'Python' started by Gregor Horvath, Mar 2, 2006.

  1. Hi,

    I searched the web and docs but cannot figure out whats wrong with this
    code:

    #!/usr/bin/python

    import Tkinter as Tk

    class testtk(Tk.Frame):

    def __init__(self):
    self.root = Tk.Tk()
    Tk.Frame.__init__(self,self.root)
    self.frame = Tk.Frame(self.root)
    self.var = Tk.StringVar()
    self.var.trace_variable('w',self.check)
    Tk.Entry(self.frame, textvariable = self.var).pack()
    self.frame.pack()
    Tk.mainloop()

    def check():
    pass

    if __name__ == "__main__":
    t = testtk()
    t.var.set("TEST")

    Result:

    Traceback (most recent call last):
    File "<stdin>", line 22, in ?
    File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 191, in set
    return self._tk.globalsetvar(self._name, value)
    _tkinter.TclError: can't set "PY_VAR0": invalid command name
    "-1210125972check"


    Any ideas, why I cant set the variable var?

    --
    Greg
    Gregor Horvath, Mar 2, 2006
    #1
    1. Advertising

  2. Re: _tkinter.TclError: can't set "PY_VAR0": invalid command name"-1210125972check"

    Gregor Horvath schrieb:

    > if __name__ == "__main__":
    > t = testtk()
    > t.var.set("TEST")
    >
    > Result:
    >
    > _tkinter.TclError: can't set "PY_VAR0": invalid command name
    > "-1210125972check"
    >
    >
    > Any ideas, why I cant set the variable var?


    Ok. The problem is that the program enters the mainloop on t = testtk()
    and t.var.set("TEST") is executed when the program ends.

    But, what I want to do is to let another program create my tkinter GUI
    via initiating my class through COM. Then the COM-Client should be able
    to set values of the tkinter variables from "the outside".

    How to do this?

    Do I have to make my GUI program threaded ? like described here:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965

    The mainloop resides in one thread and the other thread provides the COM
    object and queues the foreign COM method calls to the GUI thread?

    Is there a simpler solution?

    --
    Greg
    Gregor Horvath, Mar 2, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Berthold =?iso-8859-15?q?H=F6llmann?=

    compiling _tkinter.so (2.3) on SunOS 5.8

    Berthold =?iso-8859-15?q?H=F6llmann?=, Aug 26, 2003, in forum: Python
    Replies:
    0
    Views:
    340
    Berthold =?iso-8859-15?q?H=F6llmann?=
    Aug 26, 2003
  2. Sebastian Stelzer
    Replies:
    3
    Views:
    9,962
  3. defn noob
    Replies:
    2
    Views:
    754
    Eric Brunel
    Jun 30, 2008
  4. Terry Reedy

    Re: how to solve this tclerror?

    Terry Reedy, Jul 2, 2012, in forum: Python
    Replies:
    0
    Views:
    204
    Terry Reedy
    Jul 2, 2012
  5. Michael Matveev
    Replies:
    4
    Views:
    185
    Jason Swails
    Dec 30, 2013
Loading...

Share This Page