RE: [wxPython] I may need a MDI reality check
Below is a message that I posted a while back that contains an example of an MDI application using a sash. I’m still using this layout in a major application: it works well except for a problem specified below. Robin Dunn just replied to my questions regarding wxPython 2.3.2.1. (Thanks Robin) He recommended the following:
"
As a workaround you can just set the cursor for the notebook page windows:
page.SetCursor(wxSTANDARD_CURSOR)
"
------- Sash/Splitter bug in wxPython 2.3.2.1 and 2.3.3pre3 not in 2.3.1 -------
Hi folks,
I’ve been having a problem with wxPython 2.3.2.1 and 2.3.3pre3 that I didn’t have with 2.3.1. I’ve included a program that recreates the problem.
Briefly, I’m trying to create an MDI application where the main frame is divided into client area and a sash, using a wxSashLayoutWindow. The sash is split into two windows using a wxSplitterWindow. The problem occurs when the mouse cursor is slowly moved from the client area into the sash area. While in the client area, an arrow cursor is displayed, then it changes to a “horizontal sizing” cursor (while crossing the sash frame), then the arrow cursor re-appears, and finally the “horizontal sizing” cursor returns. The final transition to “horizontal sizing” cursor is the bug. The bug does not manifest when the mouse is moved quickly.
Is this a bug in wxPython, or am I using a wxSashLayoutWindow and wxSplitterWindow in an invalid way?
Is there a workaround that uses a different combination of sashes and splitters? I think that I initially tried using a sash within a sash, but that didn’t work.
Any examples of how to split an MDI application up the way that I’m trying?
Should I enter a bug report, or will the person that verifies that it is a bug do this?
Thanks in advance,
Matthew
···
#----------------------------------------------------------------------
#!/usr/bin/env python
1) Create a wxMDIParentFrame as the main window
2) Split main window with a wxSashLayoutWindow on the left
3) Split the sash into a top and botton portion using a wxSplitterWindow
4) Add wxNotebook’s to the top and bottom parts of the sash
5) Add a wxScrolledWindow page to each wxNotebook
from wxPython.wx import *
class MainFrame(wxMDIParentFrame):
def __init__(self, parent, id, title):
wxMDIParentFrame.__init__(self, parent, id, title, size=(800, 600))
ID_WINDOW_LEFT = wxNewId()
# A sash to the left of the client window
self.sashLeft = wxSashLayoutWindow(self, ID_WINDOW_LEFT, style = wxNO_BORDER|wxSW_3D)
self.sashLeft.SetDefaultSize((250, -1))
self.sashLeft.SetOrientation(wxLAYOUT_VERTICAL)
self.sashLeft.SetAlignment(wxLAYOUT_LEFT)
self.sashLeft.SetSashVisible(wxSASH_RIGHT, TRUE)
EVT_SIZE(self, self.OnSize)
EVT_SASH_DRAGGED(self, ID_WINDOW_LEFT, self.OnSashLeftDrag)
##########################
# Create a splitter that divides the sash into two windows
sashSplitter = wxSplitterWindow(self.sashLeft, -1, style=wxNO_3D|wxSP_3D)
# Create a notebook for the top part of the splitter
notebookTop = wxNotebook(sashSplitter, -1, style=wxCLIP_CHILDREN)
page = wxScrolledWindow(notebookTop)
notebookTop.AddPage(page, 'Page 1')
# Create a notebook for the bottom part of the splitter
notebookBottom = wxNotebook(sashSplitter, -1, style=wxCLIP_CHILDREN)
page = wxScrolledWindow(notebookBottom)
notebookBottom.AddPage(page, 'Page 1')
# add the windows to the splitter and split it.
sashSplitter.SplitHorizontally(notebookTop, notebookBottom)
sashSplitter.SetSashPosition(400, true)
sashSplitter.SetMinimumPaneSize(35)
def OnSashLeftDrag(self, event):
if event.GetDragStatus() == wxSASH_STATUS_OUT_OF_RANGE:
return
sashSize = (event.GetDragRect().width, -1)
self.sashLeft.SetDefaultSize(sashSize)
wxLayoutAlgorithm().LayoutMDIFrame(self)
self.GetClientWindow().Refresh()
def OnSize(self, event):
wxLayoutAlgorithm().LayoutMDIFrame(self)
#----------------------------------------------------------------------
class MyApp(wxApp):
def __init__(self, num, bOutputWindow = true):
wxApp.__init__(self, num)
def OnInit(self):
wxInitAllImageHandlers()
mainFrame = MainFrame(None, -1, "Cursor Bug")
mainFrame.Show(true)
self.SetTopWindow(mainFrame)
return true
def main():
app = MyApp(0)
app.MainLoop()
#----------------------------------------------------------------------------
if name == ‘main’:
main()
-----Original Message-----
From: Sam Leming [mailto:gibbs05@airmail.net]
Sent: Tuesday, June 04, 2002 3:13 AM
To: wxpython-users@lists.wxwindows.org
Subject: [wxPython] I may need a MDI reality check
Greetings all,
I’ve recently returned to Python programming after over a year of Java exile
and wxPython is completely new to me.
I’d like to write an application that uses a wxMDIParentFrame on one side of
a splitter and several controls on the other. Can a MDI parent frame have
parents in general and a splitter parent in particular? I’m not asking for
how to do this, I just want to know if it’s possible or prudent.
As I’ve said before, I’ve just started with wxPython. I don’t want to get
stuck in a “default behavior tar pit” right from the start. I’ve thrown
together a test app with a wxTextCtrl on the right side of a splitter and a
wxMDIParentFrame on the left. When I drag the splitter sash to the left it
leaves images of the sash behind in the MDI area. Resizing the window
gives me border artifacts in the MDI area. I haven’t been able to create a
MDI child window yet either.
Are these just speed bumps or am I going down the wrong road completely?
I guess plan B would be to make the MDI parent frame the top level and stick
the permanent controls to the side.
TIA,
Sam