[Tutor] Text to GUI with Tkinter

Archimedes gibbs05@flash.net
Wed, 27 Jun 2001 14:54:38 -0500


Greetings Mark, Steve, and anyone interested,

On Thursday 28 June 2001 00:12, you wrote:
> Hi every,
>  This is *NOT* a reply to the question..
>
> > 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.
> >
> > Thanks,
> > Mark
>

I'll give this issue a shot, but I have to keep it short.

Multiple user interfaces isn't a python issue as much as a design issue.
You'd have the same concerns if you were programming in Java, C++, Ada,
Perl, etc.

What you'll want to do is separate the core functionality of your program
and its user interface(s) into separate modules.  You may know you need a
character based user interface today, but tomorrow you may need a web
interface or a GUI.  You also gain the advantage of being able to test the
different pieces of your program separately.


Here's how I'd proceed with this in Python.

Step 1:
   Remove the core functionality of your program into it's own module.

Step 2:
   Create tests for every important feature of your core module using
unittest.py.  There's debate whether its better to place these tests within
the core module itself or in yet another module specifically created for
doing the tests.  Do what seems best.  Once you're experienced with this
sort of thing consider doing step 2 before step 1.

Step 3:
   Run the tests. Debug. Test. Debug...

Step 4:
   Create your text based interface module.  Import your core module and use
it just as you would any other Python module.  Test it.  Writing interfaces
is much easier when you already know the core module works.

Step 5:
   Create another module for your Tkinter interface.  Import your tried and
true core module. Test it.  It really doesn't matter what order you do steps
4 and 5 :-)


Hmmm.  Actually I think I did something similar to this for a dice roller I
submitted to Useless Python back when I was first learning Tkinter.


Hope this helps some,
Sam

>  Anybody who does reply to the above query, cud really help me out too.
> Sometime back I meant to ask something of the similar nature but peterning
> to a curses based UI, [Subject was given as 'Curses Programming']. The
> problem tho' was I'm not too good at communicating stuff, so...N E ways, I
> too am looking for 'broad' ideas, stuff like how does one approach the
> design of a (G)UI based application, do I code all the working of the app
> first an' then plug the UI in, or do I design the app. alongwith the UI.
>
> BTW ...I'd like to thank sill (that u r name??) and Arcege (I downloaded
> Pyirc...tho' cudn't get it functioning...and t'was a "bit" complex to
> understand....but that was just the first skim-thru' ...didn't get 'nuff
> time..) for replying.
>
> Peace
> Steve
>
> -------------------------
>
> |||||||||#####||||||||
> ||||||||
> ||||||||#######|||||||
> ||||||||# O O #|||||||
> ||||||||#\ ~ /#|||||||
> ||||||
> ||||||##||\_/||##|||||
> |||||
> |||||#||||||||||##||||
> ||||
> ||||#||||||||||||##|||
> ||||#|||||||||||||##||
> |||
> |||/\##|||||||||##/\||
> |
> |/    \#########/    \
> |\     \#######/     /
> |
> ||\____/#######\____/|
>
> =====================================
> Hello.  Just walk along and try NOT to think about your INTESTINES
> being almost FORTY YARDS LONG!!
> ====================================

--
||||||||||||||||||||||
|||||||||#####||||||||
||||||||#######|||||||
||||||||# O O #|||||||
||||||||#\ ~ /#|||||||
||||||##||\_/||##|||||
|||||#||||||||||##||||
||||#||||||||||||##|||
||||#|||||||||||||##||
|||/\##|||||||||##/\||
|/    \#########/    \
|\     \#######/     /
||\____/#######\____/|
=====================================
Hello.  Just walk along and try NOT to think about your INTESTINES
being almost FORTY YARDS LONG!!
====================================

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor