[Tutor] Running Python GUI on Windows and Linux...problems encountered in Windows.
Ajaya Babu
ajaya@ncoretech.com
Fri, 7 Sep 2001 14:47:24 +0530
Hi Wheelege,
Thanks allot for your help, Yes! what exactly you told is the problem.
Perhaps...it is not because of the call the the object wich is alredy used
in GUI...(may cause problems...yet to test
throughly)..self.handset.GetEventQ()
But for the movement the print state ment associated with this...
> <...>
>
class VirtualHandSetProcessor:
def __init__(self):
self.handset = VirtualHandSet()
# self.Pipe = TcpIpPipe()
thread.start_new_thread(self.WorkerThread, ())
def WorkerThread(self):
while(1):
------> #print 'Hello'
------> #print self.handset.GetEventQ()
sleep(1)
I've tested by commenting this prints and calling
a = self.handset.GetEventQ() in the while(1) loop..., now this is working
fine..,
but as you said there may be problems that I will face later...
One more two requests I've...,
First thing is I am a C++ programmer...can you suggest some good site or
meterial...which gives
good information about the python oriented design...,
Second one is in the above code I want to disable the maximizing option....,
For that I was jut thinking using protocol to register my class methods
...for WM_ messages...but I've very few documents available on it...could
you please suggest some reference to document..
Thanks allot for your great help
with regards,
Ajaya
-----Original Message-----
From: wheelege [mailto:wheelege@tsn.cc]
Sent: Friday, September 07, 2001 2:11 PM
To: Ajaya Babu; PythonTutorlist (E-mail)
Subject: Re: [Tutor] Running Python GUI on Windows and Linux...problems
encountered in Windows.
Hi,
I had similar problems with a tkinter game I developed for the place I
work for (pong+arkanoid, networked scores, network multiplayer...etc) and I
had hell with this exact error.
The way to fix it is to do >zero< GUI calls in any thread other than the
main one. This is a little trickier than it sounds, but very possible.
> <...>
>
>
> class VirtualHandSetProcessor:
> def __init__(self):
> self.handset = VirtualHandSet()
> # self.Pipe = TcpIpPipe()
> thread.start_new_thread(self.WorkerThread, ())
>
> def WorkerThread(self):
> while(1):
> print 'Hello'
> print self.handset.GetEventQ()
> sleep(1)
I didn't use this exact architecture but I think here is where your
problem may lie.
You have the same instance of a class with two threads - one which is
heavy GUI and one which looks like it has only processing. However, with
the line 'print self.handset.GetEventQ()' you are accessing a function from
an object which is in use by the other main GUI thread, for GUI type calls.
This is what I think you need to fix.
Perhaps use a dummy object with some attributes (no GUI stuff) and get the
while 1 loop to check it's attributes for changes instead of polling the
handset object (of the VirtualHandSet class). This would mean that whenever
an event occured you would have to append it to the dummy object instead of
itself, but this should be only a minor code change.
I'll just append this discaimer here - I did not use this exact object
structure so I may well be wrong :)
>
>
>
> if __name__ == '__main__':
> print "Hello"
> a = VirtualHandSetProcessor()
> print "Hello"
>