Question about wx.NoteBook

甜瓜 wrote:

Today, I feel a little inconvenient in fitting pages in wx.NoteBook.
xrc structure is listed below:
wxFrame "MainFrame"
>__BoxSizer
    >__wxPanel
        >__BoxSizer
            >__wxNoteBook
            ......

wxPanel "PageOne"
>__BoxSizer "#1"
    >__wxPanel "#2 Just for making borders"
        >__FlexGridSizer ("3 cols, many rows")
            >__ EditBox "Some input field"
            .....

I want to add "PageOne" into the wxNoteBook in "MainFrame". This code
is written in MainFrame.__init__:
        self.note_book.AddPage(page_one, "Tab1")
When the mainframe shows, the note_book does not follow the size of
PageOne, so serveral widgets in PageOne are clipped by note_book.
To fix this problem, I explicitly calls:
        self.NOTE_AD.Fit()
        self.Fit()
But wxNoteBook document says it can fit the pages automatically. Is
there something wrong with my code?

What that means is that the notebook's bestsize will be the max of the bestsizes of the pages, plus room for the tabs. So it really depends on how the sizers are configured in the child windows, etc. Also keep in mind that normally a sizer won't resize the window it is attached to, it only resizes and lays out the widgets it contains within the space given to it by the window. So if you want the frame to adjust to the needs of its contents then you will need to do something like Fit yourself.

Another problem is about "border". Previously, my xrc does not have
"#1" & "#2" items. When "PageOne" is added to note_book, left or top
widgets align VERY NEAR the edge which lead to aesthetic problem. :slight_smile:
Moreover, there is no way to set border size on "PageOne" directly,
because: 1. GetWindowBorderSize exists while SetWindowBorderSize not;
2."PageOne" is at one of the roots of xrc tree, no "border" input area
on xrced GUI. My workaround is add "#1" and "#2". Now "#2" has
"border" input area. @_@

Is there any better way to do that?

Just put the FlexGridSizer directly in BoxSizer #1, and set the border flags and value in the sizer item for the FlexGridSizer.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!