Hi, I was wondering if it's possible to call a function using a string that is the exact same as the name of the function. Here's an example in which I wanted to make 4 bitmap buttons using a for loop, and the event bound to each one would be named similarly to the name of icon on it:
self.buttons = []
self.buttonBitmaps = [ "New", "Edit", "Delete", "About" ]
for i in range( 0, 4 ):
self.image = wx.Image( "images/" + self.buttonBitmaps[ i ] + ".png",
type=wx.BITMAP_TYPE_ANY ).ConvertToBitmap()
self.tempButton = wx.BitmapButton( self.panel2, ID_BUTTON + i,
self.image, size=( 30, 30 ), pos=( i * 30, 5 ) )
self.buttons.append( self.button )
self.tempButton.Bind( wx.EVT_BUTTON,
"self.On" + self.buttonBitmaps[ i ] + "()" )
As you can see, the first button I wanted to call the function "self.OnNew()" when clicked. I know that this isn't working because I put a string in the event function, whereas it wants a function. Is there any sort of way I could turn the string into a reference to the function?