Re: am I heading in the right direction?
Tim Roberts <[email protected]>
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Organization | Providenza & Boekelheide, Inc. |
| Message-ID | <[email protected]> |
Nathan smith wrote: > > > Second off, this one is to do with panels. I'm a little stuck as to > how I should be showing my panels, and to be honest I think I'm > overdoing it a lot. It is key that you understand that all of the windowing systems are event based. With very few exceptions, when you make a call changing the state of a window, the screen pixels will not have changed by the time the call returns. Instead, the change will queue up a message. The next time your app returns to its message loop, that message will be popped off the queue and handled. That's where the pixels change. You don't have to call Show on your individual panels and controls. You just have to Show your frame. As long as a control isn't hidden, it will get drawn when the frame refreshes. Nothing gets drawn during your "create" call. This is just setting up data structures. When you call self.Show() on the frame, that will start the process of sending paint messages to all of the subwindows. That's where the pixels actually get drawn When create_window returns, nothing is yet visible. That happens later. Refresh queues up a repaint message, asking the window to repaint itself the next time it gets to its message loop. Update demands that the window repaint itself immediately, but that's not meaningful during initialization, because nothing has been painted. Basically, you never need to call Update or Refresh during initialization. A refresh will be done as soon as the window creation is finished. The Layout/Fit stuff is mostly superstition. Layout gets called during "size" message handling. Fit is useful for your Frame, so it can resize itself to fit the panel, but you generally don't need it for lower windows. Layout doesn't actually draw anything. It just forces all of the sizers to recompute the size of their contained components. If the sizes change, repaint requests will be queued up and the components will redraw themselves later. So, where you have this: > hbox1.Add(browse1,1,wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5) > vbox.Add(hbox1) > panel.SetSizer(vbox) > panel.Show() > panel.Fit() # assuming it fits it to the screen > panel.Layout() # not sure entirely, but figure it draws everything > on screen > panel.Update() # don't know if I actually need this, I'm a bit > confused between self.Refresh, and self.upadte > self.Show() # for the frame > self.Fit() > self.Update() > self.Refresh() > self.Center() I'd replace those last 10 lines with this: panel.SetSizer(vbox) self.Center() self.Fit() self.Show() You might need to experiment with adding panel.Layout after the SetSizer. Even after 20 years with wx, I'm still unclear on that interaction, so I end up experimenting. -- Tim Roberts, [email protected] Providenza & Boekelheide, Inc. -- You received this message because you are subscribed to the Google Groups "wxPython-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/8d70fe41-07fd-d27f-383b-534e112fbec8%40probo.com.
smime.p7s
(application/pkcs7-signature, 3.3 KB) - not displayed