[Tutor] How does this work?
cappy2112 at gmail.com
Wed Feb 7 19:44:44 CET 2007
> The application needs to be rewritten if this is true. The author's
> implementation is not logical,
regardless- I won't ask him to do this, it's just the way it is. I
don't know why it was written this way.
> if I'm inferring correctly that he knows there are other apps depending
> on this.
Yes he knows, but the gui aspect of it didn't come into play until the
app was deployed and already in use. He favors cmd line apps that can
be dasiy chained or piped together in the typical unix fashion.
> consider this:
> class Foo(object):
> def __init__(self):
> print "we're creating a new Foo and doing something useful here."
> if __name__ == "__main__":
> f = Foo()
> #we can do stuff with our Foo instance here.
I agree with this approach, and is how most of my apps begin.
> Now if we want to write a GUI for this, we just import this script, and
> use the Foo object to do whatever we were doing in the
> cmdline version -- no separate processes, threads, or any of that nastiness.
> Because it's imported, the contents of the 'if __name__...' conditional
> statement are never executed, so the cmdline functionality is disabled.
actually- after importing I call main directly and pass the cmd line
args specified by the user, through the gui
targetapp.main( [arg1, arg2]) # arg1 arg2 passed in through edit box in the gui
(this syntax may not be totally correct, just consider the concept. I
dont have my source in front of me.
> Hope that helps,
I understand your proposal, and agree with it. But I cannot change the
author's code, as he is the sole maintainer.
However, the problem now is more of an issue with the recent use of
the logging module in the target app, and not being able to capture
it's output, even though it is displayed on the screen.
Regardless of how the gui calls the target app, either by
instantiating a class or by calling main() after importing it- I am at
a loss as to how to "capture" the output on the screen which is now
put there by the logger, into put into a TextBox.
If implementing the target app as a class as you have suggested will
change this issue, then I am at a loss how it will work. I have used
the logging module at work, but in a more straightforward application,
and never had to deal with this kind of issue.
More information about the Tutor