Grid (possible scrollable) in Tkinter?
Greg McFarlane
gregm at iname.com
Tue Aug 31 21:37:12 EDT 1999
On 30 Aug, Def P wrote:
> ... Tkinter does not have a
> scrollable listbox. To make one isn't that hard...
You are correct in saying that it is easy to write a simply scrollable
listbox (see below *).
To this you may like to add things like a horizontal scrollbar (as
well as the vertical); dynamic display (only display the scrollbars
when necessary); convenient methods to populate the listbox; an
optional label; a margin between the scrollbar and the listbox; single
and double click callbacks; easy and consistent configurability of all
component options, etc. You may then want to use all this as part of
a dropdown listbox (combobox). If you want these features, it may
save you some pain to reuse an existing library, such as Pmw.
> ...Is building these things worthwile or shouldn't I bother
> and look into libraries like Pmw? For me, the ideal situation would be if I
> could distribute my programs without requiring external libraries.
If you are worried about having a dependency on Pmw, it is easy to
concatenate all of the Pmw modules you require into a single file and
include this with your software distribution. A script to do this can
be found in bin/bundlepmw.py in the Pmw distribution at
<http://www.dscpl.com.au/pmw/>.
* Simple example of scrollable listbox:
l = Tkinter.Listbox()
l.pack(side = 'left', fill = 'both', expand = 1)
sb = Tkinter.Scrollbar(command = l.yview)
sb.pack(side = 'left', fill = 'y')
l.configure(yscrollcommand = sb.set)
--
Greg McFarlane: INMS Telstra Australia (gregm at iname.com)
Today's forecast: Sunny, with occasional cloudy periods and a chance
of precipitation in some areas.
More information about the Python-list
mailing list