Bases: taurus.qt.qtgui.container.taurusmainwindow.TaurusMainWindow
This is main class for constructing the dynamic GUIs. TaurusGui is a specialised TaurusMainWindow which is able to handle “panels” and load configuration files. There are several ways of using TaurusGui. In the following we will give 3 examples on how to create a simple GUI called “MyGui” which contains one panel called “Foo” and consisting of a QWidget:
Example 1: use declarative configuration files.
You can create a purely declarative configuration file to be interpreted by the standard taurusgui script:
from taurus.qt.qtgui.taurusgui.utils import PanelDescription
GUI_NAME = 'MyGui'
panel = PanelDescription('Foo',
classname='taurus.external.qt.Qt.QWidget')
Note that this just a very simple example. For a much richer one, see the taurus.qt.qtgui.taurusgui.conf.tgconf_example01
Example 2: do everything programmatically.
A stand-alone python script that launches the gui when executed. No configuration file is used here. Panels and other components are added programatically:
if __name__ == '__main__':
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.taurusgui import TaurusGui
from taurus.external.qt import Qt
app = TaurusApplication(app_name='MyGui')
gui = TaurusGui()
panel = Qt.QWidget()
gui.createPanel(panel, 'Foo')
gui.show()
app.exec_()
Example 3: mixing declarative and programmatic ways
It is also possible to create a stand-alone python script which loads itself as a configuration file. In this way you can add things programmatically and at the same time use the declarative way:
GUI_NAME = 'MyGui' # <-- declarative!
if __name__ == '__main__':
from taurus.qt.qtgui.application import TaurusApplication
from taurus.qt.qtgui.taurusgui import TaurusGui
from taurus.external.qt import Qt
app = TaurusApplication()
gui = TaurusGui(confname=__file__)
panel = Qt.QWidget()
gui.createPanel(panel, 'Foo') # <-- programmatic!
gui.show()
app.exec_()
reimplemented from TaurusMainWindow.createConfig
Creates a panel from a Panel Description and sets it as “custom panel”.
Parameters: | paneldesc (:class:~`PanelDescription`) – description of the panel to be created |
---|
See also
Add a new external application on execution time
Creates a list of instrument panel descriptions by gathering the info from the Pool. Each panel is a TaurusForm grouping together all those elements that belong to the same instrument according to the Pool info
Return type: | :class:~`list` <:class:~`PanelDescription`> |
---|---|
Returns: |
Creates a synoptic panel and registers it as “SelectedInstrument” reader and writer (allowing selecting instruments from synoptic
Creates a panel containing the given widget.
Parameters: |
|
---|---|
Return type: | :class:~`DockWidgetPanel` |
Returns: | the created panel |
Note
On a previous version, there was a mandatory parameter called area (which accepted a Qt.DockWidgetArea or None as values) this parameter has now been substituted by the keyword argument floating. In order to provide backwards compatibility, the “floating” keyword argument stays at the same position as the old area argument and if a Qt.DockWidgetArea value is given, it will be interpreted as floating=True (while if None is passed, it will be interpreted as floating=False.
returns all panels in the given area
Parameters: |
|
---|
Warning
This method is deprecated
Returns the dictionary of instrument-panel associations
Return type: | :class:~`dict` <:class:~`str`, :class:~`str`> |
---|---|
Returns: | a dict whose keys are the instruments known to the gui and whose values are the corresponding associated panels (or None). |
Returns the default map used to create custom widgets by the TaurusForms belonging to this GUI
Return type: | :class:~`dict` <:class:~`str`, :class:~`Qt.QWidget`> |
---|---|
Returns: | a dictionary whose keys are device type strings (i.e. see PyTango.DeviceInfo) and whose values are widgets to be used |
See also
Returns the panel name associated to an instrument name
Parameters: | instrumentname (:class:~`str` or :class:~`None`) – The name of the instrument whose associated panel is wanted |
---|---|
Return type: | :class:~`str` or :class:~`None` |
Returns: | the associated panel name (or None). |
get a panel object by name
Return type: | :class:~`DockWidgetPanel` |
---|---|
Returns: |
returns the names of existing panels
Return type: | :class:~`list` <:class:~`str`> |
---|---|
Returns: |
TaurusGui is not to be in designer
hides all current panels
Reads a configuration file
Parameters: | confname (:class:~`str` or :class:~`None`) – the name of module located in the PYTHONPATH or in the conf subdirectory of the directory in which taurusgui.py file is installed. This method will try to import <confname>. If that fails, it will try to import tgconf_<confname>. Alternatively, confname can be the path to the configuration module (not necessarily in the PYTHONPATH). confname can also be None, in which case a dummy empty module will be used. |
---|
Slot to be called when the selected instrument has changed (e.g. by user clicking in the synoptic)
Parameters: | instrumentname (:class:~`str`) – The name that identifies the instrument. |
---|
Slot to be called when there is a new short message. Currently, the only action taken when there is a new message is to display it in the main window status bar.
Parameters: | msg (:class:~`str`) – the short descriptive message to be handled |
---|
launches the instrument-panel association dialog (modal)
reimplemented from TaurusMainWindow to show the manual in a panel (not just a dockwidget)
Remove the given external application from the GUI.
Parameters: | name (:class:~`str` or :class:~`None`) – the name of the external application to be removed If None given, the user will be prompted |
---|
remove the given panel from the GUI.
Note
The panel; is actually removed from the current perspective. If the panel is saved in other perspectives, it should be removed from them as well.
Parameters: | name (:class:~`str` or :class:~`None`) – the name of the panel to be removed If None given, the user will be prompted |
---|
Sets the dictionary of instrument-panel associations. By default, it keeps any existing association not present in the associationsdict.
Parameters: |
|
---|
Sets the widget map that is used application-wide. This widget map will be used by default in all TaurusForm Panels belonging to this gui.
Parameters: | map (:class:~`dict` <:class:~`str`, :class:~`Qt.QWidget`>) – a dictionary whose keys are device type strings (e.g. see PyTango.DeviceInfo) and whose values are widgets to be used |
---|
See also
TaurusForm.setCustomWidgetMap(), getCustomWidgetMap()
Method that sets a focus for panel passed via an argument
Parameters: | panelname (:class:~`str`) – The name that identifies the panel. This name must be unique within the panels in the GUI. |
---|
Sets the panel name associated to an instrument
Parameters: |
|
---|
shows all current panels
pops up a dialog showing the current information from the Shared Data Manager
tabifies all panels in a given area.
Parameters: | area (:class:~`Qt.DockWidgetArea`) – |
---|
Warning
This method is deprecated
Shows a dialog for selecting which custom panels should be permanently stored in the configuration.
Parameters: | showAlways (:class:~`bool`) – forces showing the dialog even if there are no new custom Panels |
---|
Shows a dialog for selecting which new externals applications should be permanently stored in the configuration.
Parameters: | showAlways (:class:~`bool`) – forces showing the dialog |
---|