fandango.qt module¶
Contents
- fandango.qt module
- Description
- Classes
- QDropable
- DialogCloser
- QDictTextBrowser
- NullWidget
- QDialogWidget
- QCustomTabWidget
- QExceptionMessage
- QEvaluator
- TangoHostChooser
- TaurusImportException
- QSignalHook
- QTableOnWidget
- TauEmitterThread
- QOptionDialog
- TauColorComponent
- QDraggable
- QCustomPushButton
- QGridTable
- QDoubleClickable
- QColorDictionary
- ModelRefresher
- QWidgetWithLayout
- TauFakeEventReceiver
- QWorker
- ApiBrowser
- QTextBuffer
- QDropTextEdit
- QDraggableLabel
- QOptionChooser
- QDictToolBar
- Functions
- raw autodoc
Classes¶
QEvaluator¶
- class fandango.qt.QEvaluator(parent=None, model='', filename='~/.qeval_history')[source]¶
- Default methods:
- mdir(expr,[module]): return elements matching expr, from module or locals() help(method): returns source of method or __doc__ doc(method): idem run(module): loads a module (reloads?) table/bold/color: html formatting
QOptionDialog¶
- class fandango.qt.QOptionDialog(parent=None, model={}, title='', cast=None)[source]¶
This class provides a fast way to update a dictionary from a Qt dialog
s = fandango.Struct(name=’test’,value=7.8) qo = QOptionDialog(model=s,cast=s.cast,title=’Options’) qo.show() #Edit and save the values s.value : 5.0
Using plain dicts: d = {‘name’:’A’,’value’:4} qo = QOptionDialog(model=d,cast=fandango.str2type,title=’Options’) qo.exec()
TauColorComponent¶
- class fandango.qt.TauColorComponent(name=None, parent=None, defaults=None)[source]¶
Abstract class for Tau color-based items.
Param: defaults will be a tuple with the default foreground,background colors (appliable if value not readable) It may allow to differentiate not-read from UNKNOWN - The TauColorComponent contains a QObject to emit Qt.SIGNALs if needed:
- self.emitter.connect(self.emitter,Qt.SIGNAL(“setColors”),self.parent.tabBar().setTabTextColor) self.emitter.emit(Qt.SIGNAL(“setColors”),self.getIndex(),color)
- getParentTauComponent()[source]¶
Returns a parent Tau component or None if no parent TaurusBaseComponent is found.
QDraggable¶
- fandango.qt.QDraggable¶
alias of DraggableQtKlass
QDoubleClickable¶
- fandango.qt.QDoubleClickable¶
alias of DoubleClickableQtKlass
QWorker¶
- class fandango.qt.QWorker(parent=None, name='', queue=None, method=None, cursor=None, sleep=5000)[source]¶
IF YOU USE TAURUS, GO THERE INSTEAD: taurus.qt.qtcore.util.emitter.SingletonWorker ; it is more optimized and maintained
This object get items from a python Queue and performs a thread safe operation on them. It is useful to delay signals in a background thread. :param parent: a Qt/Tau object :param name: identifies object logs :param queue: if None parent.getQueue() is used, if not then the queue passed as argument is used :param method: the method to be executed using each queue item as argument :param cursor: if True or QCursor a custom cursor is set while the Queue is not empty
Delaying model subscription using TauEmitterThread[edit]:
<pre> #Applying TauEmitterThread to an existing class: import Queue from functools import partial def modelSetter(args): obj,model = args[0],args[1] obj.setModel(model) klass TauGrid(Qt.QFrame, TaurusBaseWidget): ... def __init__(self, parent = None, designMode = False): ... self.modelsQueue = Queue.Queue() self.modelsThread = TauEmitterThread(parent=self,queue=self.modelsQueue,method=modelSetter ) ... def build_widgets(...): ... previous,synoptic_value = synoptic_value,TauValue(cell_frame) #synoptic_value.setModel(model) self.modelsQueue.put((synoptic_value,model)) ... def setModel(self,model): ... if hasattr(self,'modelsThread') and not self.modelsThread.isRunning(): self.modelsThread.start() elif self.modelsQueue.qsize(): self.modelsThread.next() ... </pre>
QDropTextEdit¶
- class fandango.qt.QDropTextEdit(*args)[source]¶
This method provides a widget that allows drops of text from other widgets. As a bonus, it provides a simple hook for DoubleClick events But!, QTextEdit already supported drag/drop, so it is just an exercise of how to do these things.
- handleMimeData(mimeData, method)[source]¶
Selects the most appropriate data from the given mimeData object (in the order returned by getSupportedMimeTypes()) and passes it to the given method.
Parameters: - mimeData – (QMimeData) the MIME data object from which the model is to be extracted
- method – (callable<str>) a method that accepts a string as argument. This method will be called with the data from the mimeData object
Returns: (str or None) returns the MimeType used if the model was successfully set, or None if the model could not be set
QDraggableLabel¶
- fandango.qt.QDraggableLabel¶
alias of DraggableQtKlass
QDictToolBar¶
Functions¶
QConfirmAction¶
- fandango.qt.QConfirmAction(action, parent=None, title='WARNING', message='Are you sure?', options=<PyQt4.QtGui.StandardButtons object at 0x7eff55b99b18>)[source]¶
This method will just execute action but preceeded by a confirmation dialog. To pass arguments to your action just use partial(action,*args,**kwargs) when declaring it e.g:
self._clearbutton.connect(self._clearbutton,Qt.SIGNAL(‘clicked()’),fandango.partial(fandango.qt.QConfirmAction,self.clearBuffers)
raw autodoc¶
- class fandango.qt.ApiBrowser(parent=None, model='', filename='~/.qeval_history')[source]
Bases: fandango.qt.QEvaluator
- class fandango.qt.DialogCloser(dialog)[source]
Bases: object
This decorator triggers dialog closure at the end of the decorated method e.g. dialog = QTextBuffer() widget = TaurusTrend()
TaurusTrend.closeEvent = DialogCloser(d)
- fandango.qt.GetFramedTaurusValue(model=None, label=True, hook=None)[source]
- class fandango.qt.ModelRefresher(period=30)[source]
Bases: threading.Thread, fandango.objects.SingletonMap
- class fandango.qt.NullWidget(*args)[source]
Bases: taurus.qt.qtgui.container.tauruswidget.TaurusWidget
- class fandango.qt.QColorDictionary(sort=False)[source]
Bases: fandango.dicts.SortedDict, fandango.objects.Singleton
Returns a {name:QColor} dictionary; if sorted tries to sort by color difference
- fandango.qt.QConfirmAction(action, parent=None, title='WARNING', message='Are you sure?', options=<PyQt4.QtGui.StandardButtons object at 0x7eff55b99b18>)[source]
This method will just execute action but preceeded by a confirmation dialog. To pass arguments to your action just use partial(action,*args,**kwargs) when declaring it e.g:
self._clearbutton.connect(self._clearbutton,Qt.SIGNAL(‘clicked()’),fandango.partial(fandango.qt.QConfirmAction,self.clearBuffers)
- class fandango.qt.QCustomPushButton(label, widget=None, parent=None)[source]
Bases: PyQt4.QtGui.QPushButton
- class fandango.qt.QCustomTabWidget(parent=None, icon_builder=None)[source]
Bases: PyQt4.QtGui.QWidget
A reimplementation of QTabWidget but using custom buttons to manage tabs
- class fandango.qt.QDialogWidget(parent=None, flags=None, buttons=None)[source]
Bases: PyQt4.QtGui.QDialog
It converts any Widget into a Dialog
setAccept method allows to easily connect the accepted() signal to a callable
- setAccept(f)[source]
connect the accepted() signal to a callable
- class fandango.qt.QDictTextBrowser(parent=None)[source]
Bases: PyQt4.QtGui.QWidget
Easy widget, it just shows a dictionary in a text shape
- class fandango.qt.QDictToolBar(parent=None)[source]
Bases: PyQt4.QtGui.QToolBar
- Just a customizable toolbar that can be setup using a dictionary:
- toolbar = QDictToolBar(tmw) toolbar.set_toolbar([(‘Archiving Viewer’,’Mambo-icon.ico’, lambda:launch(‘mambo’)),])
- set_toolbar(toolbar)[source]
The toolbar argument must be dictionary {name:(icon,action)} or a list of (‘Name’,’icon.jpg’,action) tuples.
- fandango.qt.QDoubleClickable
alias of DoubleClickableQtKlass
- fandango.qt.QDraggable
alias of DraggableQtKlass
- fandango.qt.QDraggableLabel
alias of DraggableQtKlass
- class fandango.qt.QDropTextEdit(*args)[source]
Bases: PyQt4.QtGui.QTextEdit
This method provides a widget that allows drops of text from other widgets. As a bonus, it provides a simple hook for DoubleClick events But!, QTextEdit already supported drag/drop, so it is just an exercise of how to do these things.
- dropEvent(event)[source]
reimplemented to support dropping of modelnames in forms
- handleMimeData(mimeData, method)[source]
Selects the most appropriate data from the given mimeData object (in the order returned by getSupportedMimeTypes()) and passes it to the given method.
Parameters: - mimeData – (QMimeData) the MIME data object from which the model is to be extracted
- method – (callable<str>) a method that accepts a string as argument. This method will be called with the data from the mimeData object
Returns: (str or None) returns the MimeType used if the model was successfully set, or None if the model could not be set
- setClickHook(hook)[source]
the hook must be a function or callable
- setSupportedMimeTypes(mimetypes)[source]
sets the mimeTypes that this widget support
Parameters: mimetypes – (list<str>) list (ordered by priority) of MIME type names
- fandango.qt.QDropable
alias of DropableQtKlass
- class fandango.qt.QEvaluator(parent=None, model='', filename='~/.qeval_history')[source]
Bases: PyQt4.QtGui.QWidget
- Default methods:
- mdir(expr,[module]): return elements matching expr, from module or locals() help(method): returns source of method or __doc__ doc(method): idem run(module): loads a module (reloads?) table/bold/color: html formatting
- execute(cmd=None, args=None)[source]
(Ctrl+Enter) Send the current command,arguments to the eval engine and process the output.
- setModel(model=None)[source]
setModel(obj) will set the last element of a sequence of commands as Model for the shell The Model can be either an object, class, module, ...
- class fandango.qt.QExceptionMessage(*args)[source]
Bases: object
- class fandango.qt.QGridTable(parent=None)[source]
Bases: PyQt4.QtGui.QFrame
This class is a frame with a QGridLayout that emulates some methods of QTableWidget
- class fandango.qt.QOptionChooser(title, text, command, args, parent=None)[source]
Bases: PyQt4.QtGui.QDialog
Dialog used to trigger several options from a bash launch script
- class fandango.qt.QOptionDialog(parent=None, model={}, title='', cast=None)[source]
Bases: fandango.qt.QDialogWidget
This class provides a fast way to update a dictionary from a Qt dialog
s = fandango.Struct(name=’test’,value=7.8) qo = QOptionDialog(model=s,cast=s.cast,title=’Options’) qo.show() #Edit and save the values s.value : 5.0
Using plain dicts: d = {‘name’:’A’,’value’:4} qo = QOptionDialog(model=d,cast=fandango.str2type,title=’Options’) qo.exec()
- class fandango.qt.QSignalHook(function)[source]
Bases: PyQt4.QtCore.QObject
Class initialized with a transformation function. For every setModel(model) it will emit a modelChanged(function(model))
- class fandango.qt.QTableOnWidget(parent=None, data=None, filters=True)[source]
Bases: PyQt4.QtGui.QWidget
A Helper class to easily initialize a QTable from an array
- class fandango.qt.QTextBuffer(title='TextBuffer', maxlen=1000, parent=None)[source]
Bases: PyQt4.QtGui.QDialog
This dialog provides a Text dialog where logs can be inserted from your application in a round buffer. It also provides a button to save the logs into a file if needed.
- class fandango.qt.QWidgetWithLayout(parent=None, layout=None, child=None)[source]
Bases: PyQt4.QtGui.QWidget
A helper widget that allows to create QWidgets with predefined layouts
- class fandango.qt.QWorker(parent=None, name='', queue=None, method=None, cursor=None, sleep=5000)[source]
Bases: PyQt4.QtCore.QThread
IF YOU USE TAURUS, GO THERE INSTEAD: taurus.qt.qtcore.util.emitter.SingletonWorker ; it is more optimized and maintained
This object get items from a python Queue and performs a thread safe operation on them. It is useful to delay signals in a background thread. :param parent: a Qt/Tau object :param name: identifies object logs :param queue: if None parent.getQueue() is used, if not then the queue passed as argument is used :param method: the method to be executed using each queue item as argument :param cursor: if True or QCursor a custom cursor is set while the Queue is not empty
Delaying model subscription using TauEmitterThread[edit]:
<pre> #Applying TauEmitterThread to an existing class: import Queue from functools import partial def modelSetter(args): obj,model = args[0],args[1] obj.setModel(model) klass TauGrid(Qt.QFrame, TaurusBaseWidget): ... def __init__(self, parent = None, designMode = False): ... self.modelsQueue = Queue.Queue() self.modelsThread = TauEmitterThread(parent=self,queue=self.modelsQueue,method=modelSetter ) ... def build_widgets(...): ... previous,synoptic_value = synoptic_value,TauValue(cell_frame) #synoptic_value.setModel(model) self.modelsQueue.put((synoptic_value,model)) ... def setModel(self,model): ... if hasattr(self,'modelsThread') and not self.modelsThread.isRunning(): self.modelsThread.start() elif self.modelsQueue.qsize(): self.modelsThread.next() ... </pre>
- getDone()[source]
Returns % of done tasks in 0-1 range
- put(callable, arg0, arg1, arg2, ...)[source]
- class fandango.qt.TangoHostChooser(hosts)[source]
Bases: PyQt4.QtGui.QDialog
Allows to choose a tango_host from a list
- class fandango.qt.TauColorComponent(name=None, parent=None, defaults=None)[source]
Bases: taurus.qt.qtgui.base.taurusbase.TaurusBaseComponent
Abstract class for Tau color-based items.
Param: defaults will be a tuple with the default foreground,background colors (appliable if value not readable) It may allow to differentiate not-read from UNKNOWN - The TauColorComponent contains a QObject to emit Qt.SIGNALs if needed:
- self.emitter.connect(self.emitter,Qt.SIGNAL(“setColors”),self.parent.tabBar().setTabTextColor) self.emitter.emit(Qt.SIGNAL(“setColors”),self.getIndex(),color)
- getParentTauComponent()[source]
Returns a parent Tau component or None if no parent TaurusBaseComponent is found.
- handleEvent(evt_src=None, evt_type=None, evt_value=None)[source]
fires a value changed event to all listeners
- updateStyle()[source]
Method called when the component detects an event that triggers a change in the style. If the value is not parseable the default colors will be set.
- fandango.qt.TauEmitterThread
alias of QWorker
- exception fandango.qt.TaurusImportException[source]
Bases: exceptions.Exception
- fandango.qt.checkApplication(args=None)[source]
- fandango.qt.execApplication()[source]
- fandango.qt.getApplication(args=None)[source]
- fandango.qt.getColorsForValue(value, palette=<taurus.qt.qtgui.util.tauruscolor.QtColorPalette object at 0x7eff566cd790>)[source]
Get QColor equivalent for a given Tango attribute value It returns a Background,Foreground tuple
- fandango.qt.getQt(full=False)[source]
Choosing between PyQt and Taurus Qt distributions
- fandango.qt.getQwtPlot(series, xIsTime=False)[source]
Series would be a {Label:[(time,value)]} dictionary
- fandango.qt.getQwtTimeScaleDraw()[source]
- fandango.qt.getRandomColor(i=None)[source]
- fandango.qt.getStateLed(model)[source]
- fandango.qt.modelSetter(obj, model)[source]
- fandango.qt.setDialogCloser(dialog, widget)[source]
set dialog to be closed on widget.closeEvent()