STATIC_BORDER = _core.STATIC_BORDER
TRANSPARENT_WINDOW = _core.TRANSPARENT_WINDOW
NO_BORDER = _core.NO_BORDER
-USER_COLOURS = _core.USER_COLOURS
-NO_3D = _core.NO_3D
TAB_TRAVERSAL = _core.TAB_TRAVERSAL
WANTS_CHARS = _core.WANTS_CHARS
POPUP_WINDOW = _core.POPUP_WINDOW
CENTER_FRAME = _core.CENTER_FRAME
CENTRE_ON_SCREEN = _core.CENTRE_ON_SCREEN
CENTER_ON_SCREEN = _core.CENTER_ON_SCREEN
-STAY_ON_TOP = _core.STAY_ON_TOP
-ICONIZE = _core.ICONIZE
-MINIMIZE = _core.MINIMIZE
-MAXIMIZE = _core.MAXIMIZE
-CLOSE_BOX = _core.CLOSE_BOX
-THICK_FRAME = _core.THICK_FRAME
-SYSTEM_MENU = _core.SYSTEM_MENU
-MINIMIZE_BOX = _core.MINIMIZE_BOX
-MAXIMIZE_BOX = _core.MAXIMIZE_BOX
-TINY_CAPTION_HORIZ = _core.TINY_CAPTION_HORIZ
-TINY_CAPTION_VERT = _core.TINY_CAPTION_VERT
-RESIZE_BOX = _core.RESIZE_BOX
-RESIZE_BORDER = _core.RESIZE_BORDER
-DIALOG_MODAL = _core.DIALOG_MODAL
-DIALOG_MODELESS = _core.DIALOG_MODELESS
-DIALOG_NO_PARENT = _core.DIALOG_NO_PARENT
-DEFAULT_FRAME_STYLE = _core.DEFAULT_FRAME_STYLE
-DEFAULT_DIALOG_STYLE = _core.DEFAULT_DIALOG_STYLE
-FRAME_TOOL_WINDOW = _core.FRAME_TOOL_WINDOW
-FRAME_FLOAT_ON_PARENT = _core.FRAME_FLOAT_ON_PARENT
-FRAME_NO_WINDOW_MENU = _core.FRAME_NO_WINDOW_MENU
-FRAME_NO_TASKBAR = _core.FRAME_NO_TASKBAR
-FRAME_SHAPED = _core.FRAME_SHAPED
ED_CLIENT_MARGIN = _core.ED_CLIENT_MARGIN
ED_BUTTONS_BOTTOM = _core.ED_BUTTONS_BOTTOM
ED_BUTTONS_RIGHT = _core.ED_BUTTONS_RIGHT
GROW = _core.GROW
EXPAND = _core.EXPAND
SHAPED = _core.SHAPED
-ADJUST_MINSIZE = _core.ADJUST_MINSIZE
+FIXED_MINSIZE = _core.FIXED_MINSIZE
TILE = _core.TILE
+ADJUST_MINSIZE = _core.ADJUST_MINSIZE
BORDER_DEFAULT = _core.BORDER_DEFAULT
BORDER_NONE = _core.BORDER_NONE
BORDER_STATIC = _core.BORDER_STATIC
"""GetHeight() -> int"""
return _core.Size_GetHeight(*args, **kwargs)
+ def IsFullySpecified(*args, **kwargs):
+ """
+ IsFullySpecified() -> bool
+
+ Returns True if both components of the size are non-default values.
+ """
+ return _core.Size_IsFullySpecified(*args, **kwargs)
+
+ def SetDefaults(*args, **kwargs):
+ """
+ SetDefaults(Size size)
+
+ Combine this size with the other one replacing the default
+ components of this object (i.e. equal to -1) with those of the
+ other.
+ """
+ return _core.Size_SetDefaults(*args, **kwargs)
+
def Get(*args, **kwargs):
"""
Get() -> (width,height)
"""GetHeight() -> int"""
return _core.Image_GetHeight(*args, **kwargs)
+ def GetSize(*args, **kwargs):
+ """GetSize() -> Size"""
+ return _core.Image_GetSize(*args, **kwargs)
+
def GetSubImage(*args, **kwargs):
"""GetSubImage(Rect rect) -> Image"""
return _core.Image_GetSubImage(*args, **kwargs)
val.thisown = 1
return val
-def EmptyImage(*args, **kwargs):
- """EmptyImage(int width=0, int height=0, bool clear=True) -> Image"""
- val = _core.new_EmptyImage(*args, **kwargs)
+def EmptyImage(*args):
+ """
+ EmptyImage(int width=0, int height=0, bool clear=True) -> Image
+ EmptyImage(Size size, bool clear=True) -> Image
+ """
+ val = _core.new_EmptyImage(*args)
val.thisown = 1
return val
"""
GetComCtl32Version() -> int
- Returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
- wasn't found at all. Raises an exception on non-Windows platforms.
+ Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or
+ 0 if it wasn't found at all. Raises an exception on non-Windows
+ platforms.
"""
return _core.PyApp_GetComCtl32Version(*args, **kwargs)
"""
PyApp_GetComCtl32Version() -> int
- Returns 400, 470, 471 for comctl32.dll 4.00, 4.70, 4.71 or 0 if it
- wasn't found at all. Raises an exception on non-Windows platforms.
+ Returns 400, 470, 471, etc. for comctl32.dll 4.00, 4.70, 4.71 or
+ 0 if it wasn't found at all. Raises an exception on non-Windows
+ platforms.
"""
return _core.PyApp_GetComCtl32Version(*args, **kwargs)
EVT_CLOSE(self.frame, self.OnCloseWindow)
+ def OnCloseWindow(self, event):
+ if self.frame is not None:
+ self.frame.Destroy()
+ self.frame = None
+ self.text = None
+
+
# These methods provide the file-like output behaviour.
def write(self, text):
"""
wx.CallAfter(self.frame.Close)
- def OnCloseWindow(self, event):
- if self.frame is not None:
- self.frame.Destroy()
- self.frame = None
- self.text = None
#----------------------------------------------------------------------
self.RestoreStdio()
- def RedirectStdio(self, filename):
+ def RedirectStdio(self, filename=None):
"""Redirect sys.stdout and sys.stderr to a file or a popup window."""
if filename:
_sys.stdout = _sys.stderr = open(filename, 'a')
return _core.GetAccelFromString(*args, **kwargs)
#---------------------------------------------------------------------------
+class VisualAttributes(object):
+ """struct containing all the visual attributes of a control"""
+ def __repr__(self):
+ return "<%s.%s; proxy of C++ wxVisualAttributes instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
+ def __init__(self, *args, **kwargs):
+ """
+ __init__() -> VisualAttributes
+
+ struct containing all the visual attributes of a control
+ """
+ newobj = _core.new_VisualAttributes(*args, **kwargs)
+ self.this = newobj.this
+ self.thisown = 1
+ del newobj.thisown
+ def __del__(self, destroy=_core.delete_VisualAttributes):
+ """__del__()"""
+ try:
+ if self.thisown: destroy(self)
+ except: pass
+
+ font = property(_core.VisualAttributes_font_get, _core.VisualAttributes_font_set)
+ colFg = property(_core.VisualAttributes_colFg_get, _core.VisualAttributes_colFg_set)
+ colBg = property(_core.VisualAttributes_colBg_get, _core.VisualAttributes_colBg_set)
+
+class VisualAttributesPtr(VisualAttributes):
+ def __init__(self, this):
+ self.this = this
+ if not hasattr(self,"thisown"): self.thisown = 0
+ self.__class__ = VisualAttributes
+_core.VisualAttributes_swigregister(VisualAttributesPtr)
+NullAcceleratorTable = cvar.NullAcceleratorTable
+PanelNameStr = cvar.PanelNameStr
+
+WINDOW_VARIANT_NORMAL = _core.WINDOW_VARIANT_NORMAL
+WINDOW_VARIANT_SMALL = _core.WINDOW_VARIANT_SMALL
+WINDOW_VARIANT_MINI = _core.WINDOW_VARIANT_MINI
+WINDOW_VARIANT_LARGE = _core.WINDOW_VARIANT_LARGE
+WINDOW_VARIANT_MAX = _core.WINDOW_VARIANT_MAX
class Window(EvtHandler):
"""
wx.Window is the base class for all windows and represents any visible
return "<%s.%s; proxy of C++ wxWindow instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,)
def __init__(self, *args, **kwargs):
"""
- __init__(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize,
- long style=0, String name=PanelNameStr) -> Window
+ __init__(Window parent, int id=-1, Point pos=DefaultPosition,
+ Size size=DefaultSize, long style=0, String name=PanelNameStr) -> Window
Construct and show a generic Window.
"""
def Create(*args, **kwargs):
"""
- Create(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize,
- long style=0, String name=PanelNameStr) -> bool
+ Create(Window parent, int id=-1, Point pos=DefaultPosition,
+ Size size=DefaultSize, long style=0, String name=PanelNameStr) -> bool
Create the GUI part of the Window for 2-phase creation mode.
"""
"""
GetLabel() -> String
- Generic way of getting a label from any window, for identification
- purposes. The interpretation of this function differs from class to
- class. For frames and dialogs, the value returned is the title. For
- buttons or static text controls, it is the button text. This function
- can be useful for meta-programs (such as testing tools or
- special-needs access programs) which need to identify windows by name.
+ Generic way of getting a label from any window, for
+ identification purposes. The interpretation of this function
+ differs from class to class. For frames and dialogs, the value
+ returned is the title. For buttons or static text controls, it is
+ the button text. This function can be useful for meta-programs
+ such as testing tools or special-needs access programs)which
+ need to identify windows by name.
"""
return _core.Window_GetLabel(*args, **kwargs)
"""
SetName(String name)
- Sets the window's name. The window name is used for ressource setting
- in X, it is not the same as the window title/label
+ Sets the window's name. The window name is used for ressource
+ setting in X, it is not the same as the window title/label
"""
return _core.Window_SetName(*args, **kwargs)
"""
GetName() -> String
- Returns the window's name. This name is not guaranteed to be unique;
- it is up to the programmer to supply an appropriate name in the window
- constructor or via wx.Window.SetName.
+ Returns the windows name. This name is not guaranteed to be
+ unique; it is up to the programmer to supply an appropriate name
+ in the window constructor or via wx.Window.SetName.
"""
return _core.Window_GetName(*args, **kwargs)
+ def SetWindowVariant(*args, **kwargs):
+ """
+ SetWindowVariant(int variant)
+
+ Sets the variant of the window/font size to use for this window,
+ if the platform supports variants, for example, wxMac. Variant values are:
+
+ wx.WINDOW_VARIANT_NORMAL Normal size
+ wx.WINDOW_VARIANT_SMALL Smaller size (about 25 % smaller than normal)
+ wx.WINDOW_VARIANT_MINI Mini size (about 33 % smaller than normal)
+ wx.WINDOW_VARIANT_LARGE Large size (about 25 % larger than normal)
+
+ """
+ return _core.Window_SetWindowVariant(*args, **kwargs)
+
+ def GetWindowVariant(*args, **kwargs):
+ """GetWindowVariant() -> int"""
+ return _core.Window_GetWindowVariant(*args, **kwargs)
+
def SetId(*args, **kwargs):
"""
SetId(int winid)
"""
return _core.Window_FitInside(*args, **kwargs)
- def SetSizeHints(*args, **kwargs):
+ def SetSizeHints(*args):
"""
SetSizeHints(int minW, int minH, int maxW=-1, int maxH=-1, int incW=-1,
int incH=-1)
+ SetSizeHints(Size minSize, Size maxSize=DefaultSize, Size incSize=DefaultSize)
Allows specification of minimum and maximum window sizes, and window
size increments. If a pair of values is not set (or set to -1), the
will not be able to size the window outside the given bounds. The
resizing increments are only significant under Motif or Xt.
"""
- return _core.Window_SetSizeHints(*args, **kwargs)
+ return _core.Window_SetSizeHints(*args)
- def SetVirtualSizeHints(*args, **kwargs):
+ def SetVirtualSizeHints(*args):
"""
SetVirtualSizeHints(int minW, int minH, int maxW=-1, int maxH=-1)
+ SetVirtualSizeHints(Size minSize, Size maxSize=DefaultSize)
Allows specification of minimum and maximum virtual window sizes. If a
pair of values is not set (or set to -1), the default values will be
used. If this function is called, the user will not be able to size
the virtual area of the window outside the given bounds.
"""
- return _core.Window_SetVirtualSizeHints(*args, **kwargs)
+ return _core.Window_SetVirtualSizeHints(*args)
def GetMinWidth(*args, **kwargs):
"""GetMinWidth() -> int"""
"""GetMaxSize() -> Size"""
return _core.Window_GetMaxSize(*args, **kwargs)
+ def GetMinSize(*args, **kwargs):
+ """GetMinSize() -> Size"""
+ return _core.Window_GetMinSize(*args, **kwargs)
+
def SetVirtualSize(*args, **kwargs):
"""
SetVirtualSize(Size size)
"""
return _core.Window_GetValidator(*args, **kwargs)
+ def Validate(*args, **kwargs):
+ """
+ Validate() -> bool
+
+ Validates the current values of the child controls using their
+ validators. If the window has wx.WS_EX_VALIDATE_RECURSIVELY
+ extra style flag set, the method will also call Validate() of all
+ child windows. Returns false if any of the validations failed.
+ """
+ return _core.Window_Validate(*args, **kwargs)
+
+ def TransferDataToWindow(*args, **kwargs):
+ """
+ TransferDataToWindow() -> bool
+
+ Transfers values to child controls from data areas specified by
+ their validators. If the window has wx.WS_EX_VALIDATE_RECURSIVELY
+ extra style flag set, the method will also call
+ TransferDataToWindow() of all child windows.
+ """
+ return _core.Window_TransferDataToWindow(*args, **kwargs)
+
+ def TransferDataFromWindow(*args, **kwargs):
+ """
+ TransferDataFromWindow() -> bool
+
+ Transfers values from child controls to data areas specified by
+ their validators. Returns false if a transfer failed. If the
+ window has wx.WS_EX_VALIDATE_RECURSIVELY extra style flag set, the
+ method will also call TransferDataFromWindow() of all child
+ windows.
+ """
+ return _core.Window_TransferDataFromWindow(*args, **kwargs)
+
+ def InitDialog(*args, **kwargs):
+ """
+ InitDialog()
+
+ Sends an EVT_INIT_DIALOG event, whose handler usually transfers
+ data to the dialog via validators.
+ """
+ return _core.Window_InitDialog(*args, **kwargs)
+
def SetAcceleratorTable(*args, **kwargs):
"""
SetAcceleratorTable(AcceleratorTable accel)
"""
Freeze()
- Freezes the window or, in other words, prevents any updates from
- taking place on screen, the window is not redrawn at all. Thaw must be
- called to reenable window redrawing.
+ Freezes the window or, in other words, prevents any updates from taking place
+ on screen, the window is not redrawn at all. Thaw must be called to reenable
+ window redrawing. Calls to Freeze/Thaw may be nested, with the actual Thaw
+ being delayed until all the nesting has been undone.
This method is useful for visual appearance optimization (for example,
it is a good idea to use it before inserting large amount of text into
"""
Thaw()
- Reenables window updating after a previous call to Freeze.
+ Reenables window updating after a previous call to Freeze. Calls to
+ Freeze/Thaw may be nested, so Thaw must be called the same number of times
+ that Freeze was before the window will be updated.
"""
return _core.Window_Thaw(*args, **kwargs)
"""
return _core.Window_IsExposedPoint(*args, **kwargs)
- def isExposedRect(*args, **kwargs):
+ def IsExposedRect(*args, **kwargs):
"""
- isExposedRect(Rect rect) -> bool
+ IsExposedRect(Rect rect) -> bool
Returns true if the given point or rectangle area has been exposed
since the last repaint. Call this in an paint event handler to
optimize redrawing by only redrawing those areas, which have been
exposed.
"""
- return _core.Window_isExposedRect(*args, **kwargs)
+ return _core.Window_IsExposedRect(*args, **kwargs)
+ def GetDefaultAttributes(*args, **kwargs):
+ """
+ GetDefaultAttributes() -> VisualAttributes
+
+ Get the default attributes for an instance of this class. This
+ is useful if you want to use the same font or colour in your own
+ control as in a standard control -- which is a much better idea
+ than hard coding specific colours or fonts which might look
+ completely out of place on the users system, especially if it
+ uses themes.
+ """
+ return _core.Window_GetDefaultAttributes(*args, **kwargs)
+
+ def GetClassDefaultAttributes(*args, **kwargs):
+ """
+ GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
+
+ Get the default attributes for this class. This is useful if
+ you want to use the same font or colour in your own control as
+ in a standard control -- which is a much better idea than hard
+ coding specific colours or fonts which might look completely out
+ of place on the users system, especially if it uses themes.
+
+ The variant parameter is only relevant under Mac currently and is
+ ignore under other platforms. Under Mac, it will change the size of the
+ returned font. See SetWindowVariant for more about this.
+ """
+ return _core.Window_GetClassDefaultAttributes(*args, **kwargs)
+
+ GetClassDefaultAttributes = staticmethod(GetClassDefaultAttributes)
def SetBackgroundColour(*args, **kwargs):
"""
SetBackgroundColour(Colour colour) -> bool
"""
return _core.Window_SetBackgroundColour(*args, **kwargs)
+ def SetDefaultBackgroundColour(*args, **kwargs):
+ """SetDefaultBackgroundColour(Colour colour)"""
+ return _core.Window_SetDefaultBackgroundColour(*args, **kwargs)
+
def SetForegroundColour(*args, **kwargs):
"""
SetForegroundColour(Colour colour) -> bool
"""
return _core.Window_SetForegroundColour(*args, **kwargs)
+ def SetDefaultForegroundColour(*args, **kwargs):
+ """SetDefaultForegroundColour(Colour colour)"""
+ return _core.Window_SetDefaultForegroundColour(*args, **kwargs)
+
def GetBackgroundColour(*args, **kwargs):
"""
GetBackgroundColour() -> Colour
"""
return _core.Window_SetFont(*args, **kwargs)
+ def SetDefaultFont(*args, **kwargs):
+ """SetDefaultFont(Font font)"""
+ return _core.Window_SetDefaultFont(*args, **kwargs)
+
def GetFont(*args, **kwargs):
"""
GetFont() -> Font
- Returns a reference to the font for this window.
+ Returns the default font used for this window.
"""
return _core.Window_GetFont(*args, **kwargs)
if not hasattr(self,"thisown"): self.thisown = 0
self.__class__ = Window
_core.Window_swigregister(WindowPtr)
-NullAcceleratorTable = cvar.NullAcceleratorTable
-PanelNameStr = cvar.PanelNameStr
def PreWindow(*args, **kwargs):
"""
"""
return _core.Window_GetCapture(*args, **kwargs)
+def Window_GetClassDefaultAttributes(*args, **kwargs):
+ """
+ Window_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
+
+ Get the default attributes for this class. This is useful if
+ you want to use the same font or colour in your own control as
+ in a standard control -- which is a much better idea than hard
+ coding specific colours or fonts which might look completely out
+ of place on the users system, especially if it uses themes.
+
+ The variant parameter is only relevant under Mac currently and is
+ ignore under other platforms. Under Mac, it will change the size of the
+ returned font. See SetWindowVariant for more about this.
+ """
+ return _core.Window_GetClassDefaultAttributes(*args, **kwargs)
+
def DLG_PNT(win, point_or_x, y=None):
"""
Convenience function for converting a Point or (x,y) in
return _core.FindWindowByLabel(*args, **kwargs)
def Window_FromHWND(*args, **kwargs):
- """Window_FromHWND(unsigned long hWnd) -> Window"""
+ """Window_FromHWND(Window parent, unsigned long _hWnd) -> Window"""
return _core.Window_FromHWND(*args, **kwargs)
#---------------------------------------------------------------------------
Command(CommandEvent event)
Simulates the effect of the user issuing a command to the
- item. See wxCommandEvent.
+ item. See wx.CommandEvent.
"""
return _core.Control_Command(*args, **kwargs)
"""
return _core.Control_SetLabel(*args, **kwargs)
+ def GetClassDefaultAttributes(*args, **kwargs):
+ """
+ GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
+
+ Get the default attributes for this class. This is useful if
+ you want to use the same font or colour in your own control as
+ in a standard control -- which is a much better idea than hard
+ coding specific colours or fonts which might look completely out
+ of place on the users system, especially if it uses themes.
+
+ The variant parameter is only relevant under Mac currently and is
+ ignore under other platforms. Under Mac, it will change the size of the
+ returned font. See SetWindowVariant for more about this.
+ """
+ return _core.Control_GetClassDefaultAttributes(*args, **kwargs)
+
+ GetClassDefaultAttributes = staticmethod(GetClassDefaultAttributes)
class ControlPtr(Control):
def __init__(self, this):
val.thisown = 1
return val
+def Control_GetClassDefaultAttributes(*args, **kwargs):
+ """
+ Control_GetClassDefaultAttributes(int variant=WINDOW_VARIANT_NORMAL) -> VisualAttributes
+
+ Get the default attributes for this class. This is useful if
+ you want to use the same font or colour in your own control as
+ in a standard control -- which is a much better idea than hard
+ coding specific colours or fonts which might look completely out
+ of place on the users system, especially if it uses themes.
+
+ The variant parameter is only relevant under Mac currently and is
+ ignore under other platforms. Under Mac, it will change the size of the
+ returned font. See SetWindowVariant for more about this.
+ """
+ return _core.Control_GetClassDefaultAttributes(*args, **kwargs)
+
#---------------------------------------------------------------------------
class ItemContainer(object):
"""GetProportion() -> int"""
return _core.SizerItem_GetProportion(*args, **kwargs)
+ SetOption = SetProportion
+ GetOption = GetProportion
def SetFlag(*args, **kwargs):
"""SetFlag(int flag)"""
return _core.SizerItem_SetFlag(*args, **kwargs)
except NameError:
__builtins__.True = 1==1
__builtins__.False = 1==0
+ def bool(value): return not not value
+ __builtins__.bool = bool
class FutureCall:
"""
- A convenience class for wxTimer, that calls the given callable
+ A convenience class for wx.Timer, that calls the given callable
object once after the given amount of milliseconds, passing any
positional or keyword args. The return value of the callable is
availbale after it has been run with the GetResult method.
self.callable = callable
self.SetArgs(*args, **kwargs)
self.runCount = 0
+ self.running = False
self.hasRun = False
self.result = None
self.timer = None
self.Stop()
self.timer = wx.PyTimer(self.Notify)
self.timer.Start(self.millis, wx.TIMER_ONE_SHOT)
+ self.running = True
Restart = Start
"""
if self.callable and getattr(self.callable, 'im_self', True):
self.runCount += 1
+ self.running = False
self.result = self.callable(*self.args, **self.kwargs)
self.hasRun = True
- wx.CallAfter(self.Stop)
+ if not self.running:
+ # if it wasn't restarted, then cleanup
+ wx.CallAfter(self.Stop)
#----------------------------------------------------------------------------