|Subject:||Re: [wxPython-users] Notebook problem on XP|
|From:||Robin Dunn ("ro....@alldunn.com)|
|Date:||Feb 18, 2010 12:59:02 pm|
On 2/17/10 6:49 PM, duncan smith wrote:
Hello, I've been struggling to get the desired behaviour with notebooks on XP for a while now. I'm hoping for a few pointers.
Basically I have workspace objects each of which which contains a list of drawable graph objects, each containing a canvas. I have a notebook with number of tabs equal to the length of the above lists. When I want to make a workspace 'active' I remove the current pages in the notebook and create new pages containing the relevant canvases (all canvases have the notebook as parent). i.e.
for i in range(self.notebook1.GetPageCount()): self.notebook1.RemovePage(0) for i, dg in enumerate(ws.drawable_graphs): self.notebook1.AddPage(dg.canvas, ws.labels[i])
This works fine on Linux (Ubuntu). The workspace is opened and I can switch between tabs and work with my canvases no problem.
Firstly, on XP I have problems removing pages.
Traceback (most recent call last): File "C:\repos\impact_engine\trunk\BNPy\GMFrame.py", line 375, in OnWSItem self.makeActive(self.getWorkspace(name)) File "C:\repos\impact_engine\trunk\BNPy\GMFrame.py", line 267, in makeActive self.notebook1.RemovePage(i) File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_controls.py", line 3002, in RemovePage return _controls_.BookCtrlBase_RemovePage(*args, **kwargs) wx._core.PyAssertionError: C++ assertion "wxAssertFailure" failed at ..\..\src\msw\notebook.cpp(733) in wxNotebook::DoRemovePage()
For some reason removing pages in the reverse order that they were added usually works, but I still get the above exception quite frequently (possibly after having switched between tabs).
Try just calling DeleteAllPages instead of your loop.
A second, and I guess related issue, is that when I switch between tabs I don't always see the correct canvas displayed. But the correct canvases are associated with the correct tabs. When I switch between tabs a handler is called that may or may not refresh the canvas. It seems that if the canvas is refreshed it requires a mouse click on the canvas area for it to display. If it hasn't been refreshed I can't get to the correct canvas at all.
Please make a small runnable sample that demonstrates this problem. http://wiki.wxpython.org/MakingSampleApps
-- Robin Dunn Software Craftsman http://wxPython.org