Notebook with tabs on the side has extra space initially

When I put tabs on the left or right side of a wx.Notebook, it initially creates a space beside the tabs that is as wide as the tabs themselves. This space disappears as soon as the frame is resized in any way. On my system (wxPython 2.8.11 on Windows 7), this can be seen by running the attached little program.

I would like to stop this extra initial space appearing but I haven’t been able to. I tried adding Refresh() and Layout() to the code and I tried putting the notebook in a panel with a sizer, but none of those things made any difference. There has been discussion on this list of the fact that windows styles are disabled when tabs aren’t at the top but I haven’t found any discussion of this extra space when tabs are on a side. Is there something I could do to get rid of this initial space?

Patrick Maher

nbtest.py (641 Bytes)

After nb = Notebook(self) call wx.CallAfter(nb.SendSizeEvent) and it works ok.

Toni

···

On Mon, 20 Feb 2012 17:08:08 +0100, Patrick Maher <patrick@maher1.net> wrote:

When I put tabs on the left or right side of a wx.Notebook, it initially
creates a space beside the tabs that is as wide as the tabs themselves.
This space disappears as soon as the frame is resized in any way. On my
system (wxPython 2.8.11 on Windows 7), this can be seen by running the
attached little program.
I would like to stop this extra initial space appearing but I haven't been
able to. I tried adding Refresh() and Layout() to the code and I tried
putting the notebook in a panel with a sizer, but none of those things made
any difference. There has been discussion on this list of the fact that
windows styles are disabled when tabs aren't at the top but I haven't found
any discussion of this extra space when tabs are on a side. Is there
something I could do to get rid of this initial space?

Sending the notebook a size event seems to take care of it for me.

         wx.CallAfter(nb.SendSizeEvent)

I used CallAfter so it will happen right after the main loop starts.

···

On 2/20/12 8:08 AM, Patrick Maher wrote:

When I put tabs on the left or right side of a wx.Notebook, it initially
creates a space beside the tabs that is as wide as the tabs themselves.
This space disappears as soon as the frame is resized in any way. On my
system (wxPython 2.8.11 on Windows 7), this can be seen by running the
attached little program.

I would like to stop this extra initial space appearing but I haven't
been able to. I tried adding Refresh() and Layout() to the code and I
tried putting the notebook in a panel with a sizer, but none of those
things made any difference. There has been discussion on this list of
the fact that windows styles are disabled when tabs aren't at the top
but I haven't found any discussion of this extra space when tabs are on
a side. Is there something I could do to get rid of this initial space?

--
Robin Dunn
Software Craftsman

Thanks guys for solving my problem.

In the actual program I’m working on, the notebook with tabs on the side is a page in another notebook with tabs on the top. Here, the problem was solved by putting the CallAfter command you suggested after the creation of the inner notebook, like this:

class Notebook(wx.Notebook):
def init(self,parent):
wx.Notebook.init(self,parent,-1)
panel = Panel(self)
subnb = SubNotebook(self)
wx.CallAfter(subnb.SendSizeEvent)
self.AddPage(panel,‘Panel’)
self.AddPage(subnb,‘SubNb’)

Thanks again,
Patrick Maher