Table Of Contents

Previous topic

Label

Next topic

RulerCtrlEvent

This Page

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


class_hierarchy Inheritance Diagram

Inheritance diagram for class RulerCtrl

Inheritance diagram of RulerCtrl


appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


super_classes Known Superclasses

PyPanel


method_summary Methods Summary

__init__ Default class constructor.
AddIndicator Adds an indicator to RulerCtrl. You should pass a unique id and a starting
CheckStyle Adjust the RulerCtrl style accordingly to borders, units, etc...
Draw Actually draws the whole RulerCtrl.
DrawOnParent Actually draws the thin line over the drawing parent window.
FindLinearTickSizes Used internally.
GetBounds Returns the RulerCtrl bounds (its client rectangle).
GetDrawingParent Returns the window to which RulerCtrl draws a thin line over.
GetFormat Returns the format used to display values in RulerCtrl.
GetIndicator Returns the indicator located at the mouse position mousePos (if any).
GetTimeFormat Returns the time format.
Invalidate Invalidates the ticks calculations.
LabelMajor Sets whether the major ticks should be labeled or not.
LabelMinor Sets whether the minor ticks should be labeled or not.
LabelString Used internally.
OfflimitsPixels Used internally.
OnEraseBackground Handles the EVT_ERASE_BACKGROUND event for RulerCtrl.
OnMouseEvents Handles the EVT_MOUSE_EVENTS event for RulerCtrl.
OnPaint Handles the EVT_PAINT event for RulerCtrl.
OnSize Handles the EVT_SIZE event for RulerCtrl.
SetBackgroundColour Sets the RulerCtrl background colour.
SetBounds Sets the bounds for RulerCtrl (its client rectangle).
SetDrawingParent Sets the window to which RulerCtrl draws a thin line over.
SetFlip Sets whether the orientation of the tick marks should be reversed.
SetFonts Sets the fonts for minor and major tick labels.
SetFormat Sets the format for RulerCtrl.
SetIndicatorColour Sets the indicator colour.
SetIndicatorValue Sets the indicator value.
SetLabelColour Sets the labels colour.
SetLabelEdges Sets whether the edge values should always be displayed or not.
SetLog Sets whether RulerCtrl should have a logarithmic scale or not.
SetOrientation Sets the RulerCtrl orientation.
SetRange Sets the RulerCtrl range.
SetSpacing Sets the RulerCtrl spacing between labels.
SetTickPenColour Sets the pen colour to draw the ticks.
SetTimeFormat Sets the time format.
SetUnits Sets the units that should be displayed beside the labels.
Tick Ticks a particular position.
TickMajor Sets whether the major ticks should be ticked or not.
TickMinor Sets whether the minor ticks should be ticked or not.
Update Updates all the ticks calculations.

api Class API



class RulerCtrl(PyPanel)

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.


Methods



__init__(self, parent, id=-1, pos=DefaultPosition, size=DefaultSize, style=STATIC_BORDER, orient=HORIZONTAL)

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 HORIZONTAL of VERTICAL .


AddIndicator(self, id, value)

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(self)

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



Draw(self, dc)

Actually draws the whole RulerCtrl.

Parameters:dc – an instance of DC.


DrawOnParent(self, indicator)

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



FindLinearTickSizes(self, UPP)

Used internally.



GetBounds(self)

Returns the RulerCtrl bounds (its client rectangle).



GetDrawingParent(self)

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



GetFormat(self)

Returns the format used to display values in RulerCtrl.

See also

RulerCtrl.SetFormat for a list of possible formats.



GetIndicator(self, mousePos)

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

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


GetTimeFormat(self)

Returns the time format.



Invalidate(self)

Invalidates the ticks calculations.



LabelMajor(self, label=True)

Sets whether the major ticks should be labeled or not.

Parameters:labelTrue to label major ticks, False otherwise.


LabelMinor(self, label=True)

Sets whether the minor ticks should be labeled or not.

Parameters:labelTrue to label minor ticks, False otherwise.


LabelString(self, d, major=None)

Used internally.



OfflimitsPixels(self, start, end)

Used internally.



OnEraseBackground(self, event)

Handles the EVT_ERASE_BACKGROUND event for RulerCtrl.

Parameters:event – a EraseEvent event to be processed.

Note

This method is intentionally empty to reduce flicker.



OnMouseEvents(self, event)

Handles the EVT_MOUSE_EVENTS event for RulerCtrl.

Parameters:event – a MouseEvent event to be processed.


OnPaint(self, event)

Handles the EVT_PAINT event for RulerCtrl.

Parameters:event – a PaintEvent event to be processed.


OnSize(self, event)

Handles the EVT_SIZE event for RulerCtrl.

Parameters:event – a SizeEvent event to be processed.


SetBackgroundColour(self, colour)

Sets the RulerCtrl background colour.

Parameters:colour – an instance of Colour.

Note

Overridden from PyPanel.



SetBounds(self, left, top, right, bottom)

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(self, dparent)

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

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


SetFlip(self, flip=True)

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

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


SetFonts(self, minorFont, majorFont)

Sets the fonts for minor and major tick labels.

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


SetFormat(self, format)

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(self, id, colour=None)

Sets the indicator colour.

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

Note

This method requires PIL to change the image palette.



SetIndicatorValue(self, sendEvent=True)

Sets the indicator value.

Parameters:sendEventTrue to send a RulerCtrlEvent, False otherwise.


SetLabelColour(self, colour=BLACK)

Sets the labels colour.

Parameters:colour – a valid Colour object.


SetLabelEdges(self, labelEdges=True)

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

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


SetLog(self, log=True)

Sets whether RulerCtrl should have a logarithmic scale or not.

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


SetOrientation(self, orient=None)

Sets the RulerCtrl orientation.

Parameters:orient – can be HORIZONTAL or VERTICAL .


SetRange(self, minVal, maxVal)

Sets the RulerCtrl range.

Parameters:


SetSpacing(self, spacing)

Sets the RulerCtrl spacing between labels.

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


SetTickPenColour(self, colour=BLACK)

Sets the pen colour to draw the ticks.

Parameters:colour – a valid Colour object.


SetTimeFormat(self, format=TimeFormat)

Sets the time format.

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


SetUnits(self, units)

Sets the units that should be displayed beside the labels.

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


Tick(self, dc, pos, d, major)

Ticks a particular position.

Parameters:
  • dc – an instance of 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(self, tick=True)

Sets whether the major ticks should be ticked or not.

Parameters:tickTrue to show major ticks, False otherwise.


TickMinor(self, tick=True)

Sets whether the minor ticks should be ticked or not.

Parameters:tickTrue to show minor ticks, False otherwise.


Update(self, dc)

Updates all the ticks calculations.

Parameters:dc – an instance of DC.