Notebook PageSize

Hi all,

I need to determine the size of a page after it has been added to the
notebook. When I add a page to a notebook and I query the page's size after
the add, then I get a size of (20,20) which is incorrect but after the next
event the page's size is reported correctly. I need to know the size of the
page directly after the add and not after the next event.

How can I get the size of the page after the AddPage?

def newPage(self):
  global win
  win = wxPanel(self.notebook,-1)
  nb = self.notebook
  nb.AddPage(win,'The next tab')
  # tried nb.Fit(),nb.Layout() etc
  print win.GetSizeTuple() # this returns (20,20)
  wxFutureCall(50,reportSize)

def reportSize(self):
  global win
  print win.GetSizeTuple() # this returns the correct size, but it is
too late

Any help would be appreciated

Regards
Gerrit van Dyk

Gerrit Van Dyk wrote:

I need to determine the size of a page after it has been added to the
notebook. When I add a page to a notebook and I query the page's size after
the add, then I get a size of (20,20) which is incorrect but after the next
event the page's size is reported correctly. I need to know the size of the
page directly after the add and not after the next event.

It's probably impossible to do exactly what you want. I suspect that the size is not *set* until after the current event ends -- it's set in a separate size event. You'll probably need to use wxCallAfter() to delay the size-dependent code until after that size event has been processed. This means that adding a page will become a two-stage affair.

By the way, it's probably not very good form to use 'win' as a global variable. Instead, you should make it an attribute -- i.e.,

def newPage(self):
     self.win = wxPanel( ...)
     #[...]
     print self.win.GetSizeTuple()

It will then be available from all methods of your frame (which I presume is what self is, in this case).

Jeff Shannon
Technician/Programmer
Credit International