vacca.utils module¶
vacca.utils python module, by srubio@cells.es
vacca.utils contains several methods and classes for:
- manage environment variables
- loading config files
- manipulate Qt color palettes
- custom Taurus event filters
This file is part of Tango Control System
Environment Variables¶
Variables can be declared in OS or as Tango.VACCA free properties
VACCA_CONFIG: get_config_file()
The config file to be loaded, it can be absolute path or relative to VACCA_DIR.
e.g. /homelocal/sicilia/applications/vacca/tbl2401.py
VACCA_DIR: wdir(‘path/to/icon’)
The folder were VACCA should be executed, all paths within the application will be relative to it. It includes all custom icons that are not part of the vacca package.
If VACCA_CONFIG is defined, it defaults to the path to config file. At ALBA installations it defaults to the path of vaccagui library. Extra modules or plugins to be imported will be loaded from this directory.
e.g. /homelocal/sicilia/applications/vacca/
VACCA_PATH: vpath(‘path/to/icon’)
Not mandatory, it defaults to the path of vacca library. Used for launchers and default icons of vacca widgets.
e.g. /homelocal/sicilia/lib/python/site-packages/vacca
Classes¶
EventCounter¶
addCustomPanel2Gui¶
- class vacca.utils.addCustomPanel2Gui(extra_panels=None)[source]¶
this Class is used to add new panel to existing TaurusGUI with the same Context. Each extra_panel class should have a ‘getPaneldescription’ and getDefaultIcon methods.
- Pass a dictionary like this:
- EXTRA_PANELS[‘VaccaProperties’] = {
- ‘class’: vacca.VaccaPropTable, ‘icon’: ‘:/places/network-server.svg’, }
WidgetAcceptDrops¶
Draggable¶
OnChangeOrTimeEventFilter¶
- class vacca.utils.OnChangeOrTimeEventFilter[source]¶
The instances of this class will be callables that can be used as filters of repeated-value events. If the event type is Change or Periodic, it will only pass when its evt_value.value is different from that of the last event received from the same source and type. If evt_value.value is not available in the current event, the whole evt_value is used for comparison and as a future reference. But!, if setMaxDeltaTime is set, then any event that occurred more than Delta Time seconds after the last one will be allowed to pass through the chain.
This is useful to avoid processing repetitive events.
Note that you cannot use this class as a filter: you need to use an instance of it.
Note 2: Use a different instance each time you insert this filter into a different widget unless you really know what you are doing.
- Example of usage::
- evf = OnChangeOrTimeEventFilter() evf.setDeltaTime(60.) filters = [evf, IGNORE_CONFIG] MyTaurusComponentInstance.setEventFilters(filters,preqt=True) filterEvent(s, t, v, filters)
Functions¶
get_env_variable¶
load_config_properties¶
get_os_launcher¶
get_config_properties¶
- class vacca.utils.Draggable[source]
Bases: object
Template for Taurus widgets accepting drops, deprecated by fandango.qt.Draggable
- mouseMoveEvent(event)[source]
reimplemented to provide drag events
- mousePressEvent(event)[source]
reimplemented to provide drag events
- class vacca.utils.DraggableLabel(parent=None, text='')[source]
Bases: vacca.utils.Draggable, PyQt4.QtGui.QLabel
- class vacca.utils.EventCounter(condition=None)[source]
Bases: vacca.utils.EventFilter
Generic event counter for taurus
- class vacca.utils.EventFilter(condition=None)[source]
Bases: object
Generic event filter for taurus
- class vacca.utils.MyTaurusComponent(name='test')[source]
Bases: taurus.qt.qtgui.base.taurusbase.TaurusBaseComponent, PyQt4.QtCore.QObject
- class vacca.utils.OnChangeOrTimeEventFilter[source]
Bases: vacca.utils.EventFilter
The instances of this class will be callables that can be used as filters of repeated-value events. If the event type is Change or Periodic, it will only pass when its evt_value.value is different from that of the last event received from the same source and type. If evt_value.value is not available in the current event, the whole evt_value is used for comparison and as a future reference. But!, if setMaxDeltaTime is set, then any event that occurred more than Delta Time seconds after the last one will be allowed to pass through the chain.
This is useful to avoid processing repetitive events.
Note that you cannot use this class as a filter: you need to use an instance of it.
Note 2: Use a different instance each time you insert this filter into a different widget unless you really know what you are doing.
- Example of usage::
- evf = OnChangeOrTimeEventFilter() evf.setDeltaTime(60.) filters = [evf, IGNORE_CONFIG] MyTaurusComponentInstance.setEventFilters(filters,preqt=True) filterEvent(s, t, v, filters)
- vacca.utils.VACCA_CONFIG = 'html'¶
VACCA_CONFIG:
The config file to be loaded, it can be absolute path or relative to WORKING_DIR. get_config_file() will import it and return the content as a python module.
e.g. /homelocal/sicilia/applications/vacca/tbl2401.py
- vacca.utils.VACCA_DIR = '/homelocal/sicilia/lib/python/site-packages/vacca/../vaccagui'¶
VACCA_DIR: wdir(‘path/to/icon’)
The folder were VACCA should be executed, all paths within the application will be relative to it. It includes all custom icons that are not part of the vacca package.
Extra modules or plugins to be imported will be loaded from this directory.
e.g. /homelocal/sicilia/applications/vacca/
- vacca.utils.VACCA_PATH = '/homelocal/sicilia/lib/python/site-packages/vacca'¶
VACCA_PATH: vpath(‘path/to/icon’)
Path to the VACCA library parent folder, tipically used for icons of vacca package Note, vpath(folder) will append /vacca to VACCA_PATH, to get internal vacca files.
e.g. VACCA_PATH = /homelocal/sicilia/lib/python/site-packages e.g. vpath = /homelocal/sicilia/lib/python/site-packages/vacca
- vacca.utils.VACCA_PROFILES = {'DEFAULT': {}, 'TEST': {}}¶
VACCA_PROFILES:
Sets of environment variables declared as free properties in the Tango Database.
- class vacca.utils.WidgetAcceptDrops[source]
Bases: object
Template for Taurus widgets accepting drops, deprecated by fandango.qt.Dropable
- TAURUS_ATTR_MIME_TYPE = 'application/taurus-attribute'¶
- TAURUS_DEV_MIME_TYPE = 'application/taurus-device'¶
- TAURUS_MODEL_LIST_MIME_TYPE = 'text/uri-list'¶
- TAURUS_MODEL_MIME_TYPE = 'application/taurus-model'¶
- TEXT_MIME_TYPE = 'text/plain'¶
- dropEvent(event)[source]
reimplemented to support drag&drop of models. See QWidget
- vacca.utils.YesNoDialog(title, message)[source]
- class vacca.utils.addCustomPanel2Gui(extra_panels=None)[source]
Bases: object
this Class is used to add new panel to existing TaurusGUI with the same Context. Each extra_panel class should have a ‘getPaneldescription’ and getDefaultIcon methods.
- Pass a dictionary like this:
- EXTRA_PANELS[‘VaccaProperties’] = {
- ‘class’: vacca.VaccaPropTable, ‘icon’: ‘:/places/network-server.svg’, }
- vacca.utils.add_menu(menuname, actions)[source]
The arguments must be a list of tuples with action names and action methods.
e.g.: EXTRA_MENUS = [ (‘Tools’,[
(‘LTB Gui’,lambda:os.system(‘vacca_LTB &’),None), (‘Jive’,lambda:os.system(‘jive &’),None), (‘Astor’,lambda:os.system(‘astor &’),None), (‘EPS Gui’,lambda:os.system(‘alba_EPS &’),None), (‘Valves’,lambda:valves.ValvesChooser().show(),None), (‘TaurusTrend’,lambda:os.system(‘taurustrend -a &’),None), ]),
- vacca.utils.create_config_properties()[source]
- vacca.utils.get_White_palette(palette=None)[source]
- vacca.utils.get_class_property(dev_class, prop, extract=False)[source]
- vacca.utils.get_config_file(config=None)[source]
- vacca.utils.get_config_properties(config='')[source]
- vacca.utils.get_env_variable(var, default='')[source]
It will try to get value from OS, then Tango.VACCA, then default
- vacca.utils.get_fullWhite_palette(palette=None)[source]
- vacca.utils.get_halfWhite_palette(palette=None)[source]
- vacca.utils.get_main_window(app=None)[source]
- vacca.utils.get_os_launcher(cmd, args=[])[source]
Returns a Linux launcher method for “cmd”. @TODO: Study Taurus.ExternalApp and use the same methods used there.
- vacca.utils.get_shared_data_manager()[source]
sdm = get_shared_data_manager() #Qt.qApp.SDM Singletone sdm.connectReader(‘channelName’,objectInstance.method,readOnConnect=False) #Using instantiated object/function instead of names!! sdm.connectWriter(‘SelectedInstrument’,out_hook,’modelChanged’) #’Channel’, object, ‘qt signal name’
- vacca.utils.get_shared_data_signals()[source]
Return the dictionary of signals and registered Qt objects.
- vacca.utils.get_solid_brush(r, g, b, pattern=None)[source]
- vacca.utils.get_taurus_gui(app=None)[source]
- vacca.utils.get_vacca_property(prop, extract=False)[source]
- vacca.utils.load_config_properties(config, export=True)[source]
It will load env variables from VACCA.$config property
NOT USED!?
- vacca.utils.replace_env(text, var, value=None)[source]
- vacca.utils.vpath(s='')[source]
- vacca.utils.wdir(s='')[source]