def _initMenuBar(self): """ Initialize the file menu """ # create file menu fileMenu = wx.Menu() fileMenu.Append( wx.ID_OPEN, "&Open", " Open repository" ) fileMenu.AppendSeparator() fileMenu.Append( wx.ID_EXIT, "E&xit", " Terminate Phyxel" ) for key, value in controlDict.iteritems(): newControlLambdas[ key ] = lambda e : openControl( key ) #for value in controlDict.itervalues(): # value # create the new menu newMenu = wx.Menu() for key, value in controlDict.iteritems(): item = newMenu.Append( key, getStringFromClass( value ), "har" ) self.Bind( wx.EVT_MENU, self.onNewTileMap, item ) #newControlLambdas[key] = ((lambda e : openControl( key )), key, value) #wx.EVT_MENU( self, key, newControlLambdas[key][0] ) #lambda e : openControl( copy( key ) ) # create menu bar self.menuBar = wx.MenuBar() self.menuBar.Append( fileMenu, "&File" ) self.menuBar.Append( newMenu, "&New" ) # link press events wx.EVT_MENU( self, wx.ID_OPEN, self.onOpen ) wx.EVT_MENU( self, wx.ID_EXIT, self.onExit ) # hook menu bar to frame self.SetMenuBar( self.menuBar )
def onNewTileMap(self, event): """ Hopefully temporery, can we use lambda's to dynamically bind to the openControl function and send in the correct id """ openControl( FILE_ID_MAP )