[Tkinter] text widget update problem

Thomas Rademacher rademacher at prostep.FTA-berlin.de
Fri Nov 29 08:39:38 EST 2002


Hallo Martin,

> On Thu, 2002-11-28 at 10:01, Thomas Rademacher wrote:
> > Hallo,
> >
> > I want to write a text widget which can be filled step by step in
dependent
> > on program sequence:
> > ...
> > scrollbar = Scrollbar(frameMsg, orient=VERTICAL)
> > scrollbar.pack(fill=Y, side=RIGHT)
> > text = Text(frameMsg, bd=0,font='courier 8', width=960, height=450,
> > fg="black")
> > text.pack()
> > text.config(yscrollcommand=scrollbar.set)
> > scrollbar.config(command=text.yview)
> > ...
> >
> > The input of the text widget I create in a singleton logger class:
> > ...
> > Logging.__msgHandle.insert(END, logString)
> > Logging.__msgHandle.update()  <--
> > ...
> >
> > I want to see the the output step by step during program sequence. But I
> > have following problems:
> > 1. With Logging.__msgHandle.update() I get a program crash when all
lines in
> > the widget filled. The widget does not show the following messages.
> > 2. Without  Logging.__msgHandle.update() I get the my program output at
the
> > end of the program and not step by step.
> >
> > How can I resolve the problem? Who has any ideas? It is a singleton
class
> > problem?
> > Thank's for your hints, Thomas
> >
> >
>
> Are you calling update() from the main thread (you don't mention threads
> but I am guessing you are using them)  Could you post a cut down version
> that demonstrates the problem?  I have had problems with calling
> update() from another thread.....
>

Yes!!! I use threads:

for ii in range(maxSession):
    log.log(__name__, 0, "enter", "beforeThreads"); <-- logging in text
widget WITHOUT problems

    myS = session.Session(dxmDbServer, ii+1, maxDs, lang, cpu, usr, pwd,
authmode, clienttype)
    thread.start_new_thread(threadSession,(myS,))

def threadSession(actSession):
     global log
     log.log(__name__, 0, "enter", "threadSession") <- logging in text
widget WITH problems
     log.log(__name__, 0, "input", actSession)
     actSession.testSession()
     log.log(__name__, 0, "leave", "threadSession")

Have you an idea how can I resolve this problem?
Thank's Thomas!






More information about the Python-list mailing list