i want to create a class that create control at runtime; for example:
self.Text1 = wx.TextCtrl( self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 50,-1 ), wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB )
self.Text1.SetFont( wx.Font( 12, 74, 90, 90, False, wx.EmptyString ) )
Tranform this (for Example define my ipotetic library) on
AddText(Text1, self.m_panel1, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 50,-1 ), wx.TE_PROCESS_ENTER|wx.TE_PROCESS_TAB )
self.Text1.SetFont( wx.Font( 12, 74, 90, 90, False, wx.EmptyString ) )
It's possibible to create and accessing to control at runtime?
Thank's Aesis.
I actually wrote an article on this topic a while back which you can read here:
The idea is to create the widget and then call the parent's Layout() method to get it to show up correctly. If you're going to be adding a lot of widgets, then you might want to use a ScrolledPanel or similar, otherwise the widgets may get added off-screen.
Binding dynamic widgets is tricky in that you want to define the event handlers BEFORE you create the widgets. I don't have any examples handy. However, you might get some ideas from this article for one approach:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.