Return Values & lambda

Discussion in 'Python' started by pradeepbpin, Feb 21, 2011.

  1. pradeepbpin

    pradeepbpin Guest

    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 ?
    pradeepbpin, Feb 21, 2011
    #1
    1. Advertising

  2. On Mon, Feb 21, 2011 at 1:59 PM, pradeepbpin <> wrote:
    > 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.

    > --
    > http://mail.python.org/mailman/listinfo/python-list
    >
    Benjamin Kaplan, Feb 21, 2011
    #2
    1. Advertising

  3. pradeepbpin

    Rafe Kettler Guest

    On Feb 21, 1:59 pm, pradeepbpin <> wrote:
    > 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
    Rafe Kettler, Feb 22, 2011
    #3
  4. On Mon, 21 Feb 2011 16:43:49 -0800, Rafe Kettler wrote:

    > On Feb 21, 1:59 pm, pradeepbpin <> wrote:
    >> 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?


    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.



    --
    Steven
    Steven D'Aprano, Feb 22, 2011
    #4
  5. pradeepbpin

    Rafe Kettler Guest

    On Feb 21, 7:59 pm, Steven D'Aprano <steve
    > wrote:
    > On Mon, 21 Feb 2011 16:43:49 -0800, Rafe Kettler wrote:
    > > On Feb 21, 1:59 pm, pradeepbpin <> wrote:
    > >> 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?

    >
    > 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.
    >
    > --
    > Steven


    That would sound reasonable.

    Rafe
    Rafe Kettler, Feb 22, 2011
    #5
  6. pradeepbpin

    pradeepbpin Guest

    On Feb 22, 5:59 am, Steven D'Aprano <steve
    > wrote:
    > On Mon, 21 Feb 2011 16:43:49 -0800, Rafe Kettler wrote:
    > > On Feb 21, 1:59 pm, pradeepbpin <> wrote:
    > >> 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?

    >
    > 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.
    >
    > --
    > Steven



    Thanks to all.

    Pradeep
    pradeepbpin, Feb 22, 2011
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roman Suzi
    Replies:
    13
    Views:
    588
    Bengt Richter
    Jan 7, 2005
  2. Greenhorn
    Replies:
    15
    Views:
    796
    Keith Thompson
    Mar 6, 2005
  3. cnb
    Replies:
    1
    Views:
    701
    George Sakkis
    Aug 29, 2008
  4. Steve Dogers

    lambda vs non-lambda proc

    Steve Dogers, Mar 30, 2009, in forum: Ruby
    Replies:
    1
    Views:
    156
    Sean O'Halpin
    Mar 30, 2009
  5. Haochen Xie
    Replies:
    4
    Views:
    232
    Haochen Xie
    Mar 17, 2013
Loading...

Share This Page