This package provides a set of taurus wiget utilities like color management, configuration, actions.
Modules
Classes
Functions
A class decorator intended to be used in a Qt.QWidget to make its UI loadable from a predefined QtDesigner UI file. This decorator will add a loadUi() method to the decorated class and optionaly a property with a name given by with_ui parameter.
The folowing example assumes the existence of the ui file <my_widget_dir>/ui/MyWidget.ui which is a QWidget panel with at least a QPushButton with objectName my_button
from taurus.external.qt import Qt
from taurus.qt.qtgui.util.ui import UILoadable
@UILoadable
class MyWidget(Qt.QWidget):
def __init__(self, parent=None):
Qt.QWidget.__init__(self, parent)
self.loadUi()
self.my_button.setText("This is MY button")
Another example using a superUI.ui file in the same directory as the widget. The widget UI components can be accessed through the widget member _ui
import os.path
from taurus.external.qt import Qt
from taurus.qt.qtgui.util.ui import UILoadable
@UILoadable(with_ui="_ui")
class MyWidget(Qt.QWidget):
def __init__(self, parent=None):
Qt.QWidget.__init__(self, parent)
self.loadUi(filename="superUI.ui", path=os.path.dirname(__file__))
self._ui.my_button.setText("This is MY button")
Parameters: | with_ui (str) – assigns a member to the decorated class from which you can access all UI components [default: None, meaning no member is created] |
---|
Warning
the current implementation (Jul14) doesn’t prevent Qt from overloading any members you might have defined previously by the widget object names from the UI file. This happens even if with_ui parameter is given. For example, if the UI contains a QPushButton with objectName my_button:
@UILoadable(with_ui="_ui")
class MyWidget(Qt.QWidget):
def __init__(self, parent=None):
Qt.QWidget.__init__(self, parent)
self.my_button = "hello"
self.loadUi()
widget = MyWidget()
print widget.my_button
<PyQt4.QtGui.QPushButton object at 0x159e2f8>
This little problem should be solved in the next taurus version.
Returns all widgets in a hierarchy of a certain type
Parameters: |
|
---|---|
Returns: | a sequence containning all widgets in the hierarchy that match the given type |
Return type: | seq<Qt.QWidget> |
Grabs the given widget into the given image filename. If period is not given (or given with None) means grab immediately once and return. If period is given and >0 means grab the image every period seconds
Parameters: |
|
---|
Loads a QtDesigner .ui file into the given widget. If no filename is given, it tries to load from a file name which is the widget class name plus the extension ”.ui” (example: if your widget class is called MyWidget it tries to find a MyWidget.ui). If path is not given it uses the directory where the python file which defines the widget is located plus a ui directory (example: if your widget is defined in a file /home/homer/workspace/taurusgui/my_widget.py then it uses the path /home/homer/workspace/taurusgui/ui)
Parameters: |
|
---|