[Tutor] looking for alternatives to tabular widget (Tkinter)

Abel Daniel abli@freemail.hu
Tue Apr 8 11:16:20 2003

Adrian Maier wrote:

> I really need a program for managing all the cdroms i have
> (data cdroms). Since I haven't found anything suitable for me 
> that runs on Linux,
Not even gtktalog? (http://www.nongnu.org/gtktalog/)
Looks pretty neat. (Haven't used it, though.)

> - using a ListBox for the read-only fields (i could concatenate
>   them, or i could use only DIR_NAME). Let's say that 15
>   records will be visible at one time.
> - creating 15 pairs of Entry widgets 
> - the user jumps from one recod to another using the Listbox,
>   and the program will sinchronize the Entry fields so that
>   they will allways contain the values that
>   correspond to the directories visible in the Listbox.
> - the data is stored into a list of dictionaries (done already)
> /----------\
> |  dir1    |  ( category1  )    ( description1  ) 
> |  dir2    |  ( category2  )    ( description2  ) 
> |  dir3    |  ( category3  )    ( description3  ) 
>  ......          ....                 ....         
> |          |  ( category14 )    ( description14 )
> |  dir15   |  ( category15 )    ( description15 )
> \----------/
> Does this sound feasible?  Is there perhaps a better approach?

Tkinter itself doesn't have a table widget you need, but others already
needed such thing, so you might try re-using thier solution. For example
looks pretty neat. (I never used it.)
(Another one would be to use Pmw, it has a table-like widget in the
contrib directory, altough you might need to modify it to allow editing
the data)

Of course, you only need a limited set of features (for example the
number of columns is fixed), so writing your own should be pretty

One thing I would do differently:
You mention using Listboxes for navigation. However, a part of the data
would be outside of the listbox. This would mean that by scrolling the
listbox, you would break the rows, as a part of the row would be
scrolled and the rest wouldn't. Of course this wont be a problem if you
hardcode the size of the listbox and make the window big enough so that
everything is visible, and the scrollbar can't be scrolled simply
because it doesn't have enough lines to need it.

But in this case, why are you using a listbox at all? You aren't using
any features of a listbox, you could simple create 15 Labels under
eachother to reach the same effect.

An other idea would be to use ScrolledFrame from the Pmw widgets.
With that you could create Labels or Entrys as needed for each piece of
data, put them into the the ScrolledFrame which would take care of
scrolling it. I think this is the way the widget in Pmw's contrib dir

Abel Daniel