KDE 4.5 PyKDE API Reference

- KDE's Python API

# KRuler Class Reference

`from PyKDE4.kdeui import *`

Inherits: QAbstractSlider → QWidget → QObject

## Detailed Description

A ruler widget.

The vertical ruler looks similar to this:

        meters                       inches

        ------   <--- end mark  ---> ------
            --                            -
            --   <---little mark--->     --
            --                            -
            --                          ---
           ---   <---medium mark          -
            --                           --
            --        tiny mark---->      -
            --                         ----
            --                            -
          ----   <-----big mark          --
            --                            -
          |>--   <--ruler pointer-->   |>--

There are tiny marks, little marks, medium marks, and big marks along the ruler.

To receive mouse clicks or mouse moves, the class has to be overloaded.

For performance reasons, the public methods don't call QWidget.repaint(). (Slots do, see documentation below.) All the changed settings will be painted once after leaving to the main event loop. For performance painting the slot methods should be used, they do a fast QWidget.repaint() call after changing the values. For setting multiple values like minValue(), maxValue(), offset() etc. using the public methods is recommended so the widget will be painted only once when entering the main event loop.

"KDE Ruler Widget"

A ruler widget.

Author:
  Jörg Habenicht

## Enumerations
MetricStyle | { Custom, Pixel, Inch, Millimetres, Centimetres, Metres }
## Methods
| __init__ (self, QWidget parent=0)
| __init__ (self, Qt::Orientation orient, QWidget parent=0, Qt::WFlags f=0)
| __init__ (self, Qt::Orientation orient, int widgetWidth, QWidget parent=0, Qt::WFlags f=0)
int | bigMarkDistance (self)
QString | endLabel (self)
int | endOffset (self)
int | length (self)
bool | lengthFixed (self)
int | littleMarkDistance (self)
int | maxValue (self)
int | mediumMarkDistance (self)
int | minValue (self)
int | offset (self)
| paintEvent (self, QPaintEvent a0)
float | pixelPerMark (self)
| setBigMarkDistance (self, int a0)
| setEndLabel (self, QString a0)
| setFrameStyle (self, int a0)
| setLength (self, int a0)
| setLengthFixed (self, bool fix)
| setLittleMarkDistance (self, int a0)
| setMaxValue (self, int a0)
| setMediumMarkDistance (self, int a0)
| setMinValue (self, int a0)
| setOffset (self, int offset)
| setPixelPerMark (self, float rate)
| setRulerMetricStyle (self, KRuler.MetricStyle a0)
| setShowBigMarks (self, bool a0)
| setShowEndLabel (self, bool a0)
| setShowEndMarks (self, bool a0)
| setShowLittleMarks (self, bool a0)
| setShowMediumMarks (self, bool a0)
| setShowPointer (self, bool a0)
| setShowTinyMarks (self, bool a0)
| setTinyMarkDistance (self, int a0)
bool | showBigMarks (self)
bool | showEndLabel (self)
bool | showEndMarks (self)
bool | showLittleMarks (self)
bool | showMediumMarks (self)
bool | showPointer (self)
bool | showTinyMarks (self)
| slideDown (self, int count=1)
| slideUp (self, int count=1)
| slotEndOffset (self, int a0)
| slotNewOffset (self, int a0)
| slotNewValue (self, int a0)
int | tinyMarkDistance (self)

## Method Documentation

__init__ | ( | self, |
|  | QWidget | parent=0
| ) |  |  |

Constructs a horizontal ruler.

__init__ | ( | self, |
|  | Qt::Orientation | orient,
|  | QWidget | parent=0,
|  | Qt::WFlags | f=0
| ) |  |  |

Constructs a ruler with orientation orient.

parent and f are passed to QFrame. The default look is a raised widget but may be changed with the inherited QFrame methods.

Parameters:

  | orient | Orientation of the ruler.
  | parent | Will be handed over to QFrame.
  | f | Will be handed over to QFrame.

__init__ | ( | self, |
|  | Qt::Orientation | orient,
|  | int | widgetWidth,
|  | QWidget | parent=0,
|  | Qt::WFlags | f=0
| ) |  |  |

Constructs a ruler with orientation orient and initial width widgetWidth.

The width sets the fixed width of the widget. This is useful if you want to draw the ruler bigger or smaller than the default size. Note: The size of the marks doesn't change. parent and f are passed to QFrame.

Parameters:

  | orient | Orientation of the ruler.
  | widgetWidth | Fixed width of the widget.
  | parent | Will be handed over to QFrame.
  | f | Will be handed over to QFrame.

int bigMarkDistance | ( |  | self ) |

Returns the distance between big marks.

QString endLabel | ( |  | self ) |

int endOffset | ( |  | self ) |

int length | ( |  | self ) |

bool lengthFixed | ( |  | self ) |

int littleMarkDistance | ( |  | self ) |

Returns the distance between little marks.

int maxValue | ( |  | self ) |

Returns the maximal value of the ruler pointer.

int mediumMarkDistance | ( |  | self ) |

int minValue | ( |  | self ) |

Returns the minimal value of the ruler pointer.

int offset | ( |  | self ) |

Returns the current ruler offset.

paintEvent | ( | self, |
|  | QPaintEvent | a0
| ) |  |  |

float pixelPerMark | ( |  | self ) |

Returns the number of pixels between two base marks.

setBigMarkDistance | ( | self, |
|  | int | a0
| ) |  |  |

Sets distance between big marks.

For English (inches) or metric styles it is twice the medium mark distance.

setEndLabel | ( | self, |
|  | QString | a0
| ) |  |  |

Sets the label this is drawn at the beginning of the visible part of the ruler to label

setFrameStyle | ( | self, |
|  | int | a0
| ) |  |  |

setLength | ( | self, |
|  | int | a0
| ) |  |  |

Sets the length of the ruler, i.e. the difference between the begin mark and the end mark of the ruler.

Same as (width() - offset())

when the length is not locked, it gets adjusted with the length of the widget.

setLengthFixed | ( | self, |
|  | bool | fix
| ) |  |  |

Locks the length of the ruler, i.e. the difference between the two end marks doesn't change when the widget is resized.

Parameters:

  | fix | fixes the length, if true

setLittleMarkDistance | ( | self, |
|  | int | a0
| ) |  |  |

Sets the distance between little marks.

The default value is 1 in the metric system and 2 in the English (inches) system.

setMaxValue | ( | self, |
|  | int | a0
| ) |  |  |

Sets the maximum value of the ruler pointer (default is 100).

This method calls update() so that the widget is painted after leaving to the main event loop.

setMediumMarkDistance | ( | self, |
|  | int | a0
| ) |  |  |

Sets the distance between medium marks.

For English (inches) styles it defaults to twice the little mark distance. For metric styles it defaults to five times the little mark distance.

setMinValue | ( | self, |
|  | int | a0
| ) |  |  |

Sets the minimal value of the ruler pointer (default is 0).

This method calls update() so that the widget is painted after leaving to the main event loop.

setOffset | ( | self, |
|  | int | offset
| ) |  |  |

Sets the ruler slide offset.

This is like slideup() or slidedown() with an absolute offset from the start of the ruler.

Parameters:

  | offset | Number of pixel to move the ruler up or left from the beginning

setPixelPerMark | ( | self, |
|  | float | rate
| ) |  |  |

Sets the number of pixels between two base marks.

Calling this method stretches or shrinks your ruler.

For pixel display ( MetricStyle) the value is 10.0 marks per pixel ;-) For English (inches) it is 9.0, and for centimetres ~2.835 -> 3.0 . If you want to magnify your part of display, you have to adjust the mark distance here. Notice: The double type is only supported to give the possibility of having some double values. It should be used with care. Using values below 10.0 shows visible jumps of markpositions (e.g. 2.345). Using whole numbers is highly recommended. To use int values use setPixelPerMark((int)your_int_value); default: 1 mark per 10 pixels

setRulerMetricStyle | ( | self, |
|  | KRuler.MetricStyle | a0
| ) |  |  |

Sets up the necessary tasks for the provided styles.

A convenience method.

setShowBigMarks | ( | self, |
|  | bool | a0
| ) |  |  |

Shows/hides big marks.

setShowEndLabel | ( | self, |
|  | bool | a0
| ) |  |  |

Show/hide number values of the end marks.

Default is false.

setShowEndMarks | ( | self, |
|  | bool | a0
| ) |  |  |

Shows/hides end marks.

setShowLittleMarks | ( | self, |
|  | bool | a0
| ) |  |  |

Shows/hides little marks.

setShowMediumMarks | ( | self, |
|  | bool | a0
| ) |  |  |

Shows/hides medium marks.

setShowPointer | ( | self, |
|  | bool | a0
| ) |  |  |

Shows/hides the pointer.

setShowTinyMarks | ( | self, |
|  | bool | a0
| ) |  |  |

Shows/hides tiny marks.

setTinyMarkDistance | ( | self, |
|  | int | a0
| ) |  |  |

Sets the distance between tiny marks.

This is mostly used in the English system (inches) with distance of 1.

bool showBigMarks | ( |  | self ) |

bool showEndLabel | ( |  | self ) |

bool showEndMarks | ( |  | self ) |

bool showLittleMarks | ( |  | self ) |

bool showMediumMarks | ( |  | self ) |

bool showPointer | ( |  | self ) |

bool showTinyMarks | ( |  | self ) |

slideDown | ( | self, |
|  | int | count=1
| ) |  |  |

Sets the number of pixels by which the ruler may slide down or right. The number of pixels moved is realive to the previous position. The Method makes sense for updating a ruler, which is working with a scrollbar.

This doesn't affect the position of the ruler pointer. Only the visible part of the ruler is moved.

Parameters:

  | count | Number of pixel moving up or left relative to the previous position

slideUp | ( | self, |
|  | int | count=1
| ) |  |  |

Sets the number of pixels by which the ruler may slide up or left. The number of pixels moved is realive to the previous position. The Method makes sense for updating a ruler, which is working with a scrollbar.

This doesn't affect the position of the ruler pointer. Only the visible part of the ruler is moved.

Parameters:

  | count | Number of pixel moving up or left relative to the previous position

slotEndOffset | ( | self, |
|  | int | a0
| ) |  |  |

slotNewOffset | ( | self, |
|  | int | a0
| ) |  |  |

Sets the ruler marks to a new position.

The pointer is NOT updated. QWidget.repaint() is called afterwards.

slotNewValue | ( | self, |
|  | int | a0
| ) |  |  |

Sets the pointer to a new position.

The offset is NOT updated. QWidget.repaint() is called afterwards.

int tinyMarkDistance | ( |  | self ) |

Returns the distance between tiny marks.

## Enumeration Documentation

MetricStyle

The types of units used.

Enumerator:

  Custom = 0 |
  Pixel |
  Inch |
  Millimetres |
  Centimetres |
  Metres |