0

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.

2
  • It's unclear what you mean exactly. Could you provide a more complete running example and better description? Commented Oct 24, 2013 at 11:17
  • 1
    I want to create my own function for build GUI fast. Commented Oct 24, 2013 at 13:13

1 Answer 1

2

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:

Sign up to request clarification or add additional context in comments.

1 Comment

Thank's so much. I't very interesting article. I Read it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.