ID_HELP = _core_.ID_HELP
ID_PRINT = _core_.ID_PRINT
ID_PRINT_SETUP = _core_.ID_PRINT_SETUP
+ID_PAGE_SETUP = _core_.ID_PAGE_SETUP
ID_PREVIEW = _core_.ID_PREVIEW
ID_ABOUT = _core_.ID_ABOUT
ID_HELP_CONTENTS = _core_.ID_HELP_CONTENTS
ID_HELP_COMMANDS = _core_.ID_HELP_COMMANDS
ID_HELP_PROCEDURES = _core_.ID_HELP_PROCEDURES
ID_HELP_CONTEXT = _core_.ID_HELP_CONTEXT
+ID_HELP_INDEX = _core_.ID_HELP_INDEX
+ID_HELP_SEARCH = _core_.ID_HELP_SEARCH
ID_CLOSE_ALL = _core_.ID_CLOSE_ALL
ID_PREFERENCES = _core_.ID_PREFERENCES
ID_CUT = _core_.ID_CUT
"""
return _core_.Size_DecTo(*args, **kwargs)
+ def Scale(*args, **kwargs):
+ """
+ Scale(self, float xscale, float yscale)
+
+ Scales the dimensions of this object by the given factors.
+ """
+ return _core_.Size_Scale(*args, **kwargs)
+
def Set(*args, **kwargs):
"""
Set(self, int w, int h)
"""
return _core_.Rect_Inside(*args, **kwargs)
+ def InsideRect(*args, **kwargs):
+ """
+ InsideRect(self, Rect rect) -> bool
+
+ Returns ``True`` if the given rectangle is completely inside this
+ rectangle or touches its boundary.
+ """
+ return _core_.Rect_InsideRect(*args, **kwargs)
+
def Intersects(*args, **kwargs):
"""
Intersects(self, Rect rect) -> bool
return _core_.Image_SetAlphaData(*args, **kwargs)
def GetAlphaBuffer(*args, **kwargs):
- """GetAlphaBuffer(self) -> PyObject"""
+ """
+ GetAlphaBuffer(self) -> PyObject
+
+ Returns a writable Python buffer object that is pointing at the Alpha
+ data buffer inside the wx.Image. You need to ensure that you do not
+ use this buffer object after the image has been destroyed.
+ """
return _core_.Image_GetAlphaBuffer(*args, **kwargs)
def SetAlphaBuffer(*args, **kwargs):
- """SetAlphaBuffer(self, buffer alpha)"""
+ """
+ SetAlphaBuffer(self, buffer alpha)
+
+ Sets the internal image alpha pointer to point at a Python buffer
+ object. This can save making an extra copy of the data but you must
+ ensure that the buffer object lives as long as the wx.Image does.
+ """
return _core_.Image_SetAlphaBuffer(*args, **kwargs)
def SetMaskColour(*args, **kwargs):
"""
return _core_.Image_HSVtoRGB(*args, **kwargs)
+
+def _ImageFromBuffer(*args, **kwargs):
+ """_ImageFromBuffer(int width, int height, buffer data, buffer alpha=None) -> Image"""
+ return _core_._ImageFromBuffer(*args, **kwargs)
+def ImageFromBuffer(width, height, dataBuffer, alphaBuffer=None):
+ """
+ Creates a `wx.Image` from the data in dataBuffer. The dataBuffer
+ parameter must be a Python object that implements the buffer interface, or
+ is convertable to a buffer object, such as a string, array, etc. The
+ dataBuffer object is expected to contain a series of RGB bytes and be
+ width*height*3 bytes long. A buffer object can optionally be supplied for
+ the image's alpha channel data, and it is expected to be width*height
+ bytes long.
+
+ The wx.Image will be created with its data and alpha pointers initialized
+ to the memory address pointed to by the buffer objects, thus saving the
+ time needed to copy the image data from the buffer object to the wx.Image.
+ While this has advantages, it also has the shoot-yourself-in-the-foot
+ risks associated with sharing a C pointer between two objects.
+
+ To help alleviate the risk a reference to the data and alpha buffer
+ objects are kept with the wx.Image, so that they won't get deleted until
+ after the wx.Image is deleted. However please be aware that it is not
+ guaranteed that an object won't move its memory buffer to a new location
+ when it needs to resize its contents. If that happens then the wx.Image
+ will end up referring to an invalid memory location and could cause the
+ application to crash. Therefore care should be taken to not manipulate
+ the objects used for the data and alpha buffers in a way that would cause
+ them to change size.
+ """
+ if not isinstance(dataBuffer, buffer):
+ dataBuffer = buffer(dataBuffer)
+ if alphaBuffer is not None and not isinstance(alphaBuffer, buffer):
+ alphaBuffer = buffer(alphaBuffer)
+ image = _core_._ImageFromBuffer(width, height, dataBuffer, alphaBuffer)
+ image._buffer = dataBuffer
+ image._alpha = alphaBuffer
+ return image
+
def InitAllImageHandlers():
"""
The former functionality of InitAllImageHanders is now done internal to
wxEVT_ICONIZE = _core_.wxEVT_ICONIZE
wxEVT_MAXIMIZE = _core_.wxEVT_MAXIMIZE
wxEVT_MOUSE_CAPTURE_CHANGED = _core_.wxEVT_MOUSE_CAPTURE_CHANGED
+wxEVT_MOUSE_CAPTURE_LOST = _core_.wxEVT_MOUSE_CAPTURE_LOST
wxEVT_PAINT = _core_.wxEVT_PAINT
wxEVT_ERASE_BACKGROUND = _core_.wxEVT_ERASE_BACKGROUND
wxEVT_NC_PAINT = _core_.wxEVT_NC_PAINT
EVT_WINDOW_DESTROY = wx.PyEventBinder( wxEVT_DESTROY )
EVT_SET_CURSOR = wx.PyEventBinder( wxEVT_SET_CURSOR )
EVT_MOUSE_CAPTURE_CHANGED = wx.PyEventBinder( wxEVT_MOUSE_CAPTURE_CHANGED )
+EVT_MOUSE_CAPTURE_LOST = wx.PyEventBinder( wxEVT_MOUSE_CAPTURE_LOST )
EVT_LEFT_DOWN = wx.PyEventBinder( wxEVT_LEFT_DOWN )
EVT_LEFT_UP = wx.PyEventBinder( wxEVT_LEFT_UP )
#---------------------------------------------------------------------------
+class MouseCaptureLostEvent(Event):
+ """
+ A mouse capture lost event is sent to a window that obtained mouse
+ capture, which was subsequently loss due to "external" event, for
+ example when a dialog box is shown or if another application captures
+ the mouse.
+
+ If this happens, this event is sent to all windows that are on the
+ capture stack (i.e. a window that called `wx.Window.CaptureMouse`, but
+ didn't call `wx.Window.ReleaseMouse` yet). The event is *not* sent
+ if the capture changes because of a call to CaptureMouse or
+ ReleaseMouse.
+
+ This event is currently emitted under Windows only.
+
+ """
+ thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
+ __repr__ = _swig_repr
+ def __init__(self, *args, **kwargs):
+ """
+ __init__(self, int winid=0) -> MouseCaptureLostEvent
+
+ A mouse capture lost event is sent to a window that obtained mouse
+ capture, which was subsequently loss due to "external" event, for
+ example when a dialog box is shown or if another application captures
+ the mouse.
+
+ If this happens, this event is sent to all windows that are on the
+ capture stack (i.e. a window that called `wx.Window.CaptureMouse`, but
+ didn't call `wx.Window.ReleaseMouse` yet). The event is *not* sent
+ if the capture changes because of a call to CaptureMouse or
+ ReleaseMouse.
+
+ This event is currently emitted under Windows only.
+
+ """
+ _core_.MouseCaptureLostEvent_swiginit(self,_core_.new_MouseCaptureLostEvent(*args, **kwargs))
+_core_.MouseCaptureLostEvent_swigregister(MouseCaptureLostEvent)
+
+#---------------------------------------------------------------------------
+
class DisplayChangedEvent(Event):
"""
An EVT_DISPLAY_CHANGED event is sent to all windows when the display
return _core_.PyApp_GetComCtl32Version(*args, **kwargs)
GetComCtl32Version = staticmethod(GetComCtl32Version)
+ def DisplayAvailable(*args, **kwargs):
+ """
+ DisplayAvailable() -> bool
+
+ Tests if it is possible to create a GUI in the current environment.
+ This will mean different things on the different platforms.
+
+ * On X Windows systems this function will return ``False`` if it is
+ not able to open a connection to the X display, which can happen
+ if $DISPLAY is not set, or is not set correctly.
+
+ * On Mac OS X a ``False`` return value will mean that wx is not
+ able to access the window manager, which can happen if logged in
+ remotely or if running from the normal version of python instead
+ of the framework version, (i.e., pythonw.)
+
+ * On MS Windows...
+
+ """
+ return _core_.PyApp_DisplayAvailable(*args, **kwargs)
+
+ DisplayAvailable = staticmethod(DisplayAvailable)
_core_.PyApp_swigregister(PyApp)
def PyApp_IsMainLoopRunning(*args):
"""
return _core_.PyApp_GetComCtl32Version(*args)
+def PyApp_DisplayAvailable(*args):
+ """
+ PyApp_DisplayAvailable() -> bool
+
+ Tests if it is possible to create a GUI in the current environment.
+ This will mean different things on the different platforms.
+
+ * On X Windows systems this function will return ``False`` if it is
+ not able to open a connection to the X display, which can happen
+ if $DISPLAY is not set, or is not set correctly.
+
+ * On Mac OS X a ``False`` return value will mean that wx is not
+ able to access the window manager, which can happen if logged in
+ remotely or if running from the normal version of python instead
+ of the framework version, (i.e., pythonw.)
+
+ * On MS Windows...
+
+ """
+ return _core_.PyApp_DisplayAvailable(*args)
+
#---------------------------------------------------------------------------
#----------------------------------------------------------------------
_defRedirect = (wx.Platform == '__WXMSW__' or wx.Platform == '__WXMAC__')
-
+
class App(wx.PyApp):
"""
The ``wx.App`` class represents the application and is used to:
initialization to ensure that the system, toolkit and
wxWidgets are fully initialized.
"""
+
wx.PyApp.__init__(self)
- if wx.Platform == "__WXMAC__":
- try:
- import MacOS
- if not MacOS.WMAvailable():
- print """\
-This program needs access to the screen. Please run with 'pythonw',
-not 'python', and only when you are logged in on the main display of
-your Mac."""
- _sys.exit(1)
- except SystemExit:
- raise
- except:
- pass
+ # make sure we can create a GUI
+ if not self.DisplayAvailable():
+
+ if wx.Platform == "__WXMAC__":
+ msg = """This program needs access to the screen.
+Please run with 'pythonw', not 'python', and only when you are logged
+in on the main display of your Mac."""
+
+ elif wx.Platform == "__WXGTK__":
+ msg ="Unable to access the X Display, is $DISPLAY set properly?"
+
+ else:
+ msg = "Unable to create GUI"
+ # TODO: more description is needed for wxMSW...
+ raise SystemExit(msg)
+
# This has to be done before OnInit
self.SetUseBestVisual(useBestVisual)
"""
return _core_.Window_AcceptsFocusFromKeyboard(*args, **kwargs)
- def GetDefaultItem(*args, **kwargs):
- """
- GetDefaultItem(self) -> Window
-
- Get the default child of this parent, i.e. the one which is activated
- by pressing <Enter> such as the OK button on a wx.Dialog.
- """
- return _core_.Window_GetDefaultItem(*args, **kwargs)
-
- def SetDefaultItem(*args, **kwargs):
- """
- SetDefaultItem(self, Window child) -> Window
-
- Set this child as default, return the old default.
- """
- return _core_.Window_SetDefaultItem(*args, **kwargs)
-
- def SetTmpDefaultItem(*args, **kwargs):
- """
- SetTmpDefaultItem(self, Window win)
-
- Set this child as temporary default
- """
- return _core_.Window_SetTmpDefaultItem(*args, **kwargs)
-
- def GetTmpDefaultItem(*args, **kwargs):
- """
- GetTmpDefaultItem(self) -> Window
-
- Return the temporary default item, which can be None.
- """
- return _core_.Window_GetTmpDefaultItem(*args, **kwargs)
-
def Navigate(*args, **kwargs):
"""
Navigate(self, int flags=NavigationKeyEvent.IsForward) -> bool
mouse and when the mouse is released the capture returns to the window
which had had captured it previously and it is only really released if
there were no previous window. In particular, this means that you must
- release the mouse as many times as you capture it.
+ release the mouse as many times as you capture it, unless the window
+ receives the `wx.MouseCaptureLostEvent` event.
+
+ Any application which captures the mouse in the beginning of some
+ operation *must* handle `wx.MouseCaptureLostEvent` and cancel this
+ operation when it receives the event. The event handler must not
+ recapture mouse.
"""
return _core_.Window_CaptureMouse(*args, **kwargs)
"""
return _core_.Window_PopupMenu(*args, **kwargs)
+ def HasMultiplePages(*args, **kwargs):
+ """HasMultiplePages(self) -> bool"""
+ return _core_.Window_HasMultiplePages(*args, **kwargs)
+
def GetHandle(*args, **kwargs):
"""
GetHandle(self) -> long
"""
return _core_.Window_ShouldInheritColours(*args, **kwargs)
+ def CanSetTransparent(*args, **kwargs):
+ """
+ CanSetTransparent(self) -> bool
+
+ Returns ``True`` if the platform supports setting the transparency for
+ this window. Note that this method will err on the side of caution,
+ so it is possible that this will return ``False`` when it is in fact
+ possible to set the transparency.
+
+ NOTE: On X-windows systems the X server must have the composite
+ extension loaded, and there must be a composite manager program (such
+ as xcompmgr) running.
+ """
+ return _core_.Window_CanSetTransparent(*args, **kwargs)
+
+ def SetTransparent(*args, **kwargs):
+ """
+ SetTransparent(self, byte alpha) -> bool
+
+ Attempt to set the transparency of this window to the ``alpha`` value,
+ returns True on success. The ``alpha`` value is an integer in the
+ range of 0 to 255, where 0 is fully transparent and 255 is fully
+ opaque.
+ """
+ return _core_.Window_SetTransparent(*args, **kwargs)
+
def PostCreate(self, pre):
"""
Phase 3 of the 2-phase create <wink!>
"""Detach(self)"""
return _core_.MenuBar_Detach(*args, **kwargs)
+ def UpdateMenus(*args, **kwargs):
+ """UpdateMenus(self)"""
+ return _core_.MenuBar_UpdateMenus(*args, **kwargs)
+
def SetAutoWindowMenu(*args, **kwargs):
"""SetAutoWindowMenu(bool enable)"""
return _core_.MenuBar_SetAutoWindowMenu(*args, **kwargs)
"""
return _core_.Control_Create(*args, **kwargs)
+ def GetAlignment(*args, **kwargs):
+ """
+ GetAlignment(self) -> int
+
+ Get the control alignment (left/right/centre, top/bottom/centre)
+ """
+ return _core_.Control_GetAlignment(*args, **kwargs)
+
+ def GetLabelText(*args, **kwargs):
+ """
+ GetLabelText(self) -> String
+
+ Get just the text of the label, without mnemonic characters ('&')
+ """
+ return _core_.Control_GetLabelText(*args, **kwargs)
+
def Command(*args, **kwargs):
"""
Command(self, CommandEvent event)
class __DocFilter:
"""
A filter for epydoc that only allows non-Ptr classes and
- fucntions, in order to reduce the clutter in the API docs.
+ functions, in order to reduce the clutter in the API docs.
"""
def __init__(self, globals):
self._globals = globals
def __call__(self, name):
import types
obj = self._globals.get(name, None)
+
+ # only document classes and function
if type(obj) not in [type, types.ClassType, types.FunctionType, types.BuiltinFunctionType]:
return False
+
+ # skip other things that are private or will be documented as part of somethign else
if name.startswith('_') or name.startswith('EVT') or name.endswith('_swigregister') or name.endswith('Ptr') :
return False
+
+ # skip functions that are duplicates of static functions in a class
+ if name.find('_') != -1:
+ cls = self._globals.get(name.split('_')[0], None)
+ methname = name.split('_')[1]
+ if hasattr(cls, methname) and type(getattr(cls, methname)) is types.FunctionType:
+ return False
+
return True
#----------------------------------------------------------------------------