wxPython dynamic add component

105 views Asked by At

How can I add component dynamically in the bSizerMain through the class SyslogFrame without edit class frame_syslog

Because the UI is generated by wxFormBuilder

class SyslogFrame(program_UI.frame_syslog):
    def __init__(self,parent): 
        program_UI.frame_syslog.__init__(self,parent)
        self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)



class frame_syslog ( wx.Frame ):
    def __init__( self, parent ):
        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"Syslog", pos = wx.DefaultPosition, size = wx.Size( 1185,714 ), style = wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT|wx.FRAME_NO_TASKBAR|wx.SYSTEM_MENU|wx.CLIP_CHILDREN|wx.TAB_TRAVERSAL )

        self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
        self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_BTNFACE ) )

        bSizerMain = wx.BoxSizer( wx.VERTICAL )

        self.SetSizer( bSizerMain )
        self.Layout()

        self.Centre( wx.BOTH )

    def __del__( self ):
        pass
1

There are 1 answers

0
Petr Blahos On

I guess you can use

self.GetSizer()

to get the sizer. Then you should be able to add things to the sizer.