Welcome to qarbon 0.1.0 documentation
qarbon is ...
Helper functions to translate state to color.
Functions
getBgColorFromState | Returns the background color for the given state: |
getCSSColorFromState | Returns a CSS string representing the color for the given state. |
getColorFromState | Returns the background a foreground color for the given state: |
getFgColorFromState | Returns the foreground color for the given state: |
getStateColorMap | Returns the map used for color states. |
Returns the map used for color states.
dict<State, tuple<bg color(tuple<R (int), G (int), B (int)>, A (int)>), fg color(tuple<R (int), G (int), B (int), A (int)>)>>
Returns: | map of the state colors |
---|---|
Return type: | dict |
Returns the background a foreground color for the given state:
tuple<bg color(tuple<R (int), G (int), B (int)>, A (int)>), fg color(tuple<R (int), G (int), B (int), A (int)>)> :return: background a foreground color for the given state :rtype: tuple
Returns a CSS string representing the color for the given state.
Returns: | a CSS string representing the color for the given state |
---|---|
Return type: | str |
Global configuration.
qarbon namespace
Auto initialize Qt
Set preffered API if not is already loaded
Whether or not should be strict in choosing Qt API
Auto initialize Qt logging to python logging
Auto initialize Qarbon resources (icons)
Remove input hook (only valid for PyQt4)
Auto initialize Qt
Set preffered API if not is already loaded
Whether or not should be strict in choosing Qt API
Auto initialize Qt logging to python logging
Auto initialize Qarbon resources (icons)
Remove input hook (only valid for PyQt4)
Model core module.
Functions
Database | Helper to get the database corresponding to the given name. |
Device | Helper to get the device corresponding to the given name. |
Attribute | Helper to get the attribute corresponding to the given name. |
Classes
Quality | Quality enum. |
Access | Access enum. |
DisplayLevel | Display level enum. |
DataType | Data type enum. |
State | State enum. |
IScheme | Base scheme class. |
IDatabase | Base database class. |
IDevice | Base device class. |
IAttribute | Base attribute class. |
Bases: qarbon.node.Node
Base scheme class.
Plugins should provide an implementation of this class.
Bases: qarbon.node.Node
Base database class.
Plugins should provide an implementation of this class as a response to a get_database from their Scheme
Bases: qarbon.node.Node
Base device class.
Plugins should provide an implementation of this class as a response to a get_device from their Scheme
Bases: qarbon.node.Node
Base attribute class.
Plugins should provide an implementation of this class as a response to a get_attribute from their Scheme
Helper logging functions.
Functions
log | |
debug | |
info | |
warn | |
warning | |
error | |
exception | |
critical | |
fatal | |
initialize | Initializes logging. |
is_initialized | |
log_it | partial(func, *args, **keywords) - new function with partial application |
debug_it | partial(func, *args, **keywords) - new function with partial application |
info_it | partial(func, *args, **keywords) - new function with partial application |
warn_it | partial(func, *args, **keywords) - new function with partial application |
error_it | partial(func, *args, **keywords) - new function with partial application |
fatal_it | partial(func, *args, **keywords) - new function with partial application |
Initializes logging. Configures the Root logger with the given log_level. If file_name is given, a rotating log file handler is added. Otherwise, adds a default output stream handler with the given log_format.
Node module.
Classes
Node | Node class representing a node in a tree. |
Plugin extension manager.
Functions
get_plugins | |
get_plugin_info | |
IPlugin | Decorator that transforms the decorated class into a plugin point. |
Helper functions to access QAction.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.action import Action
from qarbon.qt.gui.icon import Icon
def onImageFileOpen():
fileName = QtGui.QFileDialog.getOpenFileName(None,
"Open Image", "/home/homer",
"Image Files (*.png *.jpg *.bmp)")
print (fileName)
app = Application()
window = QtGui.QMainWindow()
openImageAction = Action("Open &image...", parent=window,
icon=Icon("folder-open"),
shortcut=QtGui.QKeySequence.Open,
tooltip="open an existing image file",
triggered=onImageFileOpen)
menuBar = window.menuBar()
fileMenu = menuBar.addMenu("&File")
fileMenu.addAction(openImageAction)
window.show()
app.exec_()
|
Functions
Action | Create a new QAction. |
Create a new QAction.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.action import Action
from qarbon.qt.gui.icon import Icon
def onImageFileOpen():
fileName = QtGui.QFileDialog.getOpenFileName(None,
"Open Image", "/home/homer",
"Image Files (*.png *.jpg *.bmp)")
print (fileName)
app = Application()
window = QtGui.QMainWindow()
openImageAction = Action("Open &image...", parent=window,
icon=Icon("folder-open"),
shortcut=QtGui.QKeySequence.Open,
tooltip="open an existing image file",
triggered=onImageFileOpen)
menuBar = window.menuBar()
fileMenu = menuBar.addMenu("&File")
fileMenu.addAction(openImageAction)
window.show()
app.exec_()
|
Parameters: |
|
---|---|
Returns: | a customized QAction |
Return type: | QAction |
Helper functions to manage QApplication.
Most common use case:
1 2 3 4 5 6 7 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
app = Application()
label = QtGui.QLabel("Hello, world!")
label.show()
app.exec_()
|
The advantage here is you can call Application() anywhere on your program.
Functions
Application | Returns a QApplication. |
Returns a QApplication.
If the process has initialized before a QApplication it returns the existing instance, otherwise it creates a new one.
When a QApplication is created it takes argv into account. If argv is None (default), it take arguments from sys.argv.
If argv is given and a QApplication already exists, argv will have no effect.
Parameters: | argv – optional arguments to QApplication. If the QApplication is already initialized, argv will have no effect. |
---|
Example:
1 2 3 4 5 6 7 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
app = Application()
label = QtGui.QLabel("Hello, world!")
label.show()
app.exec_()
|
Parameters: | properties – currently unused |
---|---|
Returns: | the QApplication |
Return type: | QtGui.QApplication |
Multiple axis (axes) widget.
Classes
AxesWidget | A multiple axis widget. |
Bases: PyQt4.QtCore.QObject
This property contains the axis position
Access functions:
This property contains the axis limits
Access functions:
This property contains the axis state
Access functions:
This property contains the axis label
Access functions:
This property contains the axis steps
Access functions:
This property contains the axis current step size
Access functions:
This property contains the axis unit
Access functions:
Bases: qarbon.qt.gui.groupbox.GroupBox
A multiple axis widget.
Steps changed from the Axis model:
This property sets if the widget should update stauts bar with messages
Access functions:
A base model and a base tree item.
Classes
BaseTreeItem | A generic node |
BaseModel | The base class for all Qt models. |
BaseProxyModel | A base Qt filter & sort model |
Bases: object
A generic node
alias of str
The internal itemData object
Returns: | (object) object holding the data of this item |
---|
Adds a new child node
Parameters: | child – (BaseTreeItem) child to be added |
---|
Returns the child in the given row
Returns: | (BaseTreeItem) the child node for the given row |
---|
Returns the number of childs for this node
Returns: | (int) number of childs for this node |
---|
Returns the data of this node for the given index
Returns: | (object) the data for the given index |
---|
Sets the node data
Parameters: | data – (object) the data to be associated with this node |
---|
A base tree widget and toolbar.
Classes
BaseTreeWidget | A pure Qt tree widget implementing a tree with a navigation toolbar |
Bases: qarbon.qt.gui.baseview.BaseModelWidget
A pure Qt tree widget implementing a tree with a navigation toolbar
A base view widget and toolbar.
Classes
BaseModelWidget | A pure Qt widget designed to display a Qt view widget (QTreeView for example), envolved by optional toolbar and statusbar. |
BaseToolBar | |
FilterToolBar | Internal widget providing quick filter to be placed in a _QToolArea |
EditorToolBar | Internal widget to be placed in a _QToolArea providing buttons for |
SelectionToolBar | |
RefreshToolBar | |
PerspectiveToolBar |
Bases: PyQt4.QtGui.QToolBar
Bases: qarbon.qt.gui.baseview.BaseToolBar
Internal widget providing quick filter to be placed in a _QToolArea
Bases: qarbon.qt.gui.baseview.BaseToolBar
Internal widget to be placed in a _QToolArea providing buttons for moving, adding and removing items from a view based widget
Bases: qarbon.qt.gui.baseview.BaseToolBar
Bases: qarbon.qt.gui.baseview.BaseToolBar
Bases: qarbon.qt.gui.baseview.BaseToolBar
Bases: PyQt4.QtGui.QMainWindow
A pure Qt widget designed to display a Qt view widget (QTreeView for example), envolved by optional toolbar and statusbar. The Qt model associated with the internal Qt view widget should be a Framework4.GUI.Qt.Model.BaseModel
Helper functions to colors from state
Functions
getBgQColorFromState | Returns a background QColor from the given State. |
getFgQColorFromState | Returns a foreground QColor from the given State. |
getQColorFromState | Returns a tuple<background color (QColor), foreground color (QColor)> from the given State. |
getStateColorMap | Returns the map used for color states. |
Returns a tuple<background color (QColor), foreground color (QColor)> from the given State.
Parameters: | state (State) – the state |
---|---|
Returns: | a tuple of background a foreground color for the given state |
Return type: | tuple<QColor, QColor> |
A colapsable container widget with (optional) title.
Here is a simple example that shows how to create a GroupBox with some content inside:
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 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.icon import Icon
from qarbon.qt.gui.groupbox import GroupBox
app = Application()
panel = QtGui.QWidget()
layout = QtGui.QVBoxLayout()
panel.setLayout(layout)
gb = GroupBox()
layout.addWidget(gb)
gb.title = "Configuration"
gb.icon = Icon("applications-accessories")
content = QtGui.QWidget()
gb.setContent(content)
contentLayout = QtGui.QHBoxLayout()
content.setLayout(contentLayout)
label = QtGui.QLabel("File:")
edit = QtGui.QLineEdit()
button = QtGui.QPushButton(Icon("folder-open"), "Open a file...")
contentLayout.addWidget(label)
contentLayout.addWidget(edit)
contentLayout.addWidget(button)
panel.show()
app.exec_()
|
Classes
GroupBox | An expandable/collapsible container widget |
Bases: PyQt4.QtGui.QWidget
An expandable/collapsible container widget
Returns the contents widget
Returns: | the current content widget or None if no content is set |
---|---|
Return type: | QWidget |
Sets the content widget
Parameters: | qwidget (QWidget) – the content widget or None |
---|
Returns the title button widget
Returns: | the title button widget |
---|---|
Return type: | QToolButton |
Returns the collapse button widget
Returns: | the collapse button widget |
---|---|
Return type: | QToolButton |
Sets this widget’s title
:param title:the new widget title :type title: str
Sets this widget’s title icon
Parameters: | icon – (Qt.QIcon) the new widget title icon |
---|
Returns this widget’s title icon
Returns: | this widget’s title icon |
---|---|
Return type: | QIcon |
Returns this widget’s contents visibility
Returns: | this widget’s contents visibility |
---|---|
Return type: | bool |
Sets this widget’s contents visibility
Parameters: | show (bool) – the new widget contents visibility |
---|
Returns this widget’s title visibility
Returns: | this widget’s title visibility |
---|---|
Return type: | bool |
Sets this widget’s title visibility
Parameters: | show (bool) – the new widget title visibility |
---|
Returns this widget’s title height
Returns: | this widget’s title height |
---|---|
Return type: | int |
Sets this widget’s title height
Parameters: | height (int) – the new widget title height |
---|
Sets this widget’s title style Used key/values for style_map:
- ‘title_start_color’ : brush (Ex.: ‘#E0E0E0’)
- ‘title_stop_color’ : brush (Ex.: ‘#E0E0E0’)
- ‘title_font_color’ : brush (Ex.: ‘#E0E0E0’)
- ‘title_border_radius’: radius (Ex.: ‘5px’)
- ‘content_start_color’ : brush (Ex.: ‘#E0E0E0’)
- ‘content_stop_color’ : brush (Ex.: ‘#E0E0E0’)
- ‘content_border_radius’: radius (Ex.: ‘5px’)
Parameters: | style_map (dict) – the new widget title style |
---|
This property contains the widget’s title
Access functions:
This property contains the widget’s title icon
Access functions:
This property contains the widget’s title height
Access functions:
This property contains the widget’s title visibility
Access functions:
This property contains the widget’s style map
Access functions:
This property contains the widget’s content’s visibility
Access functions:
Helper functions to handle icons and pixmaps
Most common use cases are:
1 2 3 4 5 6 7 8 9 10 11 12 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import Icon
app = Application()
# get a theme icon
icon = Icon("folder-open")
button = QtGui.QPushButton(icon, "Open file...")
button.show()
app.exec_()
|
or in a label:
1 2 3 4 5 6 7 8 9 10 11 12 13 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import Icon
app = Application()
# get a theme pixmap
pixmap = Pixmap("folder-open")
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
|
Functions
Icon | Returns a QIcon for the given icon. |
Pixmap | Returns a QPixmap for the given pixmap. |
getIcon | Returns a QIcon for the given icon. |
getPixmap | Returns a QPixmap for the given pixmap. |
getQarbonIcon | Returns a QIcon for the given qarbon icon name. |
getQarbonPixmap | Returns a QPixmap for the given pixmap name. |
getStandardIcon | Returns a QIcon for the given icon ID (QtGui.QStyle.SP_*). |
getStandardPixmap | Returns a QPixmap for the given icon ID (QtGui.QStyle.SP_*). |
getStateIcon | Returns a QIcon for the given State. |
getThemeIcon | Returns a QIcon for the given theme icon name. |
getThemePixmap | Returns a QPixmap for the given theme pixmap name. |
Returns a QIcon for the given theme icon name.
Example:
1 2 3 4 5 6 7 8 9 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getThemeIcon
app = Application()
icon = getThemeIcon("folder-open")
button = QtGui.QPushButton(icon, "Open folder")
button.show()
app.exec_()
|
Parameters: | icon_name (str) – icon name |
---|---|
Returns: | the QIcon corresponding to the given theme name. If the theme icon doesn’t exist it returns a Null icon |
Return type: | QtGui.QIcon |
Returns a QPixmap for the given theme pixmap name.
Example:
1 2 3 4 5 6 7 8 9 10 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getThemePixmap
app = Application()
pixmap = getThemePixmap("folder-open", 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
|
Parameters: | |
---|---|
Returns: | the QPixmap corresponding to the given theme name. If the theme icon doesn’t exist it returns a Null pixmap |
Return type: | QtGui.QPixmap |
Returns a QIcon for the given icon ID (QtGui.QStyle.SP_*).
Example:
1 2 3 4 5 6 7 8 9 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getStandardIcon
app = Application()
icon = getStandardIcon(QtGui.QStyle.SP_MessageBoxWarning)
button = QtGui.QPushButton(icon, "Open hutch")
button.show()
app.exec_()
|
Parameters: | icon_id (QtGui.QStyle.SP) – icon name |
---|---|
Returns: | the QIcon corresponding to the given id. If the standard ID doesn’t exist it returns a Null icon |
Return type: | QtGui.QIcon |
Returns a QPixmap for the given icon ID (QtGui.QStyle.SP_*).
Example:
1 2 3 4 5 6 7 8 9 10 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getStandardPixmap
app = Application()
pixmap = getStandardPixmap(QtGui.QStyle.SP_MessageBoxWarning, 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
|
Parameters: | |
---|---|
Returns: | the QPixmap corresponding to the given id. If the standard ID doesn’t exist it returns a Null QPixmap |
Return type: | QtGui.QPixmap |
Returns a QIcon for the given qarbon icon name.
Example:
1 2 3 4 5 6 7 8 9 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getQarbonIcon
app = Application()
icon = getQarbonIcon(":/controls/collapse.png")
button = QtGui.QPushButton(icon, "Collapse")
button.show()
app.exec_()
|
Parameters: | icon_name (str) – icon name |
---|---|
Returns: | the QIcon corresponding to the given qarbon name. If the icon doesn’t exist it returns a Null icon |
Return type: | QtGui.QIcon |
Returns a QPixmap for the given pixmap name.
Example:
1 2 3 4 5 6 7 8 9 10 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getQarbonPixmap
app = Application()
pixmap = getQarbonPixmap(":/controls/collapse.png", 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
|
Parameters: | |
---|---|
Returns: | the QPixmap corresponding to the given id. If the standard ID doesn’t exist it returns a Null QPixmap |
Return type: | QtGui.QPixmap |
Returns a QIcon for the given icon.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getIcon
app = Application()
# == getThemeIcon("folder-open")
icon = getIcon("folder-open")
# == getQarbonIcon(":/controls/collapse.png")
icon = getIcon(":/controls/collapse.png")
# == Qt.QIcon("MyResource:/bla.png")
icon = getIcon("MyResource:/bla.png")
# == getStandardIcon(QtGui.QStyle.SP_MessageBoxWarning)
icon = getIcon(QtGui.QStyle.SP_MessageBoxWarning)
button = QtGui.QPushButton(icon, "Something")
button.show()
app.exec_()
|
Parameters: | icon (str or int) – icon name or ID |
---|---|
Returns: | the QIcon corresponding to the given icon. If the icon doesn’t exist it returns a Null icon |
Return type: | QtGui.QIcon |
Returns a QPixmap for the given pixmap.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import getPixmap
app = Application()
# == getThemePixmap("folder-open", 32)
pixmap = getPixmap("folder-open", 32)
# == getQarbonPixmap(":/controls/collapse.png", 32)
pixmap = getPixmap(":/controls/collapse.png", 32)
# == QtGui.QPixmap("MyResource:/bla.png")
pixmap = getPixmap("MyResource:/bla.png", 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
|
Parameters: | |
---|---|
Returns: | the QPixmap corresponding to the given pixmap. If the pixmap doesn’t exist it returns a Null QPixmap |
Return type: | QtGui.QPixmap |
Returns a QIcon for the given icon.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import Icon
app = Application()
# == getThemeIcon("folder-open")
icon = Icon("folder-open")
# == getQarbonIcon(":/controls/collapse.png")
icon = Icon(":/controls/collapse.png")
# == Qt.QIcon("MyResource:/bla.png")
icon = Icon("MyResource:/bla.png")
# == getStandardIcon(QtGui.QStyle.SP_MessageBoxWarning)
icon = Icon(QtGui.QStyle.SP_MessageBoxWarning)
button = QtGui.QPushButton(icon, "Something")
button.show()
app.exec_()
|
Parameters: | icon (str or int) – icon name or ID |
---|---|
Returns: | the QIcon corresponding to the given icon. If the icon doesn’t exist it returns a Null icon |
Return type: | QtGui.QIcon |
Returns a QPixmap for the given pixmap.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | from qarbon.external.qt import QtGui
from qarbon.qt.qui.application import Application
from qarbon.qt.gui.icon import Pixmap
app = Application()
# == getThemePixmap("folder-open", 32)
pixmap = Pixmap("folder-open", 32)
# == getQarbonPixmap(":/controls/collapse.png", 32)
pixmap = Pixmap(":/controls/collapse.png", 32)
# == QtGui.QPixmap("MyResource:/bla.png")
pixmap = Pixmap("MyResource:/bla.png", 32)
label = QtGui.QLabel()
label.setPixmap(pixmap)
label.show()
app.exec_()
|
Parameters: | |
---|---|
Returns: | the QPixmap corresponding to the given pixmap. If the pixmap doesn’t exist it returns a Null QPixmap |
Return type: | QtGui.QPixmap |
A set of widgets to get input from the user.
Classes
InputPanel | A panel design to get an input from the user. |
Bases: PyQt4.QtGui.QWidget
A panel design to get an input from the user.
The input_data is a dictionary which contains information on how to build the input dialog. It must contains the following keys:
- prompt <str>: message to be displayed
The following are optional keys (and their corresponding default values):
- title <str> (doesn’t have default value)
- key <str> (doesn’t have default value): a label to be presented left to the input box represeting the label
- unit <str> (doesn’t have default value): a label to be presented right to the input box representing the units
- data_type <str or sequence> (‘String’): type of data to be requested. Standard accepted data types are ‘String’, ‘Integer’, ‘Float’, ‘Boolean’, ‘Text’. A list of elements will be interpreted as a selection. Default TaurusInputPanel class will interpret any custom data types as ‘String’ and will display input widget accordingly. Custom data types can be handled differently by supplying a different input_panel_klass.
- minimum <int/float> (-sys.maxint): minimum value (makes sence when data_type is ‘Integer’ or ‘Float’)
- maximum <int/float> (sys.maxint): maximum value (makes sence when data_type is ‘Integer’ or ‘Float’)
- step <int/float> (1): step size value (makes sence when data_type is ‘Integer’ or ‘Float’)
- decimals <int> (1): number of decimal places to show (makes sence when data_type is ‘Float’)
- default_value <obj> (doesn’t have default value): default value
- allow_multiple <bool> (False): allow more than one value to be selected (makes sence when data_type is a sequence of possibilities)
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | app = Application()
d = dict(prompt="What's your favourite car brand?",
data_type=["Mazda", "Skoda", "Citroen", "Mercedes", "Audi",
"Ferrari"],
default_value="Mercedes")
w = InputPanel(d)
class Listener(object):
def onAccept(self):
print "user selected", w.value()
l = Listener()
w.buttonBox().accepted.connect(l.onAccept)
w.show()
app.exec_()
|
Returns the button box from this panel
Returns: | the button box from this panel |
---|---|
Return type: | PyQt4.Qt.QDialogButtonBox |
Adds the given button with the given to the button box
Parameters: |
|
---|
Sets the icon to the dialog
Parameters: | pixmap (PyQt4.Qt.QPixmap) – the icon pixmap |
---|
A LED (light-emitting diode) widget.
This widget represents a led. The led has a color and a status (On/Off).
Here is an example showing how to display all possible combinations of color, status:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.led import Led, LedStatus, LedColor
app = Application()
panel = QtGui.QWidget()
layout = QtGui.QGridLayout()
panel.setLayout(layout)
for i, color in enumerate(LedColor):
led = Led()
led.ledColor = color
led.ledStatus = LedStatus.Off
layout.addWidget(led, i, 0)
led = Led()
led.ledColor = color
led.ledStatus = LedStatus.On
layout.addWidget(led, i, 1)
panel.show()
app.exec_()
|
Classes
Led | A LED (light-emitting diode) like widget |
Bases: qarbon.external.enum._enum.Enum
possible led colors
Bases: qarbon.external.enum._enum.Enum
possible led status
Bases: qarbon.qt.gui.pixmapwidget.PixmapWidget
A LED (light-emitting diode) like widget
constant defining default led image filename pattern
constant defining default led color (green)
constant defining default led status (On)
constant defining default led status invertion (False)
Overwrite the default minimum size hint (0,0) to be (8, 8)
Returns: | the minimum size hint 8, 8 |
---|---|
Return type: | QSize |
Gives the led name for the given status and color. If status or color are not given, the current led status or color are used.
Parameters: | |
---|---|
Returns: | string containing the led name |
Return type: | str |
Determines if the given color name is valid.
Parameters: | color (str) – the color |
---|---|
Returns: | True is the given color name is valid or False otherwise |
Return type: | bool |
Returns the current led pattern name :return: led pattern name :rtype: str
Sets the led pattern name. Should be a string containing a path to valid images. The string can contain the keywords:
- {status} - transformed to ‘on’ of ‘off’ according to the status
- {color} - transformed to the current led color
Example: :leds/images256/led_{color}_{status}.png will be transformed to :leds/images256/led_red_on.png when the led status is True and the led color is red.
Parameters: | name (str) – new pattern |
---|
Sets the led inverted mode :param status: the new inverted mode :type status: bool
This property holds the led status: False means OFF, True means ON
Access functions:
This property holds the led color
Access functions:
This property holds the led inverted: False means do not invert the
Access functions:
This property holds the led pattern name
Access functions:
A widget which displays/edits information about a QObject.
Example:
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 | from qarbon.external.qt import QtCore, QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.qobjectinfowidget import ObjectInfoWidget
app = Application()
# mw will be the QObject to be "seen"
mw = QtGui.QMainWindow()
mw.setObjectName("main window")
w = QtGui.QWidget()
w.setObjectName("central widget")
mw.setCentralWidget(w)
l = QtGui.QVBoxLayout()
w.setLayout(l)
l1 = QtGui.QLabel("H1")
l1.setObjectName("label 1")
l.addWidget(l1)
l2 = QtGui.QLabel("H2")
l2.setObjectName("label 2")
l.addWidget(l2)
mw.show()
inspector = ObjectInfoWidget(qobject=mw)
inspector.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
inspector.show()
app.exec_()
|
Classes
ObjectInfoWidget | A widget which displays/edits information about a QObject. |
A widget that displays an image (pixmap).
You can adjust properties like the aligment inside the widget space, aspect ratio and transformation mode (quality).
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.icon import Pixmap
from qarbon.qt.gui.pixmapwidget import PixmapWidget
app = Application()
panel = QtGui.QWidget()
layout = QtGui.QGridLayout()
panel.setLayout(layout)
img = PixmapWidget()
layout.addWidget(img)
img.setPixmap(Pixmap(":/led/led_red_on.png"))
img.show()
app.exec_()
|
Classes
PixmapWidget | This widget displays an image (pixmap). |
Bases: PyQt4.QtGui.QWidget
This widget displays an image (pixmap). By default the pixmap is scaled to the widget size and the aspect ratio is kept. The default alignment of the pixmap inside the widget space is horizontal left, vertical center.
Signal emited when pixmap source changes
Returns the pixmap.Returns None if no pixmap is set.
Returns: | the current pixmap |
---|---|
Return type: | QtGui.QPixmap |
Sets the pixmap for this widget. Setting it to None disables pixmap
Parameters: | pixmap (QtGui.QPixmap) – the new pixmap |
---|
Returns the aspect ratio to apply when drawing the pixmap.
Returns: | the current aspect ratio |
---|---|
Return type: | QtCore.Qt.AspectRatioMode |
Sets the aspect ratio mode to apply when drawing the pixmap.
Parameters: | pixmap (QtCore.Qt.AspectRatioMode) – the new aspect ratio mode |
---|
Returns the transformation mode to apply when drawing the pixmap.
Returns: | the current transformation mode |
---|---|
Return type: | QtCore.Qt.TransformationMode |
Sets the transformation mode to apply when drawing the pixmap.
Parameters: | pixmap (QtCore.Qt.TransformationMode) – the new transformation mode |
---|
Returns the alignment to apply when drawing the pixmap.
Returns: | the current alignment |
---|---|
Return type: | QtCore.Qt.Alignment |
Sets the alignment to apply when drawing the pixmap.
Parameters: | pixmap (QtCore.Qt.Alignment) – the new alignment |
---|
Resets the transformation mode to QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter
This property holds the widget’s pixmap
Access functions:
This property holds the widget’s pixmap aspect ratio mode
Access functions:
This property holds the widget’s pixmap transformation mode
Access functions:
This property holds the widget’s pixmap alignment
Access functions:
A widget dedicated view/edit the properties of any QObject.
Example:
1 2 3 4 5 6 7 8 9 10 11 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.propertyeditor import PropertyEditor
app = Application()
inspector = PropertyEditor(qobject=None)
# watch myself... weard
inspector.setQObject(inspector)
inspector.show()
app.exec_()
|
Classes
PropertyEditor | A widget dedicated view/edit the properties of any QObject. |
Bases: PyQt4.QtGui.QWidget
A widget dedicated view/edit the properties of any QObject.
A tree widget representing QObject hierarchy (for development purposes).
The most common use case of this widget is to debug applications which may have “zombie” widgets lying around when some widget is removed, reparented in a dynammic GUI.
Example:
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 | from qarbon.external.qt import QtCore, QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.treeqobject import TreeQObjectWidget
app = Application()
# mw will be the QObject to be "seen" in the Tree (along with all its
# childs, of course)
mw = QtGui.QMainWindow()
mw.setObjectName("main window")
w = QtGui.QWidget()
w.setObjectName("central widget")
mw.setCentralWidget(w)
l = QtGui.QVBoxLayout()
w.setLayout(l)
l1 = QtGui.QLabel("H1")
l1.setObjectName("label 1")
l.addWidget(l1)
l2 = QtGui.QLabel("H2")
l2.setObjectName("label 2")
l.addWidget(l2)
mw.show()
inspector = TreeQObjectWidget(qobject=w)
inspector.setAttribute(QtCore.Qt.WA_QuitOnClose, False)
inspector.show()
app.exec_()
|
Functions
getQObjectIcon | |
getQObjectTree | |
getQObjectTreeStr | |
getQObjectTreeAsDict | |
getQObjectTreeAsList |
Classes
TreeQObjectWidget | A tree representation of the selected QObject childs. |
Bases: qarbon.external.enum._enum.Enum
possible displays of a QObject
Bases: qarbon.qt.gui.basemodel.BaseModel
Bases: qarbon.qt.gui.basetree.BaseTreeWidget
A tree representation of the selected QObject childs.
The use case of this widget is to debug applications which may have “zombie” widgets lying around when some widget is removed, reparented in a dynammic GUI.
Helper functions to deal with Qt GUI related stuff
Functions
isWidget | Determines if the given object is a Qt Widget. |
isWidgetClass | Determines if the given object is a Qt Widget class. |
getWidgetClasses | Returns the widget classes defined in a given module. |
grabWidget | Grabs the given widget into the given image filename. |
Determines if the given object is a Qt Widget.
Parameters: | obj – object |
---|---|
Returns: | True if the given object is a Qt Widget or False otherwise |
Return type: | bool |
Determines if the given object is a Qt Widget class.
Parameters: | obj – object |
---|---|
Returns: | True if the given object is a Qt Widget class or False otherwise |
Return type: | bool |
Returns the widget classes defined in a given module.
Returns:
{widget full name(str): {“klass”: widget class(class), “name”: widget name(str), “full_name”: widget full name(str)}}
Parameters: | module_name (str) – name of the module in the format “a.b.c” |
---|---|
Returns: | a map with the widgets for the given module |
Return type: | dict |
Grabs the given widget into the given image filename. If period is None (default) it grabs immediately once and returns. If period is given and >0 means grab the image every period (in seconds).
Warning
this method MUST be called from the same thread which created the widget
Parameters: |
---|
A X11 widget that may run any command and an XTermWidget runs a xterm.
Note
this widget only works on X11 systems.
Example:
1 2 3 4 5 6 7 8 9 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.x11terminal import XTermWindow
app = Application()
term = XTermWindow()
term.start()
term.show()
app.exec_()
|
Classes
XEmbedCommandWidget | |
XEmbedCommandWindow | |
XTermWidget | A widget with an xterm console inside. |
XTermWindow | The QMainWindow version of XTermWidget |
Bases: PyQt4.QtGui.QWidget
A widget displaying an X11 window inside from a command.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.x11 import XCommandWidget
app = Application()
w = QtGui.QMainWindow()
cmdWidget = XCommandWidget(parent=w)
cmdWidget.command = 'xterm'
cmdWidget.winIdParam = '-into'
cmdWidget.start()
w.setCentralWidget(cmdWidget)
w.show()
app.exec_()
|
wait < 0 -> wait forever, wait == 0 -> not wait, wait > 0 -> wait amount in seconds
Bases: PyQt4.QtGui.QMainWindow
The QMainWindow version of XCommandWidget.
Example:
1 2 3 4 5 6 7 8 9 10 11 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.x11 import XCommandWindow
app = Application()
w = XCommandWindow()
w.command = 'xterm'
w.winIdParam = '-into'
w.start()
w.show()
app.exec_()
|
alias of XCommandWidget
Bases: qarbon.qt.gui.x11.XCommandWidget
A widget with an xterm console inside.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 | from qarbon.external.qt import QtGui
from qarbon.qt.gui.application import Application
from qarbon.qt.gui.x11 import XTermWidget
app = Application()
w = QtGui.QMainWindow()
term = XTermWidget(parent=w)
term.extraParams = ["-e", "python"]
w.setCentralWidget(term)
w.start()
w.show()
app.exec_()
|
Bases: qarbon.qt.gui.x11.XCommandWindow
The QMainWindow version of XTermWidget
from qarbon.external.qt import QtGui from qarbon.qt.gui.application import Application from qarbon.qt.gui.x11 import XTermWidget
app = Application() term = XTermWindow() term.start() term.show() app.exec_()
alias of XTermWidget
Release data for the qarbon project.
It contains the following members:
- version : (str) version string
- description : (str) brief description
- long_description : (str) a long description
- license : (str) license
- authors : (seq<seq<str,str,str>>) the list of authors
- url : (str) the project url
- download_url : (str) the project download url
- keywords : list<str> list of keywords
- classifiers : list<str> list of applicable classifiers
Name of the package for release purposes. This is the name which labels the tarballs and RPMs made by distutils, so it’s best to lowercase it.
For versions with substrings (like 0.6.16.svn), use an extra . to separate the new substring. We have to avoid using either dashes or underscores, because bdist_rpm does not accept dashes (an RPM) convention, and bdist_deb does not accept underscores (a Debian convention).
revision number
package description
long description
license
authors
package URL
download URL
keywords
package classifiers
external requirements
Simple implementation of signal/slot pattern.
Classes
Signal | Represents typical Signal pattern with connect, disconnect and emit. |
Bases: object
Represents typical Signal pattern with connect, disconnect and emit. Can be used as a descriptor. Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | class Car(object):
temperatureChanged = Signal(float)
def set_temperature(self, temp):
self.__temp = temp
self.temperatureChanged.emit(temp)
car = Car()
def on_temp_changed(temp):
print("Car temperature changed to {0}".format(temp))
car.temperatureChanged.connect(on_temp_changed)
car.set_temperature(13.4)
|
Helper functions.
Functions
is_string | Determines if the given object is a string. |
is_sequence | Determines if the given object is a sequence. |
module_directory | Returns the location of a given module. |
import_module | Import a module. |
callable_weakref | This function returns a callable weak reference to a callable object. |
Determines if the given object is a string.
Parameters: | obj (object) – the object to be analysed |
---|---|
Returns: | True if the given object is a string or False otherwise |
Return type: | bool |
Determines if the given object is a sequence.
Parameters: | |
---|---|
Returns: | True if the given object is a sequence or False otherwise |
Return type: | bool |
Returns the location of a given module.
Parameters: | module (module) – the module object |
---|---|
Returns: | the directory where the module is located |
Return type: | str |
Import a module.
The ‘package’ argument is required when performing a relative import. It specifies the package to use as the anchor point from which to resolve the relative import to an absolute import.
This function returns a callable weak reference to a callable object. Object can be a callable object, a function or a method.
Parameters: |
|
---|---|
Returns: | a weak reference for the given callable |
Return type: | BoundMethodWeakref or weakref.ref |
Value definition.
Classes
AttributeConfig | |
Value | A qarbon value. |
AttributeValue | A qarbon value. |
Bases: object
Bases: object
A qarbon value. A container for a value read from a qarbon model. It contains the following members:
r_value (Quantity): (aka: value) a Quantity representing the read value
r_timestamp (datetime.datetime): the timestamp of reading the value
w_value (Quantity): a Quantity representing the write value
quality (Quality): the quality related to the read value
value resulted in an exception or None otherwise
error (bool): tells the read resulted in an error
Example on how to pretty print
Bases: qarbon.value.Value
A qarbon value. A container for a value read from a qarbon model. It contains the following members:
r_value (Quantity): (aka: value) a Quantity representing the read value
r_timestamp (datetime.datetime): the timestamp of reading the value
w_value (Quantity): a Quantity representing the write value
quality (Quality): the quality related to the read value
value resulted in an exception or None otherwise
error (bool): tells the read resulted in an error
config (AttributeConfig): config object from which this value was obtained
Other configuration values can also be accessed:
Example on how to pretty print
qarbon.color | Helper functions to translate state to color. |
qarbon.config | Global configuration. |
qarbon.core | Model core module. |
qarbon.executor | |
qarbon.log | Helper logging functions. |
qarbon.node | Node module. |
qarbon.plugin | Plugin extension manager. |
qarbon.release | Release data for the qarbon project. |
qarbon.signal | Simple implementation of signal/slot pattern. |
qarbon.util | Helper functions. |
qarbon.value | Value definition. |
qarbon.qt.gui.action | Helper functions to access QAction. |
qarbon.qt.gui.application | Helper functions to manage QApplication. |
qarbon.qt.gui.color | Helper functions to colors from state |
qarbon.qt.gui.icon | Helper functions to handle icons and pixmaps |
qarbon.qt.gui.util | Helper functions to deal with Qt GUI related stuff |
qarbon.qt.gui.baseview | A base view widget and toolbar. |
qarbon.qt.gui.basemodel | A base model and a base tree item. |
qarbon.qt.gui.basetree | A base tree widget and toolbar. |
qarbon.qt.gui.input | A set of widgets to get input from the user. |
qarbon.qt.gui.axeswidget | Multiple axis (axes) widget. |
qarbon.qt.gui.groupbox | A colapsable container widget with (optional) title. |
qarbon.qt.gui.led | A LED (light-emitting diode) widget. |
qarbon.qt.gui.pixmapwidget | A widget that displays an image (pixmap). |
qarbon.qt.gui.propertyeditor | A widget dedicated view/edit the properties of any QObject. |
qarbon.qt.gui.objectinfowidget | A widget which displays/edits information about a QObject. |
qarbon.qt.gui.treeqobject | A tree widget representing QObject hierarchy (for development purposes). |
qarbon.qt.gui.x11 | A X11 widget that may run any command and an XTermWidget runs a xterm. |
A value passed to a function or method, assigned to a named local variable in the function body. A function or method may have both positional arguments and keyword arguments in its definition. Positional and keyword arguments may be variable-length: * accepts or passes (if in the function definition or call) several positional arguments in a list, while ** does the same for keyword arguments in a dictionary.
Any expression may be used within the argument list, and the evaluated value is passed to the local variable.
A value associated with an object which is referenced by name using dotted expressions. For example, if an object o has an attribute a it would be referenced as o.a.
dictionary An associative array, where arbitrary keys are mapped to values. The keys can be any object with __hash__() and __eq__() methods. Called a hash in Perl.
An expression that returns an iterator. It looks like a normal expression followed by a for expression defining a loop variable, range, and an optional if expression. The combined expression generates values for an enclosing function:
>>> sum(i*i for i in range(10)) # sum of squares 0, 1, 4, ... 81
285
An object representing a stream of data. Repeated calls to the iterator’s next() method return successive items in the stream. When no more data are available a StopIteration exception is raised instead. At this point, the iterator object is exhausted and any further calls to its next() method just raise StopIteration again. Iterators are required to have an __iter__() method that returns the iterator object itself so every iterator is also iterable and may be used in most places where other iterables are accepted. One notable exception is code which attempts multiple iteration passes. A container object (such as a list) produces a fresh new iterator each time you pass it to the iter() function or use it in a for loop. Attempting this with an iterator will just return the same exhausted iterator object used in the previous iteration pass, making it appear like an empty container.
More information can be found in Iterator Types.
A key function or collation function is a callable that returns a value used for sorting or ordering. For example, locale.strxfrm() is used to produce a sort key that is aware of locale specific sort conventions.
A number of tools in Python accept key functions to control how elements are ordered or grouped. They include min(), max(), sorted(), list.sort(), heapq.nsmallest(), heapq.nlargest(), and itertools.groupby().
There are several ways to create a key function. For example. the str.lower() method can serve as a key function for case insensitive sorts. Alternatively, an ad-hoc key function can be built from a lambda expression such as lambda r: (r[0], r[2]). Also, the operator module provides three key function constructors: attrgetter(), itemgetter(), and methodcaller(). See the Sorting HOW TO for examples of how to create and use key functions.
An idea or piece of code which closely follows the most common idioms of the Python language, rather than implementing code using concepts common to other languages. For example, a common idiom in Python is to loop over all elements of an iterable using a for statement. Many other languages don’t have this type of construct, so people unfamiliar with Python sometimes use a numerical counter instead:
for i in range(len(food)):
print food[i]
As opposed to the cleaner, Pythonic method:
for piece in food:
print piece
Moveable position in user units (See also dial position). Dial and user units are related by the following expressions:
user = sign x dial + offset dial = controller_position / steps_per_unit
where sign is -1 or 1. offset can be any number and steps_per_unit must be non zero.
Contributers: | T. Coutinho |
---|---|
Last Update: | April 29, 2014 |
Date | Revision | Description | Author |
---|---|---|---|
15/10/13 | 0.1 | Initial Version | T. Coutinho |
version | Changes |
---|---|
0.1 | First official release |
Qarbon is a python library of Qt widgets.
An Overview guide will help you getting started with the basic qarbon concepts. The FAQ will answer many of your questions.
For sampling, see the Examples and Screenshots chapters.