AGW Logo

agw_title RulerCtrl

RulerCtrl implements a ruler window that can be placed on top, bottom, left or right to any wxPython widget. It is somewhat similar to the rulers you can find in text editors software, though not so powerful.

hierarchy Inheritance Diagram

Inheritance diagram for: RulerCtrl

Inheritance diagram of RulerCtrl


appearance Control Appearance


RulerCtrl

RulerCtrl


method_summary Methods Summary

__init__Default class constructor.
AddIndicatorAdds an indicator to RulerCtrl. You should pass a unique id and a starting
CheckStyleAdjust the RulerCtrl style accordingly to borders, units, etc...
DrawActually draws the whole RulerCtrl.
DrawOnParentActually draws the thin line over the drawing parent window.
FindLinearTickSizesUsed internally.
GetBoundsReturns the RulerCtrl bounds (its client rectangle).
GetDrawingParentReturns the window to which RulerCtrl draws a thin line over.
GetFormatReturns the format used to display values in RulerCtrl.
GetIndicatorReturns the indicator located at the mouse position mousePos (if any).
GetTimeFormatReturns the time format.
InvalidateInvalidates the ticks calculations.
LabelMajorSets whether the major ticks should be labeled or not.
LabelMinorSets whether the minor ticks should be labeled or not.
LabelStringUsed internally.
OfflimitsPixelsUsed internally.
OnEraseBackgroundHandles the wx.EVT_ERASE_BACKGROUND event for RulerCtrl.
OnMouseEventsHandles the wx.EVT_MOUSE_EVENTS event for RulerCtrl.
OnPaintHandles the wx.EVT_PAINT event for RulerCtrl.
OnSizeHandles the wx.EVT_SIZE event for RulerCtrl.
SetBackgroundColourSets the RulerCtrl background colour.
SetBoundsSets the bounds for RulerCtrl (its client rectangle).
SetDrawingParentSets the window to which RulerCtrl draws a thin line over.
SetFlipSets whether the orientation of the tick marks should be reversed.
SetFontsSets the fonts for minor and major tick labels.
SetFormatSets the format for RulerCtrl.
SetIndicatorColourSets the indicator colour.
SetIndicatorValueSets the indicator value.
SetLabelColourSets the labels colour.
SetLabelEdgesSets whether the edge values should always be displayed or not.
SetLogSets whether RulerCtrl should have a logarithmic scale or not.
SetOrientationSets the RulerCtrl orientation.
SetRangeSets the RulerCtrl range.
SetSpacingSets the RulerCtrl spacing between labels.
SetTickPenColourSets the pen colour to draw the ticks.
SetTimeFormatSets the time format.
SetUnitsSets the units that should be displayed beside the labels.
TickTicks a particular position.
TickMajorSets whether the major ticks should be ticked or not.
TickMinorSets whether the minor ticks should be ticked or not.
UpdateUpdates all the ticks calculations.

API Class API

class RulerCtrl(wx.PyPanel)[source]

RulerCtrl implements a ruler window that can be placed on top, bottom, left or right to any wxPython widget. It is somewhat similar to the rulers you can find in text editors software, though not so powerful.



__init__(parent, id=-1, pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.STATIC_BORDER, orient=wx.HORIZONTAL)[source]

Default class constructor.

Parameters:
  • parent – parent window. Must not be None;
  • id – window identifier. A value of -1 indicates a default value;
  • pos – the control position. A value of (-1, -1) indicates a default position, chosen by either the windowing system or wxPython, depending on platform;
  • size – the control size. A value of (-1, -1) indicates a default size, chosen by either the windowing system or wxPython, depending on platform;
  • style – the window style;
  • orient – sets the orientation of the RulerCtrl, and can be either wx.HORIZONTAL of wx.VERTICAL.


AddIndicator(id, value)[source]

Adds an indicator to RulerCtrl. You should pass a unique id and a starting value for the indicator.

Parameters:
  • id – the indicator identifier;
  • value – the indicator initial value.


CheckStyle()[source]

Adjust the RulerCtrl style accordingly to borders, units, etc...



Draw(dc)[source]

Actually draws the whole RulerCtrl.

Parameters:dc – an instance of wx.DC.


DrawOnParent(indicator)[source]

Actually draws the thin line over the drawing parent window.

Parameters:indicator – the current indicator, an instance of Indicator.

Note

This method is currently not available on wxMac as it uses wx.ScreenDC.



FindLinearTickSizes(UPP)[source]

Used internally.



GetBounds()[source]

Returns the RulerCtrl bounds (its client rectangle).



GetDrawingParent()[source]

Returns the window to which RulerCtrl draws a thin line over.



GetFormat()[source]

Returns the format used to display values in RulerCtrl.

See also

SetFormat for a list of possible formats.



GetIndicator(mousePos)[source]

Returns the indicator located at the mouse position mousePos (if any).

Parameters:mousePos – the mouse position, an instance of wx.Point.


GetTimeFormat()[source]

Returns the time format.



Invalidate()[source]

Invalidates the ticks calculations.



LabelMajor(label=True)[source]

Sets whether the major ticks should be labeled or not.

Parameters:labelTrue to label major ticks, False otherwise.


LabelMinor(label=True)[source]

Sets whether the minor ticks should be labeled or not.

Parameters:labelTrue to label minor ticks, False otherwise.


LabelString(d, major=None)[source]

Used internally.



OfflimitsPixels(start, end)[source]

Used internally.



OnEraseBackground(event)[source]

Handles the wx.EVT_ERASE_BACKGROUND event for RulerCtrl.

Parameters:event – a wx.EraseEvent event to be processed.

Note

This method is intentionally empty to reduce flicker.



OnMouseEvents(event)[source]

Handles the wx.EVT_MOUSE_EVENTS event for RulerCtrl.

Parameters:event – a wx.MouseEvent event to be processed.


OnPaint(event)[source]

Handles the wx.EVT_PAINT event for RulerCtrl.

Parameters:event – a wx.PaintEvent event to be processed.


OnSize(event)[source]

Handles the wx.EVT_SIZE event for RulerCtrl.

Parameters:event – a wx.SizeEvent event to be processed.


SetBackgroundColour(colour)[source]

Sets the RulerCtrl background colour.

Parameters:colour – an instance of wx.Colour.

Note

Overridden from wx.PyPanel.



SetBounds(left, top, right, bottom)[source]

Sets the bounds for RulerCtrl (its client rectangle).

Parameters:
  • left – the left corner of the client rectangle;
  • top – the top corner of the client rectangle;
  • right – the right corner of the client rectangle;
  • bottom – the bottom corner of the client rectangle.


SetDrawingParent(dparent)[source]

Sets the window to which RulerCtrl draws a thin line over.

Parameters:dparent – an instance of wx.Window, representing the window to which RulerCtrl draws a thin line over.


SetFlip(flip=True)[source]

Sets whether the orientation of the tick marks should be reversed.

Parameters:flipTrue to reverse the orientation of the tick marks, False otherwise.


SetFonts(minorFont, majorFont)[source]

Sets the fonts for minor and major tick labels.

Parameters:
  • minorFont – the font used to draw minor ticks, a valid wx.Font object;
  • majorFont – the font used to draw major ticks, a valid wx.Font object.



SetFormat(format)[source]

Sets the format for RulerCtrl.

Parameters:format – the format used to display values in RulerCtrl. This can be one of the following bits:


Format Value Description
IntFormat 1 Integer format
RealFormat 2 Real format
TimeFormat 3 Time format
LinearDBFormat 4 Linear DB format
HHMMSS_Format 5 HHMMSS format


SetIndicatorColour(id, colour=None)[source]

Sets the indicator colour.

Parameters:
  • id – the indicator identifier;
  • colour – a valid wx.Colour object.

Note

This method requires PIL to change the image palette.



SetIndicatorValue(sendEvent=True)[source]

Sets the indicator value.

Parameters:sendEventTrue to send a RulerCtrlEvent, False otherwise.


SetLabelColour(colour=wx.BLACK)[source]

Sets the labels colour.

Parameters:colour – a valid wx.Colour object.



SetLabelEdges(labelEdges=True)[source]

Sets whether the edge values should always be displayed or not.

Parameters:labelEdgesTrue to always display edge labels, False otherwise/


SetLog(log=True)[source]

Sets whether RulerCtrl should have a logarithmic scale or not.

Parameters:logTrue to use a logarithmic scake, False to use a linear one.


SetOrientation(orient=None)[source]

Sets the RulerCtrl orientation.

Parameters:orient – can be wx.HORIZONTAL or wx.VERTICAL.


SetRange(minVal, maxVal)[source]

Sets the RulerCtrl range.

Parameters:


SetSpacing(spacing)[source]

Sets the RulerCtrl spacing between labels.

Parameters:spacing – the spacing between labels, in pixels.


SetTickPenColour(colour=wx.BLACK)[source]

Sets the pen colour to draw the ticks.

Parameters:colour – a valid wx.Colour object.



SetTimeFormat(format=TimeFormat)[source]

Sets the time format.

Parameters:format – the format used to display time values.


SetUnits(units)[source]

Sets the units that should be displayed beside the labels.

Parameters:units – the units that should be displayed beside the labels.


Tick(dc, pos, d, major)[source]

Ticks a particular position.

Parameters:
  • dc – an instance of wx.DC;

  • pos – the label position;
  • d – the current label value;
  • majorTrue if it is a major ticks, False if it is a minor one.


TickMajor(tick=True)[source]

Sets whether the major ticks should be ticked or not.

Parameters:tickTrue to show major ticks, False otherwise.


TickMinor(tick=True)[source]

Sets whether the minor ticks should be ticked or not.

Parameters:tickTrue to show minor ticks, False otherwise.


Update(dc)[source]

Updates all the ticks calculations.

Parameters:dc – an instance of wx.DC.

Tree

Table Of Contents

Previous topic

Label

Next topic

RulerCtrlEvent