CLI+GUI

Michele Simionato mis6 at pitt.edu
Fri Aug 8 19:48:31 CEST 2003


I wonder what is the recommended way of using Tkinter
together with a command line oriented application. 
I have in mind something like that:

import cmd,sys

class CMD(cmd.Cmd):
    def do_this(self,*args):
        draw_a_diagram()
    def do_that(self,*args):
        draw_another_diagram()
    def do_exit(self,*args):
        sys.exit(0)

c=CMD()
c.cmdloop()

Here the methods ``draw_a_diagram`` and ``draw_another_diagram``
should do what you expect.  Notice that I don't want to use
different windows, the graphs should be displayed on the same
window one over the other. BTW, I am not really displaying
diagrams, this is only the simplest example I can figure out
of graphics program driven by a command line interpreter.
I want to stay with the CLI interface, which I like a lot 
thanks to the readline and completion support, the easy
of use and the easy of implementation.

I have no idea of how to do that, except via contorsions
such as saving (a representation of) the diagrams in a file 
and having a separated Tkinter process that periodically look at the
file, changing the display if the file has been updated. I
guess there is a better way, since this is a quite common issue.
Any suggestion?

TIA,

                 Michele




More information about the Python-list mailing list