[Tutor] Multiple muti-selection dropdown options

Alan Gauld alan.gauld at yahoo.co.uk
Fri Feb 24 14:58:56 EST 2017


On 24/02/17 14:39, Pooja Bhalode wrote:

> list, and then move to the next list, I loose the selections made on the
> screen in the first list. I can however print it out and store it in the
> code, but I would like to show it on the screen as well

Peter has given you the answer: you need to specify
exportselection as False.

What he didn't explain is why... The default behaviour is
for the selections to be copied to the OS Windows selection
mechanism, so when tyou move to a new widget and select
something else the OS selection moves there and you lose
the previous selection. This interchange between the OS
selection and the Tkinter selection is the "export"
bit of exportselection. By making it false the OS no
longer grabs your selection and thus each widget
is free to keep track of its own. The downside is
you can no onger use your selection in any other
window (eg paste it into a field). But for this
example I doubt if that matters.

BTW You may want to change selectionmode to EXTENDED
Which shows the multiple selections more clearly
 - I think that will suit your needs better.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list