]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/MDISashDemo.py
   7 #---------------------------------------------------------------------- 
   8 # There are better ways to do IDs, but this demo requires that the window 
   9 # IDs be in a specific range. There are better ways to do that, too, but 
  10 # this will do for purposes of this demo. 
  16 ID_WINDOW_LEFT1     
= 5001 
  17 ID_WINDOW_LEFT2     
= 5002 
  18 ID_WINDOW_BOTTOM    
= 5003 
  20 #---------------------------------------------------------------------- 
  22 class MyParentFrame(wx
.MDIParentFrame
): 
  24         wx
.MDIParentFrame
.__init
__( 
  25             self
, None, -1, "MDI Parent", size
=(600,400), 
  26             style 
= wx
.DEFAULT_FRAME_STYLE | wx
.HSCROLL | wx
.VSCROLL
 
  31         menu
.Append(ID_Menu_New
, "&New Window") 
  32         menu
.AppendSeparator() 
  33         menu
.Append(ID_Menu_Exit
, "E&xit") 
  35         menubar 
= wx
.MenuBar() 
  36         menubar
.Append(menu
, "&File") 
  37         self
.SetMenuBar(menubar
) 
  39         #self.CreateStatusBar() 
  41         self
.Bind(wx
.EVT_MENU
, self
.OnNewWindow
, id=ID_Menu_New
) 
  42         self
.Bind(wx
.EVT_MENU
, self
.OnExit
, id=ID_Menu_Exit
) 
  45             wx
.EVT_SASH_DRAGGED_RANGE
, self
.OnSashDrag
, id=ID_WINDOW_TOP
,  
  49         self
.Bind(wx
.EVT_SIZE
, self
.OnSize
) 
  52         # Create some layout windows 
  53         # A window like a toolbar 
  54         win 
= wx
.SashLayoutWindow(self
, ID_WINDOW_TOP
, style
=wx
.NO_BORDER|wx
.SW_3D
) 
  55         win
.SetDefaultSize((1000, 30)) 
  56         win
.SetOrientation(wx
.LAYOUT_HORIZONTAL
) 
  57         win
.SetAlignment(wx
.LAYOUT_TOP
) 
  58         win
.SetBackgroundColour(wx
.Colour(255, 0, 0)) 
  59         win
.SetSashVisible(wx
.SASH_BOTTOM
, True) 
  64         # A window like a statusbar 
  65         win 
= wx
.SashLayoutWindow(self
, ID_WINDOW_BOTTOM
, style
=wx
.NO_BORDER|wx
.SW_3D
) 
  66         win
.SetDefaultSize((1000, 30)) 
  67         win
.SetOrientation(wx
.LAYOUT_HORIZONTAL
) 
  68         win
.SetAlignment(wx
.LAYOUT_BOTTOM
) 
  69         win
.SetBackgroundColour(wx
.Colour(0, 0, 255)) 
  70         win
.SetSashVisible(wx
.SASH_TOP
, True) 
  72         self
.bottomWindow 
= win
 
  75         # A window to the left of the client window 
  76         win 
=  wx
.SashLayoutWindow(self
, ID_WINDOW_LEFT1
, style
=wx
.NO_BORDER|wx
.SW_3D
) 
  77         win
.SetDefaultSize((120, 1000)) 
  78         win
.SetOrientation(wx
.LAYOUT_VERTICAL
) 
  79         win
.SetAlignment(wx
.LAYOUT_LEFT
) 
  80         win
.SetBackgroundColour(wx
.Colour(0, 255, 0)) 
  81         win
.SetSashVisible(wx
.SASH_RIGHT
, True) 
  82         win
.SetExtraBorderSize(10) 
  83         textWindow 
= wx
.TextCtrl(win
, -1, "", style
=wx
.TE_MULTILINE|wx
.SUNKEN_BORDER
) 
  84         textWindow
.SetValue("A sub window") 
  86         self
.leftWindow1 
= win
 
  89         # Another window to the left of the client window 
  90         win 
= wx
.SashLayoutWindow(self
, ID_WINDOW_LEFT2
, style
=wx
.NO_BORDER|wx
.SW_3D
) 
  91         win
.SetDefaultSize((120, 1000)) 
  92         win
.SetOrientation(wx
.LAYOUT_VERTICAL
) 
  93         win
.SetAlignment(wx
.LAYOUT_LEFT
) 
  94         win
.SetBackgroundColour(wx
.Colour(0, 255, 255)) 
  95         win
.SetSashVisible(wx
.SASH_RIGHT
, True) 
  97         self
.leftWindow2 
= win
 
 100     def OnSashDrag(self
, event
): 
 101         if event
.GetDragStatus() == wx
.SASH_STATUS_OUT_OF_RANGE
: 
 106         if eID 
== ID_WINDOW_TOP
: 
 107             self
.topWindow
.SetDefaultSize((1000, event
.GetDragRect().height
)) 
 109         elif eID 
== ID_WINDOW_LEFT1
: 
 110             self
.leftWindow1
.SetDefaultSize((event
.GetDragRect().width
, 1000)) 
 112         elif eID 
== ID_WINDOW_LEFT2
: 
 113             self
.leftWindow2
.SetDefaultSize((event
.GetDragRect().width
, 1000)) 
 115         elif eID 
== ID_WINDOW_BOTTOM
: 
 116             self
.bottomWindow
.SetDefaultSize((1000, event
.GetDragRect().height
)) 
 118         wx
.LayoutAlgorithm().LayoutMDIFrame(self
) 
 119         self
.GetClientWindow().Refresh() 
 122     def OnSize(self
, event
): 
 123         wx
.LayoutAlgorithm().LayoutMDIFrame(self
) 
 126     def OnExit(self
, evt
): 
 130     def OnNewWindow(self
, evt
): 
 131         self
.winCount 
= self
.winCount 
+ 1 
 132         win 
= wx
.MDIChildFrame(self
, -1, "Child Window: %d" % self
.winCount
) 
 133         canvas 
= ScrolledWindow
.MyCanvas(win
) 
 137 #---------------------------------------------------------------------- 
 139 if __name__ 
== '__main__': 
 142             wx
.InitAllImageHandlers() 
 143             frame 
= MyParentFrame() 
 145             self
.SetTopWindow(frame
)