Tkinter / Threads: "Invalid command name"

Michael Schutte m.schutte at
Thu Dec 18 18:53:38 CET 2003

I know, questions about Tkinter and threads have been answered very
often, but I want to ask anyway.
I am using Python 2.2 on a Linux (SuSE Linux 8.1) system.
I want to write a server application; like telnet is a client. The user
should be able to bind() to a port and wait for a client. The written
and recieved data is stored in a Text widget, self.__text. The
accept()ing is done in a seperate thread (using the threading module),
in method self.__tryConnect().
But the seperate thread raises an exception at
	self.__text["state"]="normal" .
A part of the code:

def go(self, portn):
	# Open the window and connect.

	# Bind self.__server to ("", portn), call listen(), ...

	# When everything's ok, start the accept()ing thread.

def __tryConnect(self):
	# Accept a connection
	self.__text["state"]="normal"    # Here the exception is raised		
	self.__text.insert("end", "Waiting for connection... ")
	try: self.__client, addr=self.__server.accept()
	except: success=0
	if not success:
		self.__text.insert("end", "failed.\n")
		self.__text.insert("end", "ok, connected with %s.\n" % 					addr[0])

But when I join() the thread, everything works as it should. Eventually
the self.__text reference is lost when __tryConnect() returns?
The exception is:

Exception in thread Thread-1:
Traceback (most recent call last):
	File "...", line xx, in configure:, configure)
TclError: invalid command name ".123123123.12341234" ,

while ".123123123.12341234" is the text widgets identification.
Can anyone help me?

Michael Schutte <m.schutte at>

More information about the Python-list mailing list