Note that there are some explanatory texts on larger screens.

plurals
  1. POWxPython: Multiple Widgets in a Child Window
    primarykey
    data
    text
    <p>I'm teaching myself (Wx) Python and got stuck. I want to create a child window that has a recurring set of information inside of my TestFrame, which contains most of my code. The problem is, it only shows one widget in my code. I am trying to figure out the following, in order of importance to me. </p> <p>**Note that this code is an extension to <a href="https://stackoverflow.com/questions/8263513/show-another-window-wxpython">this</a> page.*</p> <ol> <li>How can I allow multiple widgets in the "AddBox" class to appear correctly?</li> <li>When my window is resized, it corrupts the button images as in the screen attached. How could I fix this?</li> <li>How do you call/bind each of these dynamically created widgets?</li> <li>Bonus: is the "OnSize" module needed here?</li> </ol> <p>Thank you for your help. If allowed/appropriate, I'm willing to contribute $5 via Paypal to the winner if you PM me.</p> <pre><code>import wx class AddBox(wx.Window): def __init__(self, parent): wx.Window.__init__(self, parent) pbox = wx.BoxSizer(wx.VERTICAL) controlback = wx.Button(self, label="Back") controlforward = wx.Button(self, label="Forward") pbox.AddMany([(controlback, 1, wx.ALL), (controlforward, 1, wx.ALL)]) class TestFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, -1, size=(1000, 550)) self.Bind(wx.EVT_SIZE, self.OnSize) pbox0 = wx.BoxSizer(wx.VERTICAL) controlback0 = wx.Button(self, label="Back0") controlforward0 = wx.Button(self, label="Forward0") pbox0.AddMany([(controlback0, 1, wx.ALL), (controlforward0, 1, wx.ALL)]) pbox2 = wx.BoxSizer(wx.VERTICAL) self.scrolling_window = wx.ScrolledWindow( self ) self.scrolling_window.SetScrollRate(1,6) self.scrolling_window.EnableScrolling(True,True) self.sizer_container = wx.BoxSizer( wx.VERTICAL ) self.sizer = wx.BoxSizer( wx.VERTICAL ) self.sizer_container.Add(self.sizer,1,wx.CENTER,wx.EXPAND) self.child_windows = [] for i in range(0,8): wind = AddBox(self.scrolling_window) self.sizer.Add(wind, 0, wx.CENTER|wx.ALL, 5) self.child_windows.append(wind) self.scrolling_window.SetSizer(self.sizer_container) #self.Layout() #not needed? pbox2.AddMany([(self.sizer_container, 1, wx.ALL)]) def OnSize(self, event): self.scrolling_window.SetSize(self.GetClientSize()) if __name__=='__main__': app = wx.PySimpleApp() f = TestFrame() f.Show() app.MainLoop() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload