fandango.qt module

Classes

QDropable

fandango.qt.QDropable

alias of DropableQtKlass

DialogCloser

class fandango.qt.DialogCloser(dialog)[source]

This decorator triggers dialog closure at the end of the decorated method e.g. dialog = QTextBuffer() widget = TaurusTrend()

TaurusTrend.closeEvent = DialogCloser(d)

QDictTextBrowser

class fandango.qt.QDictTextBrowser(parent=None)[source]

Easy widget, it just shows a dictionary in a text shape

NullWidget

class fandango.qt.NullWidget(*args)[source]

QDialogWidget

class fandango.qt.QDialogWidget(parent=None, flags=None, buttons=None)[source]

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

QCustomTabWidget

class fandango.qt.QCustomTabWidget(parent=None, icon_builder=None)[source]

A reimplementation of QTabWidget but using custom buttons to manage tabs

QExceptionMessage

class fandango.qt.QExceptionMessage(*args)[source]

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
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, ...

TangoHostChooser

class fandango.qt.TangoHostChooser(hosts)[source]

Allows to choose a tango_host from a list

TaurusImportException

class fandango.qt.TaurusImportException[source]

QSignalHook

class fandango.qt.QSignalHook(function)[source]

Class initialized with a transformation function. For every setModel(model) it will emit a modelChanged(function(model))

QTableOnWidget

class fandango.qt.QTableOnWidget(parent=None, data=None, filters=True)[source]

A Helper class to easily initialize a QTable from an array

TauEmitterThread

fandango.qt.TauEmitterThread

alias of QWorker

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.

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.

QDraggable

fandango.qt.QDraggable

alias of DraggableQtKlass

QCustomPushButton

class fandango.qt.QCustomPushButton(label, widget=None, parent=None)[source]

QGridTable

class fandango.qt.QGridTable(parent=None)[source]

This class is a frame with a QGridLayout that emulates some methods of QTableWidget

QDoubleClickable

fandango.qt.QDoubleClickable

alias of DoubleClickableQtKlass

QColorDictionary

class fandango.qt.QColorDictionary(sort=False)[source]

Returns a {name:QColor} dictionary; if sorted tries to sort by color difference

ModelRefresher

class fandango.qt.ModelRefresher(period=30)[source]

QWidgetWithLayout

class fandango.qt.QWidgetWithLayout(parent=None, layout=None, child=None)[source]

A helper widget that allows to create QWidgets with predefined layouts

TauFakeEventReceiver

class fandango.qt.TauFakeEventReceiver[source]

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>
getDone()[source]

Returns % of done tasks in 0-1 range

put(callable, arg0, arg1, arg2, ...)[source]

ApiBrowser

class fandango.qt.ApiBrowser(parent=None, model='', filename='~/.qeval_history')[source]

QTextBuffer

class fandango.qt.QTextBuffer(title='TextBuffer', maxlen=1000, parent=None)[source]

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.

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.

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

QDraggableLabel

fandango.qt.QDraggableLabel

alias of DraggableQtKlass

QOptionChooser

class fandango.qt.QOptionChooser(title, text, command, args, parent=None)[source]

Dialog used to trigger several options from a bash launch script

QDictToolBar

class fandango.qt.QDictToolBar(parent=None)[source]
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.

Functions

getRandomColor

fandango.qt.getRandomColor(i=None)[source]

getQt

fandango.qt.getQt(full=False)[source]

Choosing between PyQt and Taurus Qt distributions

getApplication

fandango.qt.getApplication(args=None)[source]

modelSetter

fandango.qt.modelSetter(obj, model)[source]

checkApplication

fandango.qt.checkApplication(args=None)[source]

execApplication

fandango.qt.execApplication()[source]

setDialogCloser

fandango.qt.setDialogCloser(dialog, widget)[source]

set dialog to be closed on widget.closeEvent()

getColorsForValue

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

GetFramedTaurusValue

fandango.qt.GetFramedTaurusValue(model=None, label=True, hook=None)[source]

getStateLed

fandango.qt.getStateLed(model)[source]

getQwtPlot

fandango.qt.getQwtPlot(series, xIsTime=False)[source]

Series would be a {Label:[(time,value)]} dictionary

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)

getQwtTimeScaleDraw

fandango.qt.getQwtTimeScaleDraw()[source]

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

fire_targets(targets=[])[source]
get_targets(widgets=[])[source]
run()[source]
stop()[source]
class fandango.qt.NullWidget(*args)[source]

Bases: taurus.qt.qtgui.container.tauruswidget.TaurusWidget

Input(value)[source]
show()[source]
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

get_diff_code(name, color)[source]
get_rgb_normalized(color)[source]
show()[source]
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

getText()[source]
setBold(bold)[source]
setLabel(label)[source]
setWidget(widget)[source]
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

addTab(widget, label, icon=None, width=50, height=60)[source]
clear()[source]
count()[source]
currentIndex()[source]
currentWidget()[source]
elideMode()[source]
emitCurrentChanged()[source]
indexOf(widget)[source]
insertTab(index, page, icon, label)[source]
isTabEnabled(index)[source]
labelIndex(label)[source]
labelOf(widget)[source]
removeTab(index)[source]
setCurrentIndex(index)[source]
setCurrentWidget(widget, label='')[source]
setElideMode(elide)[source]
setTabEnabled(index, enable)[source]
setTabPosition(position)[source]
setTabShape(shape)[source]
setTabToolTip(index, tip)[source]
setUsesScrollButtons(uses)[source]
tabBar()[source]
tabPosition()[source]
tabShape()[source]
tabText(index)[source]
tabToolTip(index)[source]
usesScrollButtons()[source]
widget(index)[source]
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

setWidget(widget, accept_signal=None, reject_signal=None)[source]
sizeHint()[source]
widget()[source]
class fandango.qt.QDictTextBrowser(parent=None)[source]

Bases: PyQt4.QtGui.QWidget

Easy widget, it just shows a dictionary in a text shape

setModel(model)[source]
setupUi()[source]
static test()[source]
updateText(item)[source]
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’)),])
add_to_main_window(MainWindow, where=4)[source]
build_action(name, icon, action)[source]
set_toolbar(toolbar)[source]

The toolbar argument must be dictionary {name:(icon,action)} or a list of (‘Name’,’icon.jpg’,action) tuples.

setup_ui()[source]
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.

addModels(models)[source]
dropEvent(event)[source]

reimplemented to support dropping of modelnames in forms

getSupportedMimeTypes()[source]
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

mimeTypes()[source]
mouseDoubleClickEvent(event)[source]
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
dir_module(*args)[source]
evalQ(c)[source]
execute(cmd=None, args=None)[source]

(Ctrl+Enter) Send the current command,arguments to the eval engine and process the output.

help(m=None)[source]
static main(args=None)[source]
multiline_edit()[source]
multiline_exec()[source]
multiline_load()[source]
printf(txt, append=True, highlight=False, curr='')[source]
save_to(filename=None, txt=None)[source]
setEval(m=None)[source]
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, ...

setup_ui()[source]
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

clear()[source]
columnCount()[source]
itemAt(x, y)[source]
removeWidget(widget)[source]
resizeColumnsToContents()[source]
resizeRowsToContents()[source]
rowCount()[source]
setCellWidget(*args)[source]
setColumnCount(count)[source]
setColumnWidth(col, width)[source]
setHorizontalHeaderLabels(labels)[source]
setItem(x, y, item, spanx=1, spany=1)[source]
setRowCount(count)[source]
setRowHeight(row, height)[source]
setVerticalHeaderLabels(labels)[source]
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

launch()[source]
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()

accept()[source]
getModel()[source]
setModel(model)[source]
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))

setModel(model)[source]
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

setCells(data=None)[source]
setData(data=None)[source]
setFiltered()[source]
static test(csvfile)[source]
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.

append(text)[source]
clear()[source]
saveLogs()[source]
setText(text)[source]
text()[source]
toggle(arg=None)[source]
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

addChildWidget(child, row=None, column=None)[source]
childWidget()[source]
removeChildWidget()[source]
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

getQueue()[source]
next()[source]
put(callable, arg0, arg1, arg2, ...)[source]
run()[source]
class fandango.qt.TangoHostChooser(hosts)[source]

Bases: PyQt4.QtGui.QDialog

Allows to choose a tango_host from a list

done(*args)[source]
static main(args=[])[source]
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)
getModelClass()[source]
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

isReadOnly()[source]
setColors(background, foreground)[source]
setModel(model)[source]
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

class fandango.qt.TauFakeEventReceiver[source]
event_received(source, type_, value)[source]
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()