Zack
Zack

Reputation: 4375

wx.Notebook tab only showing in cropped in top left corner rather than taking up the whole frame?

I'm trying to test out the wx.Notebook tabs in one of my guis. However, I've got a problem where only a tiny portion of the tab shows in the top left corner.

enter image description here

As you can see, only a very small part of it is showing. I can't figure out what wrong.

My code is as follows:

import wx
class MyFrame(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, "test", size=(640,480))
        panel = wx.Panel(self)

        notebook = wx.Notebook(panel, style=wx.BK_DEFAULT, size=(640,480))
        tabOne = wx.Panel(notebook)
        notebook.AddPage(tabOne, "Tab One")

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(notebook, flag=wx.EXPAND)
        self.SetSizer(sizer)

if __name__ == '__main__':

    app = wx.PySimpleApp(redirect=False)
    frame = MyFrame(parent=None, id=-1)
    frame.Show()
    app.MainLoop()

Anyone know what would cause such a thing?

Upvotes: 2

Views: 433

Answers (1)

f4lco
f4lco

Reputation: 3814

You have to fix one line:

notebook = wx.Notebook(self, style=wx.BK_DEFAULT, size=(640,480))

Formerly you created the notebook as child of panel which hasn't any sizer set. Hence the small size. panel is now obsolete.

Upvotes: 1

Related Questions