1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
|
.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2018 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. module:: wx.lib.agw.rulerctrl
.. currentmodule:: wx.lib.agw.rulerctrl
.. highlight:: python
.. _wx.lib.agw.rulerctrl:
==========================================================================================================================================
|phoenix_title| **wx.lib.agw.rulerctrl**
==========================================================================================================================================
:class:`~wx.lib.agw.rulerctrl.RulerCtrl` implements a ruler window that can be placed on top, bottom, left or right
to any wxPython widget.
Description
===========
:class:`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:`RulerCtrl` has the following characteristics:
- Can be horizontal or vertical;
- 4 built-in formats: integer, real, time and linearDB formats;
- Units (as ``cm``, ``dB``, ``inches``) can be displayed together with the label values;
- Possibility to add a number of "paragraph indicators", small arrows that point at
the current indicator position;
- Customizable background colour, tick colour, label colour;
- Possibility to flip the ruler (i.e. changing the tick alignment);
- Changing individually the indicator colour (requires PIL at the moment);
- Different window borders are supported (``wx.STATIC_BORDER``, ``wx.SUNKEN_BORDER``,
``wx.DOUBLE_BORDER``, ``wx.NO_BORDER``, ``wx.RAISED_BORDER``, ``wx.SIMPLE_BORDER``);
- Logarithmic scale available;
- Possibility to draw a thin line over a selected window when moving an indicator,
which emulates the text editors software.
And a lot more. See the demo for a review of the functionalities.
Usage
=====
Usage example::
import wx
import wx.lib.agw.rulerctrl as RC
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "RulerCtrl Demo")
panel = wx.Panel(self)
text = wx.TextCtrl(panel, -1, "Hello World! wxPython rules", style=wx.TE_MULTILINE)
ruler1 = RC.RulerCtrl(panel, -1, orient=wx.HORIZONTAL, style=wx.SUNKEN_BORDER)
ruler2 = RC.RulerCtrl(panel, -1, orient=wx.VERTICAL, style=wx.SUNKEN_BORDER)
mainsizer = wx.BoxSizer(wx.HORIZONTAL)
leftsizer = wx.BoxSizer(wx.VERTICAL)
bottomleftsizer = wx.BoxSizer(wx.HORIZONTAL)
topsizer = wx.BoxSizer(wx.HORIZONTAL)
leftsizer.Add((20, 20), 0, wx.ADJUST_MINSIZE, 0)
topsizer.Add((39, 0), 0, wx.ADJUST_MINSIZE, 0)
topsizer.Add(ruler1, 1, wx.EXPAND, 0)
leftsizer.Add(topsizer, 0, wx.EXPAND, 0)
bottomleftsizer.Add((10, 0))
bottomleftsizer.Add(ruler2, 0, wx.EXPAND, 0)
bottomleftsizer.Add(text, 1, wx.EXPAND, 0)
leftsizer.Add(bottomleftsizer, 1, wx.EXPAND, 0)
mainsizer.Add(leftsizer, 3, wx.EXPAND, 0)
panel.SetSizer(mainsizer)
# our normal wxApp-derived class, as usual
app = wx.App(0)
frame = MyFrame(None)
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()
Events
======
:class:`RulerCtrl` implements the following events related to indicators:
- ``EVT_INDICATOR_CHANGING``: the user is about to change the position of one indicator;
- ``EVT_INDICATOR_CHANGED``: the user has changed the position of one indicator.
Supported Platforms
===================
:class:`RulerCtrl` has been tested on the following platforms:
* Windows (Windows XP);
* Linux Ubuntu (Dapper 6.06)
Window Styles
=============
`No particular window styles are available for this class.`
Events Processing
=================
This class processes the following events:
========================== ==================================================
Event Name Description
========================== ==================================================
``EVT_INDICATOR_CHANGED`` The user has changed the indicator value.
``EVT_INDICATOR_CHANGING`` The user is about to change the indicator value.
========================== ==================================================
License And Version
===================
:class:`RulerCtrl` is distributed under the wxPython license.
Latest Revision: Andrea Gavana @ 19 Dec 2012, 21.00 GMT
Version 0.4
|function_summary| Functions Summary
====================================
================================================================================ ================================================================================
:func:`~wx.lib.agw.rulerctrl.ConvertPILToWX` Converts a PIL image into a :class:`wx.Image`.
:func:`~wx.lib.agw.rulerctrl.ConvertWXToPIL` Converts a :class:`wx.Image` into a PIL image.
:func:`~wx.lib.agw.rulerctrl.GetIndicatorBitmap` Returns the image indicator as a :class:`wx.Bitmap`.
:func:`~wx.lib.agw.rulerctrl.GetIndicatorData` Returns the image indicator as a decompressed stream of characters.
:func:`~wx.lib.agw.rulerctrl.GetIndicatorImage` Returns the image indicator as a :class:`wx.Image`.
:func:`~wx.lib.agw.rulerctrl.MakePalette` Creates a palette to be applied on an image based on input colour.
================================================================================ ================================================================================
|
|class_summary| Classes Summary
===============================
================================================================================ ================================================================================
:ref:`~wx.lib.agw.rulerctrl.Indicator` This class holds all the information about a single indicator inside :class:`RulerCtrl`.
:ref:`~wx.lib.agw.rulerctrl.Label` Auxilary class. Just holds information about a label in :class:`RulerCtrl`.
:ref:`~wx.lib.agw.rulerctrl.RulerCtrl` :class:`RulerCtrl` implements a ruler window that can be placed on top, bottom, left or right
:ref:`~wx.lib.agw.rulerctrl.RulerCtrlEvent` Represent details of the events that the :class:`RulerCtrl` object sends.
================================================================================ ================================================================================
|
.. toctree::
:maxdepth: 1
:hidden:
wx.lib.agw.rulerctrl.Indicator
wx.lib.agw.rulerctrl.Label
wx.lib.agw.rulerctrl.RulerCtrl
wx.lib.agw.rulerctrl.RulerCtrlEvent
Functions
------------
.. function:: ConvertPILToWX(pil, alpha=True)
Converts a PIL image into a :class:`wx.Image`.
:param `pil`: a PIL image;
:param `alpha`: ``True`` if the image contains alpha transparency, ``False``
otherwise.
:note: Requires PIL (Python Imaging Library), which can be downloaded from
http://www.pythonware.com/products/pil/
.. function:: ConvertWXToPIL(bmp)
Converts a :class:`wx.Image` into a PIL image.
:param `bmp`: an instance of :class:`wx.Image`.
:note: Requires PIL (Python Imaging Library), which can be downloaded from
http://www.pythonware.com/products/pil/
.. function:: GetIndicatorBitmap()
Returns the image indicator as a :class:`wx.Bitmap`.
.. function:: GetIndicatorData()
Returns the image indicator as a decompressed stream of characters.
.. function:: GetIndicatorImage()
Returns the image indicator as a :class:`wx.Image`.
.. function:: MakePalette(tr, tg, tb)
Creates a palette to be applied on an image based on input colour.
:param `tr`: the red intensity of the input colour;
:param `tg`: the green intensity of the input colour;
:param `tb`: the blue intensity of the input colour.
|