There are other people that should be doing this - but I guess I'll dispense my little knowledge of this, and then let other people correct me. =)
Windows are the main thing in a GUI (duh!). In wxWidgets, almost all windows need to have a wxFrame as a parent - for sure, you will have one wxFrame for your application.
For me, the part that took me the longest to figure out, and what really isn't in the documentation, is a good way to size your window to the frame. So:
This snippet of code should help you to size the window according to the parent (and the parent is probably a wxFrame). It assumes, of course, that the parent has a defined size:
Yes, it's that easy. But what if your window isn't in a frame - like a pop-up window? Here's what I did for a wxDialog containing an wxHtmlWindow (I pretty much stole this from the demo that comes with wxPython):
1 class MyInfo(wxDialog): 2 htmlStr = "<html><body><h1>Your content here</h1></body></html>" 3 4 #again, parent is a frame, though it won't appear "bounded" in a frame 5 def __init__ (self,parent): 6 wxDialog.__init__(self,parent,-1, "About") 7 8 # I found it's best to set either the width or the height 9 self.htmlWin = wxHtmlWindow(self,-1,size=(300,-1)) 10 self.htmlWin.SetPage(self.htmlStr) 11 12 ir = self.htmlWin.GetInternalRepresentation() 13 self.html.SetSize( (ir.GetWidth()+5, ir.GetHeight()+5) ) 14 15 self.SetClientSize(self.html.GetSize()) 16 self.CentreOnParent(wxBOTH)
wxSplitterWindow - Setting Relative Size
This section moved to ProportionalSplitterWindow.
I am new to GUI programming, so this question may be dumb, but- Why do people implement the "wxWindow" class? Why not just use sizers within a frame? I see people use "Window" in many places, I just don't understand why. -- LionKimbro 2003-09-17 20:52:00
The wxFrame class is not designed to be a container of controls (although it can), but rather a container of other types of windows. On the other hand, a wxPanel is designed to be a container of controls and it implements TAB traversal and etc. Try putting controls on just a frame on MS Windows and you'll see another reason to do it. -- RobinDunn