]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/py/wxd/Frames.py
1 """Decorator classes for documentation and shell scripting.
4 __author__
= "Patrick K. O'Brien <pobrien@orbtech.com>"
6 __revision__
= "$Revision$"[11:-2]
9 # These are not the real wxPython classes. These are Python versions
10 # for documentation purposes. They are also used to apply docstrings
11 # to the real wxPython classes, which are SWIG-generated wrappers for
15 from Base
import Object
16 import Parameters
as wx
17 from Window
import TopLevelWindow
, Window
20 class Frame(TopLevelWindow
):
21 """A frame is a window whose size and position can (usually) be
22 changed by the user. It usually has thick borders and a title bar,
23 and can optionally contain a menu bar, toolbar and status bar. A
24 frame can contain any window that is not a frame or dialog.
26 A frame that has a status bar and toolbar created via the
27 CreateStatusBar/CreateToolBar functions manages these windows, and
28 adjusts the value returned by GetClientSize to reflect the
29 remaining size available to application windows.
31 An application should normally define a CloseEvent handler for the
32 frame to respond to system close events, for example so that
33 related data and subwindows can be cleaned up."""
35 def __init__(self
, parent
, id, title
, pos
=wx
.DefaultPosition
,
36 size
=wx
.DefaultSize
, style
=wx
.DEFAULT_FRAME_STYLE
,
37 name
=wx
.PyFrameNameStr
):
38 """Create a Frame instance.
40 parent - The window parent. This may be None. If it is not
41 None, the frame will always be displayed on top of the parent
44 id - The window identifier. It may take a value of -1 to
45 indicate a default value.
47 title - The caption to be displayed on the frame's title bar.
49 pos - The window position. A value of (-1, -1) indicates a
50 default position, chosen by either the windowing system or
51 wxWindows, depending on platform.
53 size - The window size. A value of (-1, -1) indicates a
54 default size, chosen by either the windowing system or
55 wxWindows, depending on platform.
57 style - The window style.
59 name - The name of the window. This parameter is used to
60 associate a name with the item, allowing the application user
61 to set Motif resource values for individual windows."""
64 def Create(self
, parent
, id, title
, pos
=wx
.DefaultPosition
,
65 size
=wx
.DefaultSize
, style
=wx
.DEFAULT_FRAME_STYLE
,
66 name
=wx
.PyFrameNameStr
):
67 """Create a Frame instance."""
70 def Command(self
, id):
71 """Simulate a menu command; id is a menu item identifier."""
74 def CreateStatusBar(self
, number
=1, style
=wx
.ST_SIZEGRIP
, id=-1,
75 name
=wx
.PyStatusLineNameStr
):
76 """Create a status bar at the bottom of frame.
78 number - The number of fields to create. Specify a value
79 greater than 1 to create a multi-field status bar.
81 style - The status bar style. See wx.StatusBar for a list of
84 id - The status bar window identifier. If -1, an identifier
85 will be chosen by wxWindows.
87 name - The status bar window name.
89 The width of the status bar is the whole width of the frame
90 (adjusted automatically when resizing), and the height and
91 text size are chosen by the host windowing system.
93 By default, the status bar is an instance of wx.StatusBar."""
96 def CreateToolBar(self
, style
=wx
.NO_BORDER | wx
.TB_HORIZONTAL
,
97 id=-1, name
=wx
.PyToolBarNameStr
):
98 """Create a toolbar at the top or left of frame.
100 style - The toolbar style. See wxToolBar for a list of valid
103 id - The toolbar window identifier. If -1, an identifier will
104 be chosen by wxWindows.
106 name - The toolbar window name.
108 By default, the toolbar is an instance of wx.ToolBar (which is
109 defined to be a suitable toolbar class on each platform, such
112 When a toolbar has been created with this function, or made
113 known to the frame with wx.Frame.SetToolBar, the frame will
114 manage the toolbar position and adjust the return value from
115 wx.Window.GetClientSize to reflect the available space for
116 application windows."""
119 def DoGiveHelp(self
, text
, show
):
120 """Show help text (typically in the statusbar).
122 show is False if you are hiding the help, True otherwise.
124 Meant to be overridden if a derived frame wants to do
125 something else with help text from menus and etc. The default
126 implementation simply calls Frame.SetStatusText."""
129 def GetClientAreaOrigin(self
):
130 """Return origin of frame client area (in client coordinates).
132 It may be different from (0, 0) if the frame has a toolbar."""
135 def GetMenuBar(self
):
136 """Return menubar currently associated with frame (if any)."""
139 def GetStatusBar(self
):
140 """Return status bar currently associated with frame (if any)."""
143 def GetStatusBarPane(self
):
144 """Return status bar pane used to display menu/toolbar help."""
147 def GetToolBar(self
):
148 """Return toolbar currently associated with frame (if any)."""
151 def PopStatusText(self
, number
=0):
152 """Redraw status bar with previous status text.
154 number - The status field (starting from zero)."""
157 def ProcessCommand(self
, id):
158 """Process menu command; return True if processed.
160 id is the menu command identifier."""
163 def PushStatusText(self
, text
, number
=0):
164 """Set status bar text and redraw status bar, remembering
167 text - The text for the status field.
169 number - The status field (starting from zero).
171 Use an empty string to clear the status bar."""
174 def SendSizeEvent(self
):
175 """Send a dummy size event to the frame forcing it to
176 reevaluate its children positions. It is sometimes useful to
177 call this function after adding or deleting a children after
178 the frame creation or if a child size changes.
180 Note that if the frame is using either sizers or constraints
181 for the children layout, it is enough to call Frame.Layout()
182 directly and this function should not be used in this case."""
185 def SetMenuBar(self
, menubar
):
186 """Show the menu bar in the frame.
188 menuBar - The menu bar to associate with the frame.
190 If the frame is destroyed, the menu bar and its menus will be
191 destroyed also, so do not delete the menu bar explicitly
192 (except by resetting the frame's menu bar to another frame or
195 Under Windows, a call to Frame.OnSize is generated, so be sure
196 to initialize data members properly before calling SetMenuBar.
198 Note that it is not possible to call this function twice for
199 the same frame object."""
202 def SetStatusBar(self
, statBar
):
203 """Associate a status bar with the frame."""
206 def SetStatusBarPane(self
, n
):
207 """Set the status bar pane used to display menu and toolbar
208 help. Using -1 disables help display."""
211 def SetStatusText(self
, text
, number
=0):
212 """Set status bar text and redraw status bar.
214 text - The text for the status field.
216 number - The status field (starting from zero).
218 Use an empty string to clear the status bar."""
221 def SetStatusWidths(self
, choices
):
222 """Sets the widths of the fields in the status bar.
224 choices - a Python list of integers, each of which is a status
225 field width in pixels. A value of -1 indicates that the field
226 is variable width; at least one field must be -1.
228 The widths of the variable fields are calculated from the
229 total width of all fields, minus the sum of widths of the
230 non-variable fields, divided by the number of variable fields."""
233 def SetToolBar(self
, toolbar
):
234 """Associate a toolbar with the frame."""
238 class LayoutAlgorithm(Object
):
239 """LayoutAlgorithm implements layout of subwindows in MDI or SDI
240 frames. It sends a wx.CalculateLayoutEvent event to children of
241 the frame, asking them for information about their size. For MDI
242 parent frames, the algorithm allocates the remaining space to the
243 MDI client window (which contains the MDI child frames). For SDI
244 (normal) frames, a 'main' window is specified as taking up the
247 Because the event system is used, this technique can be applied to
248 any windows, which are not necessarily 'aware' of the layout
249 classes. However, you may wish to use wx.SashLayoutWindow for
250 your subwindows since this class provides handlers for the
251 required events, and accessors to specify the desired size of the
252 window. The sash behaviour in the base class can be used,
253 optionally, to make the windows user-resizable.
255 LayoutAlgorithm is typically used in IDE (integrated development
256 environment) applications, where there are several resizable
257 windows in addition to the MDI client window, or other primary
258 editing window. Resizable windows might include toolbars, a
259 project window, and a window for displaying error and warning
262 When a window receives an OnCalculateLayout event, it should call
263 SetRect in the given event object, to be the old supplied
264 rectangle minus whatever space the window takes up. It should
265 also set its own size accordingly.
266 SashLayoutWindow.OnCalculateLayout generates an OnQueryLayoutInfo
267 event which it sends to itself to determine the orientation,
268 alignment and size of the window, which it gets from internal
269 member variables set by the application.
271 The algorithm works by starting off with a rectangle equal to the
272 whole frame client area. It iterates through the frame children,
273 generating OnCalculateLayout events which subtract the window size
274 and return the remaining rectangle for the next window to process.
275 It is assumed (by SashLayoutWindow.OnCalculateLayout) that a
276 window stretches the full dimension of the frame client, according
277 to the orientation it specifies. For example, a horizontal window
278 will stretch the full width of the remaining portion of the frame
279 client area. In the other orientation, the window will be fixed
280 to whatever size was specified by OnQueryLayoutInfo. An alignment
281 setting will make the window 'stick' to the left, top, right or
282 bottom of the remaining client area. This scheme implies that
283 order of window creation is important. Say you wish to have an
284 extra toolbar at the top of the frame, a project window to the
285 left of the MDI client window, and an output window above the
286 status bar. You should therefore create the windows in this
287 order: toolbar, output window, project window. This ensures that
288 the toolbar and output window take up space at the top and bottom,
289 and then the remaining height in-between is used for the project
292 LayoutAlgorithm is quite independent of the way in which
293 OnCalculateLayout chooses to interpret a window's size and
294 alignment. Therefore you could implement a different window class
295 with a new OnCalculateLayout event handler, that has a more
296 sophisticated way of laying out the windows. It might allow
297 specification of whether stretching occurs in the specified
298 orientation, for example, rather than always assuming
299 stretching. (This could, and probably should, be added to the
300 existing implementation).
302 The algorithm object does not respond to events, but itself
303 generates the following events in order to calculate window sizes:
304 EVT_QUERY_LAYOUT_INFO(func), EVT_CALCULATE_LAYOUT(func)."""
307 """Create a LayoutAlgorithm instance."""
310 def LayoutFrame(self
, frame
, mainWindow
=wx
.NULL
):
311 """Lay out the children of a normal frame.
313 mainWindow is set to occupy the remaining space. This
314 function simply calls LayoutWindow()."""
317 def LayoutMDIFrame(self
, frame
, rect
=wx
.NULL
):
318 """Lay out the children of an MDI parent frame.
320 If rect is non-NULL, the given rectangle will be used as a
321 starting point instead of the frame's client area.
323 The MDI client window is set to occupy the remaining space."""
326 def LayoutWindow(self
, parent
, mainWindow
=wx
.NULL
):
327 """Lay out the children of a normal frame or other window.
329 mainWindow is set to occupy the remaining space. If this is
330 not specified, then the last window that responds to a
331 calculate layout event in query mode will get the remaining
332 space (that is, a non-query OnCalculateLayout event will not
333 be sent to this window and the window will be set to the
338 class MDIChildFrame(Frame
):
362 class MDIClientWindow(Window
):
374 class MDIParentFrame(Frame
):
385 def ActivateNext(self
):
389 def ActivatePrevious(self
):
393 def ArrangeIcons(self
):
401 def GetActiveChild(self
):
405 def GetClientWindow(self
):
409 def GetToolBar(self
):
418 class MiniFrame(Frame
):
430 class SplashScreen(Frame
):
437 def GetSplashStyle(self
):
441 def GetSplashWindow(self
):
445 def GetTimeout(self
):
450 class SplashScreenWindow(Window
):
466 class StatusBar(Window
):
477 def GetBorderX(self
):
481 def GetBorderY(self
):
485 def GetFieldRect(self
):
489 def GetFieldsCount(self
):
493 def GetStatusText(self
):
497 def PopStatusText(self
):
501 def PushStatusText(self
):
505 def SetFieldsCount(self
):
509 def SetMinHeight(self
):
513 def SetStatusText(self
):
517 def SetStatusWidths(self
):