Phoenix Logo

phoenix_title wx.propgrid.SystemColourProperty

Has dropdown list of wxWidgets system colours.

Value used is of wx.propgrid.ColourPropertyValue type.


class_hierarchy Class Hierarchy

Inheritance diagram for class SystemColourProperty:

method_summary Methods Summary

__init__  
ColourToString Override in derived class to customize how colours are printed as strings.
DoSetAttribute Reimplement this member function to add special handling for attributes of this property.
GetColour Default is to use SystemSettings.GetColour(index).
GetCustomColourIndex Returns index of entry that triggers colour picker dialog (default is last).
GetVal  
IntToValue Converts integer (possibly a choice selection) into Variant value appropriate for this property.
OnCustomPaint Override to paint an image in front of the property value text or drop-down list item (but only if wx.propgrid.PGProperty.OnMeasureImage is overridden as well).
OnEvent Events received by editor widgets are processed here.
OnMeasureImage Returns size of the custom painted image in front of property.
OnSetValue This virtual function is called after m_value has been set.
QueryColourFromUser  
StringToValue Converts text into Variant value appropriate for this property.
ValueToString Converts property value into a text representation.

property_summary Properties Summary

CustomColourIndex See GetCustomColourIndex
Val See GetVal

api Class API



class wx.propgrid.SystemColourProperty(EnumProperty)

Possible constructors:

SystemColourProperty(label=PG_LABEL, name=PG_LABEL,
                     value=ColourPropertyValue())

Has dropdown list of wxWidgets system colours.


Methods



__init__(self, label=PG_LABEL, name=PG_LABEL, value=ColourPropertyValue())
Parameters:


ColourToString(self, col, index, argFlags=0)

Override in derived class to customize how colours are printed as strings.

Parameters:
  • col (wx.Colour) –
  • index (int) –
  • argFlags (int) –
Return type:

string



DoSetAttribute(self, name, value)

Reimplement this member function to add special handling for attributes of this property.

Parameters:
  • name (string) –
  • value (PGVariant) –
Return type:

bool

Returns:

Return False to have the attribute automatically stored in m_attributes. Default implementation simply does that and nothing else.

Note

To actually set property attribute values from the application, use wx.propgrid.PGProperty.SetAttribute instead.



GetColour(self, index)

Default is to use SystemSettings.GetColour(index).

Override to use custom colour tables etc.

Parameters:index (int) –
Return type:Colour


GetCustomColourIndex(self)

Returns index of entry that triggers colour picker dialog (default is last).

Return type:int


GetVal(self, pVariant=None)
Parameters:pVariant (PGVariant) –
Return type: wx.propgrid.ColourPropertyValue


IntToValue(self, variant, number, argFlags=0)

Converts integer (possibly a choice selection) into Variant value appropriate for this property.

Parameters:
  • variant (PGVariant) – On function entry this is the old value (should not be NullVariant in normal cases). Translated value must be assigned back to it.
  • number (int) – Integer to be translated into variant.
  • argFlags (int) – If wx.propgrid.PG_FULL_VALUE is set, returns complete, storable value instead of displayable one.
Return type:

bool

Returns:

Returns True if resulting Variant value was different.

Note

  • If property is not supposed to use choice or spinctrl or other editor with int-based value, it is not necessary to implement this method.
  • Default implementation simply assign given int to m_value.
  • If property uses choice control, and displays a dialog on some choice items, then it is preferred to display that dialog in IntToValue instead of OnEvent.
  • You might want to take into account that m_value is Mull variant if property value is unspecified (which is usually only case if you explicitly enabled that sort behaviour).


OnCustomPaint(self, dc, rect, paintdata)

Override to paint an image in front of the property value text or drop-down list item (but only if wx.propgrid.PGProperty.OnMeasureImage is overridden as well).

If property’s OnMeasureImage returns size that has height != 0 but less than row height ( < 0 has special meanings), wx.propgrid.PropertyGrid calls this method to draw a custom image in a limited area in front of the editor control or value text/graphics, and if control has drop-down list, then the image is drawn there as well (even in the case OnMeasureImage returned higher height than row height).

NOTE: Following applies when OnMeasureImage returns a “flexible” height ( using PG_FLEXIBLE_SIZE(W,H) macro), which implies variable height items: If rect.x is < 0, then this is a measure item call, which means that dc is invalid and only thing that should be done is to set paintdata.m_drawnHeight to the height of the image of item at index paintdata.m_choiceItem. This call may be done even as often as once every drop-down popup show.

Parameters:

Note

  • You can actually exceed rect width, but if you do so then paintdata.m_drawnWidth must be set to the full width drawn in pixels.
  • Due to technical reasons, rect’s height will be default even if custom height was reported during measure call.
  • Brush is guaranteed to be default background colour. It has been already used to clear the background of area being painted. It can be modified.
  • Pen is guaranteed to be 1-wide ‘black’ (or whatever is the proper colour) pen for drawing framing rectangle. It can be changed as well.

See also

ValueToString



OnEvent(self, propgrid, wnd_primary, event)

Events received by editor widgets are processed here.

Note that editor class usually processes most events. Some, such as button press events of TextCtrlAndButton class, can be handled here. Also, if custom handling for regular events is desired, then that can also be done (for example, wx.propgrid.SystemColourProperty custom handles wxEVT_CHOICE to display colour picker dialog when ‘custom’ selection is made).

If the event causes value to be changed, SetValueInEvent should be called to set the new value.

The parameter event is the associated wx.Event.

Parameters:

return True if any changes in value should be reported.

Return type:bool

Note

  • If property uses choice control, and displays a dialog on some choice items, then it is preferred to display that dialog in IntToValue instead of OnEvent.


OnMeasureImage(self, item)

Returns size of the custom painted image in front of property.

This method must be overridden to return non-default value if OnCustomPaint is to be called.

Parameters:item (int) – Normally -1, but can be an index to the property’s list of items.
Return type:Size

Note

  • Default behaviour is to return wx.Size, which means no image.
  • Default image width or height is indicated with dimension -1.
  • You can also return wx.propgrid.PG_DEFAULT_IMAGE_SIZE which equals :ref:`wx.Size`(-1, -1).


OnSetValue(self)

This virtual function is called after m_value has been set.

Note

  • If m_value was set to Null variant (ie. unspecified value), OnSetValue will not be called.
  • m_value may be of any variant type. Typically properties internally support only one variant type, and as such OnSetValue provides a good opportunity to convert supported values into internal type.
  • Default implementation does nothing.


QueryColourFromUser(self, variant)
Parameters:variant (PGVariant) –
Return type:bool


StringToValue(self, variant, text, argFlags=0)

Converts text into Variant value appropriate for this property.

Parameters:
  • variant (PGVariant) – On function entry this is the old value (should not be NullVariant in normal cases). Translated value must be assigned back to it.
  • text (string) – Text to be translated into variant.
  • argFlags (int) – If wx.propgrid.PG_FULL_VALUE is set, returns complete, storable value instead of displayable one (they may be different). If wx.propgrid.PG_COMPOSITE_FRAGMENT is set, text is interpreted as a part of composite property string value (as generated by ValueToString called with this same flag).
Return type:

bool

You might want to take into account that m_value is Null variant if property value is unspecified (which is usually only case if you explicitly enabled that sort behaviour).

Returns:Returns True if resulting Variant value was different.

Note

Default implementation converts semicolon delimited tokens into child values. Only works for properties with children.



ValueToString(self, value, argFlags=0)

Converts property value into a text representation.

Parameters:
  • value (PGVariant) – Value to be converted.
  • argFlags (int) – If 0 (default value), then displayed string is returned. If wx.propgrid.PG_FULL_VALUE is set, returns complete, storable string value instead of displayable. If wx.propgrid.PG_EDITABLE_VALUE is set, returns string value that must be editable in textctrl. If wx.propgrid.PG_COMPOSITE_FRAGMENT is set, returns text that is appropriate to display as a part of string property’s composite text representation.
Return type:

string

Note

Default implementation calls GenerateComposedValue .


Properties



CustomColourIndex

See GetCustomColourIndex



Val

See GetVal