[Tutor] Tkinter resizable menu??

Alan Gauld alan.gauld at btinternet.com
Tue Jul 8 20:56:05 CEST 2014


On 08/07/14 16:46, Albert-Jan Roskam wrote:
> I pasted the code here because it is a bit much (sorry):

Too much for me, I gave up without spotting the problem.

One thing that did strike me though was that you spend quite
a lot of code setting up scrollbars etc on your list boxes.

The Tix module has a scrollable listbox widget which is
quite easy to use and does all that stuff for you.

Simply replace

import Tkinter as tk

with

import Tix as tk

and it should just work as is.
Then replace the list box and scrollers with the
ScrolledListBox widget.

Much less work.
Tix is not very well documented but the ScrolledListBox
(and ScrolledText) are two of the better examples.


Also all that messing around with lambdas etc outside the
widget creation would actually be easier to read if you
just used the lambda inside the command=argument and
referenced the actual method. Having two levels of
redirection simply makes the reader have to search
your code to find out what it really is...

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list