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:
== Sizing Windows ==
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:
{{{
#!python
class MyWindow (wxWindow):
def __init___(self,parent):
wxWindow.__init__(self, parent,-1)
self.SetSize(parent.GetClientSize())
}}}
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 wxHtml''''''Window (I pretty much stole this from the demo that comes with wxPython):
{{{
#!python
class MyInfo(wxDialog):
htmlStr = "
Your content here
"
#again, parent is a frame, though it won't appear "bounded" in a frame
def __init__ (self,parent):
wxDialog.__init__(self,parent,-1, "About")
# I found it's best to set either the width or the height
self.htmlWin = wxHtmlWindow(self,-1,size=(300,-1))
self.htmlWin.SetPage(self.htmlStr)
ir = self.htmlWin.GetInternalRepresentation()
self.html.SetSize( (ir.GetWidth()+5, ir.GetHeight()+5) )
self.SetClientSize(self.html.GetSize())
self.CentreOnParent(wxBOTH)
}}}
== wxSplitterWindow - Setting Relative Size ==
This section moved to ProportionalSplitterWindow.
== Questions ==
* 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 <>
* 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