示例#1
0
 def __init__(self, parent=None):
     TaurusGui.__init__(self)
     self._components = None
     self.initComponents()
     self.prepareJorgsBar()
     self.loadDefaultPerspective()
     self.splashScreen().finish(self)
示例#2
0
    def __init__(self, parent=None, designMode=False):
        TaurusGui.__init__(self, parent)
        self.loadUi()

        # setting up the device Tree.
        #@todo: This should be done in the ui file when the TaurusDatabaseTree Designer plugin is available
        import taurus.qt.qtgui.tree
        TaurusDbTreeWidget = taurus.qt.qtgui.tree.TaurusDbTreeWidget

        self.deviceTree = TaurusDbTreeWidget(
            perspective=TaurusElementType.Device)
        self.deviceTree.getQModel().setSelectables([TaurusElementType.Member
                                                    ])  # TODO: Tango-centric
        # self.deviceTree.insertFilter(filterNonExported)
        self.setCentralWidget(self.deviceTree)

        # register subwidgets for configuration purposes
        # self.registerConfigDelegate(self.taurusAttrForm)
        # self.registerConfigDelegate(self.deviceTree)
        self.registerConfigDelegate(self._ui.taurusCommandsForm)

        self.loadSettings()
        self.createActions()

        # self.addToolBar(self.basicTaurusToolbar())

        self.deviceTree.currentItemChanged.connect(self.onItemSelectionChanged)

        self.updatePerspectivesMenu()
        if not designMode:
            self.splashScreen().finish(self)
示例#3
0
def test_paneldescription(qtbot):
    gui = TaurusGui(confname=__file__, configRecursionDepth=0)
    w1 = gui.getPanel('testpanel1').widget()
    qtbot.addWidget(gui)
    qtbot.addWidget(w1)
    assert w1.withButtons is False
    assert w1.isWithButtons() is False
    assert not hasattr(w1, "foobar")
    assert w1.modifiableByUser is False
def create_application():
    """Return an (application, taurusgui) pair."""
    basedir = os.path.dirname(__file__)
    confname = os.path.join(basedir, "config.py")
    app = TaurusApplication()
    #gui = MyTaurusGui(None, confname, False)
    gui = TaurusGui(confname=confname)
    #gui.mousePressEvent = myMousePressEvent
    gui.show()
    return app, gui
def create_application():
    """Return an (application, taurusgui) pair."""
    basedir = os.path.dirname(__file__)
    confname = os.path.join(basedir, "config.py")
    app = TaurusApplication()
    #gui = MyTaurusGui(None, confname, False)
    gui = TaurusGui(confname=confname)
    #gui.mousePressEvent = myMousePressEvent
    gui.show()
    return app, gui
示例#6
0
 def getQtDesignerPluginInfo(cls):
     ret = TaurusGui.getQtDesignerPluginInfo()
     ret['module'] = 'taurus.qt.qtgui.panel'
     return ret
示例#7
0
 def setModel(self, name):
     """Reimplemented to delegate model to the commands and attrs forms"""
     TaurusGui.setModel(self, name)
     self._ui.taurusAttrForm.setModel(name)
     self._ui.taurusCommandsForm.setModel(name)
示例#8
0
 def setTangoHost(self, host):
     """extended from :class:setTangoHost"""
     TaurusGui.setTangoHost(self, host)
     self.deviceTree.setModel(host)
示例#9
0
def run():
    # Simplify TaurusGui
    TaurusGui.TAURUS_MENU_ENABLED = False
    TaurusGui.TOOLS_MENU_ENABLED = False
    TaurusGui.HELP_MENU_ENABLED = False
    TaurusGui.FULLSCREEN_TOOLBAR_ENABLED = False
    TaurusGui.PANELS_MENU_ENABLED = False
    TaurusGui.APPLETS_TOOLBAR_ENABLED = False
    TaurusGui.QUICK_ACCESS_TOOLBAR_ENABLED = False

    app = TaurusApplication(app_name='tpgArchiving')
    gui = TaurusGui()
    gui.setWindowTitle('Taurus Archiving Plot')
    plot = TaurusPlot()

    #class MyPlot(TaurusPlot):
    #pass

    ##def dropEvent(self, event):
    ##print('In dropEvent(%s)' % str(dir(event)))
    ##def dragMoveEvent(self,event):
    ##print('Dragging ...')
    ##event.acceptProposedAction()
    ##def dragEnterEvent(self,event):
    ##print('Entering ...')
    ##event.acceptProposedAction()

    #plot = MyPlot()
    #plot.setAcceptDrops(True)
    #plot = fandango.qt.Dropable(TaurusPlot)()
    #plot.setDropLogger(fandango.printf)
    #plot.setSupportedMimeTypes(fandango.qt.MIMETYPES)

    plot.setBackgroundBrush(Qt.QColor('white'))
    axis = DateAxisItem(orientation='bottom')
    plot_items = plot.getPlotItem()

    axis.attachToPlotItem(plot_items)
    # TODO (cleanup menu actions)
    if plot_items.legend is not None:
        plot_items.legend.hide()

    msi = TangoArchivingModelSelectorItem()
    # hide time stamp selector
    msi.ui.ts_checkBox.setVisible(False)
    # hide add single Y model
    msi._addSelectedAction.setVisible(False)
    msi.setModel(msi.default_model)
    # progress bar
    pb = Qt.QProgressBar()
    pb.setGeometry(0, 0, 300, 25)

    def updateProgressBar(stop=True):
        if stop is True:
            final = 1
        else:
            final = 0
        pb.setRange(0, final)

    updateProgressBar()

    ###########################################################################
    # Update t0 and t1 based on sigXRangeChanged
    ###########################################################################
    def onUpdateXViewRange():
        x, _ = plot.viewRange()
        t0, t1 = x
        t0s = str2localtime(t0)
        t1s = str2localtime(t1)
        msi.time_selector.ui.comboBox_begin.setItemText(5, t0s)
        msi.time_selector.ui.comboBox_end.setItemText(7, t1s)
        msi.time_selector.ui.comboBox_begin.setItemText(5, t0s)
        msi.time_selector.ui.comboBox_end.setItemText(7, t1s)
        msi.time_selector.ui.comboBox_begin.setCurrentIndex(5)
        msi.time_selector.ui.comboBox_end.setCurrentIndex(7)

    vb = plot.getPlotItem().getViewBox()
    vb.sigXRangeChanged.connect(onUpdateXViewRange)

    ###########################################################################
    # Legend
    ###########################################################################
    gv = Qt.QGraphicsView(Qt.QGraphicsScene())
    gv.setBackgroundBrush(Qt.QBrush(Qt.QColor('white')))
    l = pg.LegendItem(None, offset=(0, 0))
    gv.scene().addItem(l)

    def updateExternalLegend():
        for dataitem in plot_items.listDataItems():
            l.removeItem(dataitem.name())

        for dataitem in plot_items.listDataItems():
            if dataitem.name():
                l.addItem(dataitem, dataitem.name())

    ###########################################################################
    # Connect CurvesAppearanceChooser to external legend
    ###########################################################################
    from taurus_pyqtgraph.curveproperties import (CurvesAppearanceChooser,
                                                  CurveAppearanceProperties)

    def onApply(self):
        names = self.getSelectedCurveNames()
        prop = self.getShownProperties()
        # Update self.curvePropDict for selected properties
        for n in names:
            self.curvePropDict[n] = CurveAppearanceProperties.merge(
                [self.curvePropDict[n], prop],
                conflict=CurveAppearanceProperties.inConflict_update_a)
        # emit a (PyQt) signal telling what properties (first argument) need to
        # be applied to which curves (second argument)
        # self.curveAppearanceChanged.emit(prop, names)
        # return both values

        self.curvePropAdapter.setCurveProperties(self.curvePropDict, names)
        # Update legend
        updateExternalLegend()

        return prop, names

    # Override CurvesAppearanceChooser.onApply
    CurvesAppearanceChooser.onApply = onApply

    ###########################################################################
    # Helper
    ###########################################################################
    def updateAll(legend=True):
        # Update legend
        if legend is True:
            updateExternalLegend()
        # run plot auto range
        time.sleep(0.2)  # Wait till models are loading
        plot_items.getViewBox().menu.autoRange()
        # Stop progress bar
        updateProgressBar()

    ###########################################################################
    # onAddXYModel
    ###########################################################################

    def onAddXYModel(models=None):
        # Update progress bar
        # updateProgressBar(False)
        print('onAddXYModel(%s)' % models)
        if not isSequenceType(models):
            print('Overriding models ...')
            models = msi.getSelectedModels()

        c = msi.cursor()
        msi.setCursor(Qt.Qt.WaitCursor)
        current = plot._model_chooser_tool.getModelNames()
        print('current: %s' % str(current))
        models = [m for m in models if m not in current]
        print('new models: %s' % str(models))
        plot.addModels(models)
        updateAll()
        msi.setCursor(c)

    # Connect button
    msi.modelsAdded.connect(onAddXYModel)

    #plot.setDropEventCallback(onAddXYModel)

    ###########################################################################
    # Override TaurusGui close event
    ###########################################################################
    def closeEvent(self, event):
        try:
            self.__macroBroker.removeTemporaryPanels()
        except:
            pass
        TaurusMainWindow.closeEvent(self, event)
        for n, panel in self._TaurusGui__panels.items():
            panel.closeEvent(event)
            panel.widget().closeEvent(event)
            if not event.isAccepted():
                result = Qt.QMessageBox.question(
                    self, 'Closing error',
                    "Panel '%s' cannot be closed. Proceed closing?" % n,
                    Qt.QMessageBox.Yes | Qt.QMessageBox.No)
                if result == Qt.QMessageBox.Yes:
                    event.accept()
                else:
                    break

        for curve in plot_items.listDataItems():
            plot.removeItem(curve)
            l.removeItem(curve.name())
        gui.saveSettings()

    # Override TaurusGui close event
    TaurusGui.closeEvent = closeEvent

    ###########################################################################
    # Create tgarch tool bar
    ###########################################################################
    def _onRefresh():
        t0, t1 = msi.time_selector.getTimes()
        # Validate models
        v = TangoArchivingAttributeNameValidator()
        query = "{0};t0={1};t1={2}"
        for curve in plot.getPlotItem().listDataItems():

            if isinstance(curve, TaurusPlotDataItem):
                ymodel = curve.getModel()
                # tgarch attr
                if v.getUriGroups(ymodel).get('scheme') != 'tgarch':
                    continue
                fullname, _, _ = v.getNames(ymodel)
                bmodel, current_query = fullname.split('?')
                db = current_query.split(';')[0]
                q = query.format(db, t0, t1)
                model = "{0}?{1}".format(bmodel, q)
                xmodel = "{};ts".format(model)
                curve.setModel(None)
                curve.setXModel(None)
                curve.setModel(model)
                curve.setXModel(xmodel)
        updateAll(legend=False)

    def onRefresh():
        # Update progress bar
        updateProgressBar(False)
        t1 = threading.Thread(target=_onRefresh)
        t1.start()

    tgarchToolBar = gui.addToolBar("TgArch")
    tgarchToolBar.addAction(Qt.QIcon.fromTheme("view-refresh"),
                            "refresh tgarch curves", onRefresh)

    ###########################################################################
    # Create panels
    ###########################################################################
    gui.createPanel(plot, 'Plot')
    gui.createPanel(msi, 'Chooser')
    gui.createPanel(pb, 'Progress bar')
    gui.createPanel(gv, 'Legend')
    # Load configuration
    gui.loadSettings()
    gui.show()

    app.exec_()
 def __init__(self, parent=None, confname=None, confRec=None):
     TaurusGui.__init__(self, None, confname, True)
示例#11
0
    
elif config:
    try:
      import imp
      print('Loading %s as python module'%config)
      config = imp.find_module(config.replace('.','/'))[1]
      dirname = os.path.dirname(config)
    except:
      pass

dirname = dirname or os.path.dirname(config) or \
  vu.get_vacca_property('VACCA_DIR',extract=1) or ''

vu.VACCA_DIR = os.environ['VACCA_DIR'] = dirname
vu.VACCA_CONFIG = os.environ['VACCA_CONFIG'] = config

print('Vacca Environment variables (vacca.main):')
print('\n'.join(map(str,(t for t in os.environ.items() if 'VACCA' in t[0]))))
  
### MAIN CODE FOR PANELS GENERATION IS IN vacca.config SUBMODULE
print '-'*80
confname = 'vaccagui'
app = TaurusApplication()
gui = TaurusGui(None, confname=confname)
gui.show()
ret = app.exec_()

taurus.info('Finished execution of TaurusGui')
sys.exit(ret)

示例#12
0
# (at your option) any later version.
##
# Taurus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
##
# You should have received a copy of the GNU Lesser General Public License
# along with Taurus.  If not, see <http://www.gnu.org/licenses/>.
##
###########################################################################

"""An example of usage of TaurusGui in which the specific GUI is set up both
programmatically and using the same file as the configuration file.
This can be launched directly as a stand-alone python script"""


GUI_NAME = "MyGui"

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")
    gui.show()
    app.exec_()
 def __init__(self, parent=None, confname=None, confRec=None):
     TaurusGui.__init__(self, None, confname, True)
示例#14
0
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
##
# Taurus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
##
# You should have received a copy of the GNU Lesser General Public License
# along with Taurus.  If not, see <http://www.gnu.org/licenses/>.
##
###########################################################################

'''An example of usage of TaurusGui in which the specific GUI is set up both
programmatically and using the same file as the configuration file.
This can be launched directly as a stand-alone python script'''


GUI_NAME = 'MyGui'

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(cmd_line_parser=None)
    gui = TaurusGui(confname=__file__)
    panel = Qt.QWidget()
    gui.createPanel(panel, 'Foo')
    gui.show()
    app.exec_()
示例#15
0
文件: gui_noconf.py 项目: cmft/taurus
# Taurus is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
##
# Taurus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
##
# You should have received a copy of the GNU Lesser General Public License
# along with Taurus.  If not, see <http://www.gnu.org/licenses/>.
##
###########################################################################

'''An example of usage of TaurusGui in which no configuration file is used
(everything is done programmatically)
This can be launched directly as a stand-alone python script'''

if __name__ == '__main__':
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.qt.qtgui.taurusgui import TaurusGui
    from taurus.external.qt import Qt
    # if app_name name not given, it uses the file name
    app = TaurusApplication(app_name='MyGui')
    gui = TaurusGui()
    panel = Qt.QWidget()
    gui.createPanel(panel, 'Foo')
    gui.show()
    app.exec_()
示例#16
0
##
# Taurus is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
##
# Taurus is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
##
# You should have received a copy of the GNU Lesser General Public License
# along with Taurus.  If not, see <http://www.gnu.org/licenses/>.
##
###########################################################################
'''An example of usage of TaurusGui in which no configuration file is used
(everything is done programmatically)
This can be launched directly as a stand-alone python script'''

if __name__ == '__main__':
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.qt.qtgui.taurusgui import TaurusGui
    from taurus.external.qt import Qt
    # if app_name name not given, it uses the file name
    app = TaurusApplication(app_name='MyGui')
    gui = TaurusGui()
    panel = Qt.QWidget()
    gui.createPanel(panel, 'Foo')
    gui.show()
    app.exec_()
示例#17
0
def taurusgui(confname=None):
    from taurus.qt.qtgui.taurusgui import TaurusGui

    taurus.info('Starting execution of TaurusGui')

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] confname")
    parser.set_description("The taurus GUI application")
    parser.add_option(
        "",
        "--config-dir",
        dest="config_dir",
        default=None,
        help="use the given configuration directory for initialization")
    parser.add_option(
        "",
        "--new-gui",
        action="store_true",
        dest="new_gui",
        default=None,
        help="launch a wizard for creating a new TaurusGUI application")
    parser.add_option(
        "",
        "--fail-proof",
        action="store_true",
        dest="fail_proof",
        default=None,
        help=
        "launch in fail proof mode (it prevents potentially problematic configs from being loaded)"
    )

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurusgui",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    if options.new_gui:  # launch app settings wizard instead of taurusgui
        from taurus.qt.qtgui.taurusgui import AppSettingsWizard
        wizard = AppSettingsWizard()
        wizard.show()
        sys.exit(app.exec_())

    if confname is None:
        confname = options.config_dir

    if confname is None:
        if len(
                args
        ) == 1:  # for backwards compat, we allow to specify the confname without the "--config-dir" parameter
            confname = args[0]
        else:
            parser.print_help(sys.stderr)
            sys.exit(1)

    if options.fail_proof:
        configRecursionDepth = 0
    else:
        configRecursionDepth = None

    gui = TaurusGui(None,
                    confname=confname,
                    configRecursionDepth=configRecursionDepth)

    gui.show()
    ret = app.exec_()

    taurus.info('Finished execution of TaurusGui')
    sys.exit(ret)