Format for Python/Tkinter program

Russell E. Owen no at spam.invalid
Sat Mar 22 00:59:06 CET 2003

I didn't read every word but basically it looks good to me.

I like the fact that you aren't doing "from Tkinter import *" and that 
you are using SimpleCallback (aka currying functions) instead of using 

Regarding packaging: I tend to have a separate module or package for 
each widget, unless the widget is really simple. If a window or widget 
is sufficiently complex, I create a separate file for each major 
component, so I can easily test and work on each component separately. 
For instance in a recent control interface for a complicated instrument 
named DIS I created:
DIS (folder)  contains "from DISWdg import *"  the main widget that uses the other files in this package a set of Tk variable-like things that contains current info 
about DIS the main set of input controls for setting the 
configuration of DIS combines and the main command buttons a panel showing the status

I also make each widget into a subclass of Frame (or some other obvious 
Tkinter class), so I can directly grid or pack it. For instance:
import TkInter
class MyWdg(Tkinter.Frame):
  def __init__(self, master, myWdg inputs, **kargs):
    Tkinter.Frame.__init__(self, master, **kargs) my own initialization

(another file):
import Tkinter
import MyWdg
root = Tk()
aWdg = MyWdg.MyWdg(root)
# or get fancier and pack or grid several widgets together...

I hope you find PMW reliable. When I tried it on a Mac a year or two ago 
I found some bugs and gave up on it. A pity, because it does a lot of 
nice things.

In article <8761b8c9.0303211200.66811084 at>,
 vicki at (Vandl) wrote:

>I am new to Python/Tkinter, having programmed quite a bit in C/Motif.
>I am trying to get a feel for the appropriate format for my new

More information about the Python-list mailing list