Re: [Pyobjc-dev] threading and pyobjc? (Suggestions wanted)
Brought to you by:
ronaldoussoren
From: <joa...@ma...> - 2005-02-25 03:29:39
|
Joachim M=E5rtensson wrote: > Thanks, I have borrowed threading code from the original Web Services=20 > Tool. Every thing works, no blocking at all, again: Thank you! However=20 > I want to update some text that is displayed just under the toolbar,=20 > just as in the WST app. > However everytime I call the update method my app locks, and has to be=20 > force quitted. > Here is the code: > > def setStatusTextFieldMessage_(self, aMessage): > if not aMessage: > aMessage =3D "Displaying information about "=20 > +`len(self._methodList)` +" methods." > =20 > self.statusTextField.performSelectorOnMainThread_withObject_waitUntilDo= ne_(=20 > > "setStringValue:", aMessage, 0) > > def reloadVisibleData_(self, sender): > if self._working: > # don't start a new job while there's an unfinished one > return > self.setStatusTextFieldMessage_("Checking ...") # This works > self.startWorking() > url =3D self._server > self._workerThread.scheduleWork(self.getMethods, url) > self.setStatusTextFieldMessage_("Found %d methods." %=20 > len(self._OrigList)) > def getMethods(self, url): > pool =3D NSAutoreleasePool.alloc().init() > self._methodList =3D[] > self._OrigList=3D[] > self.startWorking() # Start Process indicator > filelist =3DGlobDirectoryWalker(url, "*.m") > for filename in filelist: > self.receiveMethods(filename) > ab =3D len(self._methodList) > self.setStatusTextFieldMessage_("Found %d methods." % ab)=20 > #This does not > > Again thanks a lot for all your answers so far, they have been very=20 > helpful. Replying to my own mail, sorry. I have found the problem, I forgot to=20 make the string unicode, everything now works as it should. self.statusTextField.performSelectorOnMainThread_withObject_waitUntilDone= _( "setStringValue:", unicode(aMessage), 0) Maybe someone can explain why this is needed when using threads but not=20 otherwise? Joachim M=E5rtensson |