wx.xrc.XmlResourceHandler¶
SizerXmlHandler is a class for resource handlers capable of creating a wx.Sizer object from an XML
node.
wx.xrc.XmlResourceHandler is an abstract base class for resource handlers capable of creating a control from an XML
node.
See XML Based Resource System for details.
See also
Class Hierarchy¶
Known Subclasses¶
SizerXmlHandler
Methods Summary¶
Default constructor. |
|
Add a style flag (e.g. |
|
Add styles common to all Window-derived classes. |
|
Returns |
|
Creates children. |
|
Helper function. |
|
Creates a resource from a node. |
|
Creates an object (menu, dialog, control, …) from an |
|
Called from CreateResource after variables were filled. |
|
Creates an animation (see wx.adv.Animation) from the filename specified in param. |
|
Gets a bitmap. |
|
Gets a bitmap bundle. |
|
Gets a bool flag (1, t, yes, on, |
|
After CreateResource has been called this will return the class name of the |
|
Gets colour in HTML syntax (#``RRGGBB``). |
|
Returns the current file system. |
|
Gets a dimension (may be in dialog units). |
|
Gets a direction. |
|
Gets a float value from the parameter. |
|
Gets a font. |
|
Returns the |
|
Returns an icon. |
|
Returns an icon bundle. |
|
Creates an image list from the param markup data. |
|
After CreateResource has been called this will return the instance that the |
|
Gets the integer value from the parameter. |
|
Returns the resource name. |
|
After CreateResource has been called this will return the |
|
Gets the first child of the given node or |
|
Gets node content from |
|
Gets the next sibling node related to the given node, possibly |
|
Gets the parent of the node given. |
|
Finds the node or returns |
|
Finds the parameter value or returns the empty string. |
|
After CreateResource has been called this will return the current item’s parent, if any. |
|
After CreateResource has been called this will return the item’s parent as a wx.Window. |
|
Gets the position (may be in dialog units). |
|
After CreateResource has been called this will return the current wx.xrc.XmlResource object. |
|
Gets the size (may be in dialog units). |
|
Gets style flags from text in form “flag | flag2| flag3 |…” Only understands flags added with |
|
Gets text from param and does some conversions |
|
Check to see if a parameter exists. |
|
Checks if the given node is an object node. |
|
Convenience function. |
|
Reports error in |
|
Like |
|
Sets the parent resource. |
|
Sets common window options. |
Properties Summary¶
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
|
See |
Class API¶
- class wx.xrc.XmlResourceHandler(Object)¶
Possible constructors:
XmlResourceHandler() -> None
SizerXmlHandler is a class for resource handlers capable of creating a Sizer object from an
XML
node.
Methods¶
- __init__(self)¶
Default constructor.
- Return type:
None
- AddStyle(self, name, value)¶
Add a style flag (e.g.
MB_DOCKABLE
) to the list of flags understood by this handler.- Parameters:
name (string)
value (int)
- Return type:
None
- AddWindowStyles(self)¶
Add styles common to all Window-derived classes.
- Return type:
None
- CanHandle(self, node)¶
Returns
True
if it understands this node and can create a resource from it,False
otherwise.- Parameters:
node (wx.xml.XmlNode)
- Return type:
bool
Note
You must not call any wx.xrc.XmlResourceHandler methods except
IsOfClass
from this method! The instance is not yet initialized with node data at the timeCanHandle
is called and it is only safe to operate on node directly or to callIsOfClass
.
- CreateChildren(self, parent, this_hnd_only=False)¶
Creates children.
- Parameters:
parent (wx.Object)
this_hnd_only (bool)
- Return type:
None
- CreateChildrenPrivately(self, parent, rootnode=None)¶
Helper function.
- Parameters:
parent (wx.Object)
rootnode (wx.xml.XmlNode)
- Return type:
None
- CreateResFromNode(self, node, parent, instance=None)¶
Creates a resource from a node.
- Parameters:
node (wx.xml.XmlNode)
parent (wx.Object)
instance (wx.Object)
- Return type:
- CreateResource(self, node, parent, instance)¶
Creates an object (menu, dialog, control, …) from an
XML
node.Should check for validity. parent is a higher-level object (usually window, dialog or panel) that is often necessary to create the resource.
If instance is not
None
it should not create a new instance via ‘new’ but should rather use this one, and call its Create method.- Parameters:
node (wx.xml.XmlNode)
parent (wx.Object)
instance (wx.Object)
- Return type:
- DoCreateResource(self)¶
Called from CreateResource after variables were filled.
- Return type:
- GetAnimation(self, param='animation', ctrl=None)¶
Creates an animation (see wx.adv.Animation) from the filename specified in param.
It is recommended to provide ctrl argument to this function (which is only available in wxWidgets 3.1.4 or later) to make sure that the created animation is compatible with the specified control, otherwise a wx.adv.Animation object compatible with the default wx.adv.AnimationCtrl implementation is created.
- Parameters:
param (string)
ctrl (wx.adv.AnimationCtrl)
- Return type:
- GetBitmap(self, *args, **kw)¶
-
GetBitmap (self, param=”bitmap”, defaultArtClient=ART_OTHER, size=DefaultSize)
Gets a bitmap.
GetBitmap (self, node, defaultArtClient=ART_OTHER, size=DefaultSize)
Gets a bitmap from an XmlNode.
- Parameters:
node (wx.xml.XmlNode)
defaultArtClient (wx.ArtClient)
size (wx.Size)
- Return type:
Added in version 2.9.1.
- GetBitmapBundle(self, *args, **kw)¶
-
GetBitmapBundle (self, param=”bitmap”, defaultArtClient=ART_OTHER, size=DefaultSize)
Gets a bitmap bundle.
- Parameters:
param (string)
defaultArtClient (wx.ArtClient)
size (wx.Size)
- Return type:
Added in version 4.1/wxWidgets-3.1.6.
GetBitmapBundle (self, node, defaultArtClient=ART_OTHER, size=DefaultSize)
Gets a bitmap bundle from the provided node.
- Parameters:
node (wx.xml.XmlNode)
defaultArtClient (wx.ArtClient)
size (wx.Size)
- Return type:
Added in version 4.1/wxWidgets-3.1.6.
- GetBool(self, param, defaultv=False)¶
Gets a bool flag (1, t, yes, on,
True
areTrue
, everything else isFalse
).- Parameters:
param (string)
defaultv (bool)
- Return type:
bool
- GetClass(self)¶
After CreateResource has been called this will return the class name of the
XML
resource node being processed.- Return type:
str
Added in version 2.9.5.
- GetColour(self, param, defaultColour=NullColour)¶
Gets colour in HTML syntax (#``RRGGBB``).
- GetCurFileSystem(self)¶
Returns the current file system.
- Return type:
- GetDimension(self, param, defaultv=0, windowToUse=0)¶
Gets a dimension (may be in dialog units).
- Parameters:
param (string)
defaultv (int)
windowToUse (wx.Window)
- Return type:
int
- GetDirection(self, param, dirDefault=LEFT)¶
Gets a direction.
If the given param is not present or has empty value, dirDefault is returned by default. Otherwise the value of the parameter is parsed and a warning is generated if it’s not one of
LEFT
,TOP
,RIGHT
orBOTTOM
.- Parameters:
param (string)
dirDefault (Direction)
- Return type:
Added in version 2.9.3.
- GetFloat(self, param, defaultv=0)¶
Gets a float value from the parameter.
- Parameters:
param (string)
defaultv (float)
- Return type:
float
- GetID(self)¶
Returns the
wx.xrc.XRCID
.- Return type:
int
- GetIcon(self, *args, **kw)¶
-
GetIcon (self, param=”icon”, defaultArtClient=ART_OTHER, size=DefaultSize)
Returns an icon.
GetIcon (self, node, defaultArtClient=ART_OTHER, size=DefaultSize)
Gets an icon from an XmlNode.
- Parameters:
node (wx.xml.XmlNode)
defaultArtClient (wx.ArtClient)
size (wx.Size)
- Return type:
Added in version 2.9.1.
- GetIconBundle(self, param, defaultArtClient=ART_OTHER)¶
Returns an icon bundle.
- Parameters:
param (string)
defaultArtClient (wx.ArtClient)
- Return type:
Added in version 2.9.0.
Note
Bundles can be loaded either with stock IDs or from files that contain more than one image (e.g. Windows icon files). If a file contains only single image, a bundle with only one icon will be created.
- GetImageList(self, param='imagelist')¶
Creates an image list from the param markup data.
- Parameters:
param (string)
- Return type:
- Returns:
The new instance of wx.ImageList or
None
if no data is found.
Added in version 2.9.1.
- GetInstance(self)¶
After CreateResource has been called this will return the instance that the
XML
resource content should be created upon, if it has already been created.If
None
then the handler should create the object itself.- Return type:
Added in version 2.9.5.
- GetLong(self, param, defaultv=0)¶
Gets the integer value from the parameter.
- Parameters:
param (string)
defaultv (long)
- Return type:
int
- GetName(self)¶
Returns the resource name.
- Return type:
str
- GetNode(self)¶
After CreateResource has been called this will return the
XML
node being processed.- Return type:
Added in version 2.9.5.
- GetNodeChildren(self, node)¶
Gets the first child of the given node or
None
.This method is safe to call with
None
argument, it just returnsNone
in this case.- Parameters:
node (wx.xml.XmlNode)
- Return type:
Added in version 4.1/wxWidgets-3.1.0.
- GetNodeContent(self, node)¶
Gets node content from
wx.xml.XML_ENTITY_NODE
.- Parameters:
node (wx.xml.XmlNode)
- Return type:
str
- GetNodeNext(self, node)¶
Gets the next sibling node related to the given node, possibly
None
.This method is safe to call with
None
argument, it just returnsNone
in this case.- Parameters:
node (wx.xml.XmlNode)
- Return type:
Added in version 4.1/wxWidgets-3.1.0.
- GetNodeParent(self, node)¶
Gets the parent of the node given.
This method is safe to call with
None
argument, it just returnsNone
in this case.- Parameters:
node (wx.xml.XmlNode)
- Return type:
Added in version 4.1/wxWidgets-3.1.0.
- GetParamNode(self, param)¶
Finds the node or returns
None
.- Parameters:
param (string)
- Return type:
- GetParamValue(self, *args, **kw)¶
-
GetParamValue (self, param)
Finds the parameter value or returns the empty string.
- Parameters:
param (string)
- Return type:
str
GetParamValue (self, node)
Returns the node parameter value.
- Parameters:
node (wx.xml.XmlNode)
- Return type:
str
Added in version 2.9.1.
- GetParent(self)¶
After CreateResource has been called this will return the current item’s parent, if any.
- Return type:
Added in version 2.9.5.
- GetParentAsWindow(self)¶
After CreateResource has been called this will return the item’s parent as a wx.Window.
- Return type:
Added in version 2.9.5.
- GetPosition(self, param='pos')¶
Gets the position (may be in dialog units).
- Parameters:
param (string)
- Return type:
- GetResource(self)¶
After CreateResource has been called this will return the current wx.xrc.XmlResource object.
- Return type:
Added in version 2.9.5.
- GetSize(self, param='size', windowToUse=0)¶
Gets the size (may be in dialog units).
- GetStyle(self, param='style', defaults=0)¶
Gets style flags from text in form “flag | flag2| flag3 |…” Only understands flags added with
AddStyle
.- Parameters:
param (string)
defaults (int)
- Return type:
int
- GetText(self, param, translate=True)¶
Gets text from param and does some conversions:
replaces \n, \r, \t by respective characters (according to C syntax)
replaces
$
byand
$$
by$
(needed for_File
toFile
translation because ofXML
syntax)calls GetTranslations (unless disabled in wx.xrc.XmlResource)
- Parameters:
param (string)
translate (bool)
- Return type:
str
- HasParam(self, param)¶
Check to see if a parameter exists.
- Parameters:
param (string)
- Return type:
bool
- IsObjectNode(self, node)¶
Checks if the given node is an object node.
Object nodes are those named “object” or “object_ref”.
- Parameters:
node (wx.xml.XmlNode)
- Return type:
bool
Added in version 4.1/wxWidgets-3.1.0.
- IsOfClass(self, node, classname)¶
Convenience function.
Returns
True
if the node has a property class equal to classname, e.g. object class=”wxDialog”.- Parameters:
node (wx.xml.XmlNode)
classname (string)
- Return type:
bool
- ReportError(self, *args, **kw)¶
-
ReportError (self, context, message)
Reports error in
XRC
resources to the user.See
wx.xrc.XmlResource.ReportError
for more information.- Parameters:
context (wx.xml.XmlNode)
message (string)
- Return type:
None
Added in version 2.9.0.
ReportError (self, message)
Like
ReportError
, but uses the node of currently processed object (m_node) as the context.- Parameters:
message (string)
- Return type:
None
Added in version 2.9.0.
- ReportParamError(self, param, message)¶
Like
ReportError
, but uses the node of parameter param of the currently processed object as the context.This is convenience function for reporting errors in particular parameters.
- Parameters:
param (string)
message (string)
- Return type:
None
Added in version 2.9.0.
- SetParentResource(self, res)¶
Sets the parent resource.
- Parameters:
res (wx.xrc.XmlResource)
- Return type:
None
Properties¶
- Animation¶
See
GetAnimation
- BitmapBundle¶
See
GetBitmapBundle
- CurFileSystem¶
See
GetCurFileSystem
- ImageList¶
See
GetImageList
- Instance¶
See
GetInstance
- ParentAsWindow¶
- Position¶
See
GetPosition
- Resource¶
See
GetResource