[Tutor] Passing arguments
Reggie Dugard
reggie@merfinllc.com
Wed Jul 2 12:36:02 2003
Edmund,
You have the right idea about passing a reference to the progressMeter
method to the Calc class instance, either in its constructor or when you
call the method that does the calculation. For example
gui = GUI(...)
c = Calc(...)
c.do_loop(..., gui.updateProgress)
and in the do_loop method:
def do_loop(self, ..., progress=None):
...
while calculate:
...
if progress:
percent_done = ...
progress(percent_done)
Hopefully this will put you on the right track.
On Wed, 2003-07-02 at 09:14, DORSEY_EDMUND_K@LILLY.COM wrote:
> I have a class called GUI which draws my GUI. I then have another
> class called Calc which does all the calculations.
>
> One of the GUI objects I'm using is a progressMeter (pmw)
>
> The progressMeter is declared in GUI and it has an update function
> called updateProgress. So you can have a loop and keep calling
> updateProgress and increment your progress.
> This works fine and dandy if I call updateProgress in the GUI class.
> The problem is I can't monitor the progress in the GUI class because
> the calculation is being done in the Calc class.
>
> Ideally, I want to called updateProgress in the loop of Calc Class.
>
> I thought for a second since python passes stuff by reference I could
> just pass a reference to the progressMeter to Calc and then do the
> update there but that doesn't work.
>
> Do I need to make the progressMeter global? I read that's not very
> elegant.
>
> How would I go about letting the Calc class update progressMeter.
> Thank you for your help.
>
> ~Ed
--
Reggie