From: Kevin A. <al...@se...> - 2004-04-27 18:09:55
|
> From: Uwe Schmitt > > Hi, > > I wrote a litte GUI for steering some numerical calculations. > PythonCard works fine, but I got one problem: How can I refresh > the GUI inside an event triggered method ? I have: > > def on_startbutton_mouseDown(self, event): > > self.components.calcinfo.text="calculation started" > self.doCalc1() # needs some seconds > self.components.calcinfo.text="calculation finished" > > self.components.calcinfo is a TextField component. > > If I start this application, the first message does not appear > before the calculation is started... > > Any hints ? > > Greetings, Uwe Let's open up the widgets sample with the shell (widgets.py -s) and experiment... >>> fld = comp.fldTextField >>> import time >>> fld.text = 'hello world';time.sleep(3) >>> fld.text = 'update me now';fld.Update();time.sleep(3) >>> fld.text = 'with refresh';fld.Refresh();fld.Update();time.sleep(3) >>> s = comp.txtStaticText >>> s.text = 'hello world';time.sleep(3) Calling Refresh and Update is safest because it forces the whole control to be redrawn. The StaticText component actually contains an explicit Refresh() call as part of its _setText method but I'm considering removing that. The original idea was that StaticText is more likely to be used for the kind of status messages you are doing above, so it would be nice to have it automatically do the right thing. Of course, it really needs to call Update as well for it to always work on all platforms, so I'll add that until a decision is made on whether to drop automatic Refresh/Update in the future. As an alternative you can use a statusBar. It should already do the right thing as far as immediate updates are concerned. BTW, do you have a whitelist-based mail block in place on your system? I can't send you email directly without a bounce, so everyone who replies to your emails on this list end up with a bounced message which is very annoying. Here's a sample... <sc...@nu...>: 134.96.7.8 does not like recipient. Remote host said: 550 5.0.0 <sc...@nu...>... Spam address. Giving up on 134.96.7.8. ka |