Can't pass parameters to function from WxPython Menu Item
Question: I'm having trouble getting sensible output when I try to bind menu buttons to
a function. First, I pass a few items to create a menu in my application:

    
    
    imported_applications = ["foo", "bar"]
    
    application_menu = wx.Menu()
    
    for app in imported_applications:
        # Create Items
        item = wx.MenuItem(application_menu, wx.ID_ANY, app, )
        application_menu.Append(item)
    
        # Bind to function
        self.Bind(wx.EVT_MENU, self.select_application, item, id=app)
    
    # Add to menubar
    menubar.Append(application_menu, '&Applications')
    
    self.SetMenuBar(menubar)
    

Then I try to get that parameter when select_application is called:

    
    
    def select_application(self, event):
    
        id_selected = event.GetId()
        print(id_selected)
    

Outputs:

    
    
    -2014
    -2015
    

**Not sure where that is coming from but I expect it to output the id that I
set at`bind`. The contents of imported_applications are two strings, i.e.
["foo", "bar]**


Answer: 
    app = [ "foo", "bar", ]
    for app in ...
    

Here, your **app** variable is overwritten.

