[Tutor] Text to GUI with Tkinter

Bruce Sass bsass@freenet.edmonton.ab.ca
Wed, 27 Jun 2001 15:12:13 -0600 (MDT)


On Wed, 27 Jun 2001, Mark Tobin wrote:
> On 28 Jun 2001, at 0:18, Roman Suzi wrote:
> > On Wed, 27 Jun 2001, Mark Tobin wrote:
> >
> > >Does anybody have any general suggestions for taking a
> > >(somewhat) complete text based program and translating it to a
> > >Tkinter GUI?  Is there a procedure or process that makes this a
> > >simpler task then it appears on the surface?  What steps have you
> > >taken to do this?  Should I have been planning to GUIfy the
> > >program from the beginning, and now I'm essentially going to have
> > >to rewrite the program?  I'm just looking for some broad ideas.
> >
> > The answer depends on what the program does and how fat is it's
> > connection to user: how much controls it has.
>
> Hmmm.. I see what you're saying... in my particular app the
> interface simply controls the execution of some functions and
> displays results (pretty simple), but I'm really asking from a larger
> design perspective...
<...>
> > The wise solution is to separate program logic from GUI.  This way you
> > could change both with less trouble later.
>
> That's sort of what Archimedes suggested and in retrospect makes
> a fair bit of sense, but I wish I knew that when I started... oh well..
> next time ;-)

You also need to decide if you want prg-gui and prg-tui, or just prg.

Archimedes seemed to be heading towards the former, where the UI is
the main thing and the user runs different programs depending on which
UI (s)he wants.

Having a single program that can spit out to either a text UI or a
graphics UI may be the way to go though, depending on the
circumstances.  Using this design paradigm you end up with a core, a
generic UI layer, and modules for the actual GUI and TUI code.  It is
a little trickier to code, but can be very flexible.  e.g. (and not
saying that this is actually how it is coded), I can start xemacs in a
GUI environment then login to a text console and do

	gnuclient somefile

which starts up a text interface to the same instance of xemacs that
is displaying to a window on the GUI.

> > Why do you need GUI?
>
> I don't really, I just want to figure this stuff out...

A much better reason than, `the boss is making me...'.  :)


- Bruce