Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > _tkinter.TclError: can't set "PY_VAR0": invalid command name "-1210125972check"

Reply
Thread Tools

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

 
 
Gregor Horvath
Guest
Posts: n/a
 
      03-02-2006
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
 
Reply With Quote
 
 
 
 
Gregor Horvath
Guest
Posts: n/a
 
      03-02-2006
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/Coo...n/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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run as command - "The directory Name is Invalid" Blackbird MCSA 1 04-09-2007 03:18 PM
Invalid URI: There is an invalid sequence in the string. Error!! Patrick.O.Ige ASP .Net 1 07-02-2006 11:21 AM
Invalid 'name' attribute name =?Utf-8?B?QW5kZXJzIEphbnNzb24=?= ASP .Net 3 02-14-2006 06:05 PM
Error in asp text: Command text not set for the command Jack ASP General 2 03-07-2005 11:27 PM
Tkinter / Threads: "Invalid command name" Michael Schutte Python 2 12-19-2003 09:12 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57