Guification of console app
metiu.uitem at gmail.com
Fri Nov 25 10:05:28 CET 2005
Yes, I'll try to give you an example:
you have a compression utility that works as a standard *nix filter, so
it takes something from stdin and gives it back compressed to stdout
you like to use it as such, because it's nice to call it from the
now someone finds your utility quite nice, and says it would be nice to
have a GUI that shows you, for example, how long it will take to
one way for sure it would be to fork your app, but this would be a
waste of time
you'd like to reuse the compression library you've already written for
your GUI and your console, but:
- you'd like to have your console app clean and simple, such as:
data = sys.stdin.read()
cdata = CompressLib.compress(data)
but you'd like the GUI to show some progress and status info.
I guess the way is still to make the compress call split in microsteps
and have the app call it, so you can use an EVT_IDLE call from the GUI,
but maybe there's a better way...
Peter Hansen ha scritto:
> metiu wrote:
> > Say I have a console app that does something in three steps:
> > - opens a file
> > - transfers the file through a serial port
> > - does some elaborations
> > and I want to build a GUI around it that, for example, sets the file
> > name to open or starts the different steps.
> > I started using wxPython (actually boa-constructor) to build a frame
> > with everything I want.
> > The problem is: when the console app method is working, the GUI is
> > locked...
> > How can the console app communicate with the GUI in order to make it
> > tick (think of status messages, progress bars, log messages...)?
> > If I use threads and events, or wxYield, or EVT_IDLE, I'm tweaking the
> > console app so that it won't work just in console anymore.
> Could you please explain what makes this a "console" app, specifically?
> You are proposing wrapping a GUI around it, which would make it not a
> console app (by definition), so it would help if you specified exactly
> what elements (which functions, etc.) cause you to label it a "console"
> app. (For example, maybe it calls msvcrt.kbhit/getch or something...)
> The reason for asking is that the specifics of your answer will make it
> easier to describe how to modify this "console" so that the relevant
> parts work equally well as a _real_ console app (no GUI) or with the
> GUI. We could describe it in more general terms, but it might not be
> apparent how to adapt that to your own case.
More information about the Python-list