Phoenix Logo

phoenix_title 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.


class_hierarchy Class Hierarchy

Inheritance diagram for class XmlResourceHandler:

sub_classes Known Subclasses

SizerXmlHandler


method_summary Methods Summary

__init__ Default constructor.
AddStyle Add a style flag (e.g.
AddWindowStyles Add styles common to all Window-derived classes.
CanHandle Returns True if it understands this node and can create a resource from it, False otherwise.
CreateChildren Creates children.
CreateChildrenPrivately Helper function.
CreateResFromNode Creates a resource from a node.
CreateResource Creates an object (menu, dialog, control, ...) from an XML node.
DoCreateResource Called from CreateResource after variables were filled.
GetAnimation Creates an animation (see wx.adv.Animation) from the filename specified in param.
GetBitmap Gets a bitmap.
GetBool Gets a bool flag (1, t, yes, on, True are True, everything else is False).
GetClass After CreateResource has been called this will return the class name of the XML resource node being processed.
GetColour Gets colour in HTML syntax (#``RRGGBB``).
GetCurFileSystem Returns the current file system.
GetDimension Gets a dimension (may be in dialog units).
GetDirection Gets a direction.
GetFloat Gets a float value from the parameter.
GetFont Gets a font.
GetID Returns the wx.xrc.XRCID.
GetIcon Returns an icon.
GetIconBundle Returns an icon bundle.
GetImageList Creates an image list from the param markup data.
GetInstance 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.
GetLong Gets the integer value from the parameter.
GetName Returns the resource name.
GetNode After CreateResource has been called this will return the XML node being processed.
GetNodeContent Gets node content from wx.xml.XML_ENTITY_NODE.
GetParamNode Finds the node or returns None.
GetParamValue Finds the parameter value or returns the empty string.
GetParent After CreateResource has been called this will return the current item’s parent, if any.
GetParentAsWindow After CreateResource has been called this will return the item’s parent as a wx.Window.
GetPosition Gets the position (may be in dialog units).
GetResource After CreateResource has been called this will return the current wx.xrc.XmlResource object.
GetSize Gets the size (may be in dialog units).
GetStyle Gets style flags from text in form “flag | flag2| flag3 |...” Only understands flags added with AddStyle .
GetText Gets text from param and does some conversions
HasParam Check to see if a parameter exists.
IsOfClass Convenience function.
ReportError Reports error in XRC resources to the user.
ReportParamError Like ReportError , but uses the node of parameter param of the currently processed object as the context.
SetParentResource Sets the parent resource.
SetupWindow Sets common window options.

api Class API



class wx.xrc.XmlResourceHandler(Object)

Possible constructors:

XmlResourceHandler()

SizerXmlHandler is a class for resource handlers capable of creating a Sizer object from an XML node.


Methods



__init__(self)

Default constructor.



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) –


AddWindowStyles(self)

Add styles common to all Window-derived classes.



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 time CanHandle is called and it is only safe to operate on node directly or to call IsOfClass .



CreateChildren(self, parent, this_hnd_only=False)

Creates children.

Parameters:
  • parent (wx.Object) –
  • this_hnd_only (bool) –


CreateChildrenPrivately(self, parent, rootnode=None)

Helper function.

Parameters:


CreateResFromNode(self, node, parent, instance=None)

Creates a resource from a node.

Parameters:
Return type:

wx.Object



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:
Return type:

wx.Object



DoCreateResource(self)

Called from CreateResource after variables were filled.

Return type: wx.Object


GetAnimation(self, param="animation")

Creates an animation (see wx.adv.Animation) from the filename specified in param.

Parameters:param (string) –
Return type: wx.adv.Animation


GetBitmap(self, *args, **kw)

overload Overloaded Implementations:



GetBitmap (self, param=”bitmap”, defaultArtClient=ART_OTHER, size=DefaultSize)

Gets a bitmap.

Parameters:
  • param (string) –
  • defaultArtClient (wx.ArtClient) –
  • size (wx.Size) –
Return type:

wx.Bitmap



GetBitmap (self, node, defaultArtClient=ART_OTHER, size=DefaultSize)

Gets a bitmap from an XmlNode.

Parameters:
Return type:

wx.Bitmap

New in version 2.9.1.





GetBool(self, param, defaultv=False)

Gets a bool flag (1, t, yes, on, True are True, everything else is False).

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:string

New in version 2.9.5.



GetColour(self, param, defaultColour=NullColour)

Gets colour in HTML syntax (#``RRGGBB``).

Parameters:
  • param (string) –
  • defaultColour (wx.Colour) –
Return type:

wx.Colour



GetCurFileSystem(self)

Returns the current file system.

Return type: wx.FileSystem


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:

wx.Coord



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 or BOTTOM .

Parameters:
  • param (string) –
  • dirDefault (Direction) –
Return type:

wx.DataObject.Direction

New 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



GetFont(self, param="font")

Gets a font.

Parameters:param (string) –
Return type: wx.Font


GetID(self)

Returns the wx.xrc.XRCID.

Return type:int


GetIcon(self, *args, **kw)

overload Overloaded Implementations:



GetIcon (self, param=”icon”, defaultArtClient=ART_OTHER, size=DefaultSize)

Returns an icon.

Parameters:
  • param (string) –
  • defaultArtClient (wx.ArtClient) –
  • size (wx.Size) –
Return type:

wx.Icon



GetIcon (self, node, defaultArtClient=ART_OTHER, size=DefaultSize)

Gets an icon from an XmlNode.

Parameters:
Return type:

wx.Icon

New in version 2.9.1.





GetIconBundle(self, param, defaultArtClient=ART_OTHER)

Returns an icon bundle.

Parameters:
  • param (string) –
  • defaultArtClient (wx.ArtClient) –
Return type:

wx.IconBundle

New 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: wx.ImageList
Returns:The new instance of wx.ImageList or None if no data is found.

New 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: wx.Object

New in version 2.9.5.



GetLong(self, param, defaultv=0)

Gets the integer value from the parameter.

Parameters:
  • param (string) –
  • defaultv (long) –
Return type:

long



GetName(self)

Returns the resource name.

Return type:string


GetNode(self)

After CreateResource has been called this will return the XML node being processed.

Return type: wx.xml.XmlNode

New in version 2.9.5.



GetNodeContent(self, node)

Gets node content from wx.xml.XML_ENTITY_NODE.

Parameters:node (wx.xml.XmlNode) –
Return type:string


GetParamNode(self, param)

Finds the node or returns None.

Parameters:param (string) –
Return type: wx.xml.XmlNode


GetParamValue(self, *args, **kw)

overload Overloaded Implementations:



GetParamValue (self, param)

Finds the parameter value or returns the empty string.

Parameters:param (string) –
Return type:string



GetParamValue (self, node)

Returns the node parameter value.

Parameters:node (wx.xml.XmlNode) –
Return type:string

New in version 2.9.1.





GetParent(self)

After CreateResource has been called this will return the current item’s parent, if any.

Return type: wx.Object

New 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: wx.Window

New in version 2.9.5.



GetPosition(self, param="pos")

Gets the position (may be in dialog units).

Parameters:param (string) –
Return type: wx.Point


GetResource(self)

After CreateResource has been called this will return the current wx.xrc.XmlResource object.

Return type: wx.xrc.XmlResource

New in version 2.9.5.



GetSize(self, param="size", windowToUse=0)

Gets the size (may be in dialog units).

Parameters:
  • param (string) –
  • windowToUse (wx.Window) –
Return type:

wx.Size



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 $ by and $$ by $ (needed for _File to File translation because of XML syntax)
  • calls GetTranslations (unless disabled in wx.xrc.XmlResource)
Parameters:
  • param (string) –
  • translate (bool) –
Return type:

string



HasParam(self, param)

Check to see if a parameter exists.

Parameters:param (string) –
Return type:bool


IsOfClass(self, node, classname)

Convenience function.

Returns True if the node has a property class equal to classname, e.g. object class=”wxDialog”.

Parameters:
Return type:

bool



ReportError(self, *args, **kw)

overload Overloaded Implementations:



ReportError (self, context, message)

Reports error in XRC resources to the user.

See wx.xrc.XmlResource.ReportError for more information.

Parameters:

New 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) –

New 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) –

New in version 2.9.0.



SetParentResource(self, res)

Sets the parent resource.

Parameters:res (wx.xrc.XmlResource) –


SetupWindow(self, wnd)

Sets common window options.

Parameters:wnd (wx.Window) –

Properties



Animation

See GetAnimation



Bitmap

See GetBitmap



Class

See GetClass



CurFileSystem

See GetCurFileSystem



Font

See GetFont



ID

See GetID



Icon

See GetIcon



ImageList

See GetImageList



Instance

See GetInstance



Name

See GetName



Node

See GetNode



Parent

See GetParent



ParentAsWindow

See GetParentAsWindow



Position

See GetPosition



Resource

See GetResource



Size

See GetSize



Style

See GetStyle