#!/usr/bin/env python ''' Let's try to construct the gui builders as functions within a module instead of objects ''' import wx import testGuiData from testguicontroller import GuiController as gcontrol controller = gcontrol() def ButtonBuilder(parent, buttonName): ''' This function builds button in every parent requesting to do so. Data needed for button construction (label, position etc.) must be stored in the testGuiData.buttonData dictionary. ''' button_data = testGuiData.buttonData[buttonName] #print button_data, just for debugging _button = wx.Button(parent, -1, button_data.label) handler = getattr(gcontrol, button_data.handler) #handler = button_data.handler print handler name = "controller." + str(handler.__name__) #parent.Bind(wx.EVT_BUTTON, controller.OnTest, _button); This does work indeed! parent.Bind(wx.EVT_BUTTON, eval(name), _button) return _button def TextBuilder(parent, textname): ''' This function builds text widegets in every parent requesting to do so. Data needed for text box construction (label, position etc.) must be stored in the testGuiData.textData dictionary. Inthe dictionary also the type of text widget: static or TxtCtrl must be constructed ''' text_data = testGuiData.textData[textname] if text_data[0] == "static": _textbox = wx.StaticText(parent, -1, text_data[1]) return _textbox else: _textbox = wx.TextCtrl(parent, -1, text_data[1]) return _textbox