Multiple pages problem

Hi,

I want to make many separate pages in a document (like a Word,
wxPanel in wxScrolledWindow). I'm having trouble with layouting
of pages in the document: when the total size of pages exceeds
65000 pixels. Some last pages appears in the begin. Thus I can
create documents with 65 or less pages, but I need more. Any ideas?

Lotus

WX: wxPythonWIN32-2.4.2.4-Py23.exe
OS: WinMe

from wxPython.wx import *

class Page(wxPanel):
  def __init__(self, parent, pos, size, number):
    wxPanel.__init__(self, parent, -1, pos = pos, size = size)
    self.SetBackgroundColour(wxWHITE)
    wxStaticText(self, -1, str(number), pos = (10, 10))

class Doc(wxScrolledWindow):
  def __init__(self, parent):
    wxScrolledWindow.__init__(self, parent, -1)
    
    self.pages = []
    self.margin = 10
    self.pageWidth = 500
    self.pageHeight = 1000
    
    self.sizer = wxBoxSizer(wxVERTICAL)
    
    for i in range(70): #try to chagne this to 60
      self.addPage()
    
    self.SetVirtualSizeHints(300, self.getPagesHeight())
    self.SetSizer(self.sizer)
    
    self.SetScrollRate(10, 10)
  
  def addPage(self):
    x = self.margin
    y = self.getPagesHeight()
    width = self.pageWidth
    height = self.pageHeight
    page = Page(self, (x, y), (width, height), len(self.pages) + 1)
    self.pages.append(page)
    self.sizer.Add(page, 0, wxBOTTOM, 10)
  
  def getPagesHeight(self):
    height = len(self.pages) * self.pageHeight + self.margin
    return height

class MainFrame(wxFrame):
  def __init__(self):
    wxFrame.__init__(self, None, -1, __file__, size = (700, 500))
    self.Center()
    self.doc = Doc(self)
    self.Show(true)

class App(wxApp):
  def OnInit(self):
    self.mw=MainFrame()
    return true
    
if __name__=="__main__":
  app=App()
  app.MainLoop()

Lotus wrote:

Hi,

I want to make many separate pages in a document (like a Word,
wxPanel in wxScrolledWindow). I'm having trouble with layouting
of pages in the document: when the total size of pages exceeds
65000 pixels. Some last pages appears in the begin. Thus I can
create documents with 65 or less pages, but I need more. Any ideas?

Lotus

WX: wxPythonWIN32-2.4.2.4-Py23.exe
OS: WinMe

Window sizes and coordinants on win9x and winME are limited to 64k. Instead of using a wxScrolledWindow witha huge virtual size try using a wxWindow with scrollbars and handle the scroll events yourself. You'll probably also want to draw the portion of your pages that are visible directly on this window instead of using a separate wxPanel for each one.

···

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