taurus.qt.qtgui.dialog

This package contains a collection of taurus Qt widgets representing various panels like forms or panels to be inserted in dialogs

Classes

class ProtectTaurusMessageBox(title=None, msg=None)[source]

The idea of this class is to be used as a decorator on any method you which to protect against exceptions. The handle of the exception is to display a TaurusMessageBox with the exception information. The optional parameter title gives the window bar a customized title. The optional parameter msg allows you to give a customized message in the dialog. Example:

@ProtectTaurusMessgeBox(title="Error trying to turn the beam on")
def turnBeamOn(device_name):
    d = taurus.Device(device_name)
    d.TurnOn()

(more info)

class TaurusExceptHookMessageBox(hook_to=None, title=None, msg=None)[source]

A callable class that acts as an excepthook that displays an unhandled exception in a TaurusMessageBox.

Parameters
  • hook_to (callable) – callable excepthook that will be called at the end of this hook handling [default: None]

  • title – message box title [default: None meaning use exception value]

  • msg – message box text [default: None meaning use exception]

(more info)

class TaurusInputDialog(input_data=None, parent=None, input_panel_klass=None, designMode=False)[source]

The TaurusInputDialog class provides a simple convenience dialog to get a single value from the user.

(more info)

class TaurusMessageBox(err_type=None, err_value=None, err_traceback=None, parent=None, designMode=False)[source]

A panel intended to display a taurus error. Example:

dev = taurus.Device("sys/tg_test/1")
try:
    print(dev.read_attribute("throw_exception"))
except PyTango.DevFailed, df:
    msgbox = TaurusMessageBox()
    msgbox.show()

You can show the error outside the exception handling code. If you do this, you should keep a record of the exception information as given by sys.exc_info():

dev = taurus.Device("sys/tg_test/1")
exc_info = None
try:
    print(dev.read_attribute("throw_exception"))
except PyTango.DevFailed, df:
    exc_info = sys.exc_info()

if exc_info:
    msgbox = TaurusMessageBox(*exc_info)
    msgbox.show()

(more info)

Functions

get_input(input_data, parent=None, input_panel_klass=None)[source]

Static convenience function to get an input from the user using a dialog. The dialog will be modal.

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)

Parameters
  • input_data (dict) – a dictionary with information on how to build the input dialog

  • parent (PyQt5.Qt.QWidget) – parent widget

  • input_panel_klass (TaurusInputPanel) – python class to be used as input panel [default: TaurusInputPanel]

Returns

a tuple containing value selected and boolean which is true if user accepted the dialog (pressed Ok) or false otherwise

Return type

tuple< obj, bool >

Examples:

d1 = dict(prompt="What's your name?", data_type="String")
d2 = dict(
    prompt="What's your age?",
    data_type="Integer",
    default_value=4,
    maximum=100,
    key="Age",
    unit="years"
    )
d3 = dict(
    prompt="What's your favourite number?",
    data_type="Float",
    default_value=0.1,
    maximum=88.8,
    key="Number"
    )
d4 = dict(
    prompt="What's your favourite car brand?",
    data_type=["Mazda", "Skoda", "Citroen", "Mercedes", "Audi"],
    default_value="Mercedes"
    )
d5 = dict(
    prompt="Select some car brands", allow_multiple=True,
    data_type=["Mazda", "Skoda", "Citroen", "Mercedes", "Audi"],
    default_value=["Mercedes", "Citroen"]
    )
d6 = dict(
    prompt="What's your favourite color?",
    key="Color",
    data_type=["blue", "red", "green"],
    default_value="red"
    )
d7 = dict(prompt="Do you like bears?",
    data_type='Boolean',
    key="Yes/No",
    default_value=True
    )
d8 = dict(
    prompt="Please write your memo",
    data_type='Text',
    key="Memo",
    default_value="By default a memo is a long thing"
    )
for d in [d1, d2, d3, d4, d5, d6, d7, d8]:
    get_input(input_data=d, title=d['prompt'])
protectTaurusMessageBox(fn)[source]

The idea of this function is to be used as a decorator on any method you which to protect against exceptions. The handle of the exception is to display a TaurusMessageBox with the exception information. Example:

@protectTaurusMessgeBox
def turnBeamOn(device_name):
    d = taurus.Device(device_name)
    d.TurnOn()