Return Values & lambda

P

pradeepbpin

I have a main program module that invokes an input dialog box via a
menu item. Now, the code for drawing and processing the input of
dialog box is in another module, say 'dialogs.py'. I connect the menu
item to this dialog box by a statement like,

manu_item.connect('activate', lambda a: dialogs.open_dilaog())

If this function open_dialog() returns a list of dialog inputs values,
how can I access those values in the main module ?
 
B

Benjamin Kaplan

I have a main program module that invokes an input dialog box via  a
menu item. Now, the code for drawing and processing the input of
dialog box is in another module, say 'dialogs.py'. I connect the menu
item to this dialog box by a statement like,

manu_item.connect('activate', lambda a: dialogs.open_dilaog())

If this function open_dialog() returns a list of dialog inputs values,
how can I access those values in the main module ?

You can't. The event handler just calls a method. It's expected that
you'll do everything you need in that. Make your own method for the
menu item that starts off by creating the dialog and then handles the
results.
 
R

Rafe Kettler

I have a main program module that invokes an input dialog box via  a
menu item. Now, the code for drawing and processing the input of
dialog box is in another module, say 'dialogs.py'. I connect the menu
item to this dialog box by a statement like,

manu_item.connect('activate', lambda a: dialogs.open_dilaog())

If this function open_dialog() returns a list of dialog inputs values,
how can I access those values in the main module ?

Moreover, I don't see why you need a lambda in this case. Why not just
pass the function itself?

Rafe
 
S

Steven D'Aprano

Moreover, I don't see why you need a lambda in this case. Why not just
pass the function itself?

My guess is that the callback function is passed a single argument, and
open_dialog doesn't take any arguments, hence the wrapper which just
ignores the argument and calls the function.
 
R

Rafe Kettler

My guess is that the callback function is passed a single argument, and
open_dialog doesn't take any arguments, hence the wrapper which just
ignores the argument and calls the function.

That would sound reasonable.

Rafe
 
P

pradeepbpin

My guess is that the callback function is passed a single argument, and
open_dialog doesn't take any arguments, hence the wrapper which just
ignores the argument and calls the function.


Thanks to all.

Pradeep
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top