[Tutor] returning from 2 functions at once
Ed Connell
edwinconnell at gmail.com
Sun Oct 10 15:14:55 EDT 2021
Hi again.
You hit the nail square on the head. It is the event-driven mode that has
me flustered. I have consulted many examples and they ALL have one thing
in common. No matter the triggering event (change in selection,
double-clicking, or responding to a button-click) they ALL print the choice
from within the call-back function. I have made choice
a global variable, but this seems mickey-mouse to me. The choice is ALWAYS
identified within the call-back function.
Probably there is an easy way to communicate the choice to the rest of the
program, but it escapes me.
What I want is to be able to pass, from a program section, a candidate list
(counties to visit, files to open, teams to watch) to the function and have
it tell (return) my choice.
If this is not something you want to mess with, please tell me the
help-list to annoy.
Thanks,
Ed
On Sat, Oct 9, 2021 at 12:51 PM Alan Gauld <learn2program at gmail.com> wrote:
> CCing to tutor.
>
> Please use replyAll when respo ding to tutor list mails.
>
>
> On 09/10/2021 15:13, Ed Connell wrote:
> >
> > Actually I am trying to learn to work with tkinter but I don't think
> > y'all do tkinter. Is there a list for that?
> >
> There is a dedicated tkinter list but since its part of the standard
> library we cover the basics here too.
>
> If its complicated stuff the tkinter list is better.
>
>
> > def pickFromList(( thelist ):
> > stuff...
> > return choice
> >
> > I can do that easily in Python, but I want to use the ttk.Listbox( ...
> >
> I can't find any reference to a ttk.Listbox widget. There is however a
> tkinter Listbox
> so I'll assume you mean ghat.
>
> As I'm sure you know tkinter is event driven so a function like the
> above only makes
> sense when we know which events you are attaching it to? For example the
> tkinter.Listbox
> widget often has the mouse button actions bound to events and these
> often call the curselection()
> method to get the list of currently selected items (or their indices at
> least.)
>
> But you need to explain with a bit more detail what exactly you are
> trying to do.
> Its not obvious.
>
> > --
>
> 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
>
>
--
I have a right and a left brain, but there is nothing right in the left one
and there is nothing left in the right one!
More information about the Tutor
mailing list