Exemple #1
0
def main():
    import taurus.qt.qtgui.icon  # otherwise the arrows don't show in the demo
    global arrowWidget

    def resetAll():
        arrowWidget.resetIntDigitCount()
        arrowWidget.resetDecDigitCount()
        arrowWidget.resetMinValue()
        arrowWidget.resetMaxValue()
        arrowWidget.resetValue()

    def setNAN():
        arrowWidget.setValue(float('nan'))

    def setNone():
        arrowWidget.setValue(None)

    a = Qt.QApplication([])
    panel = Qt.QWidget()
    l = Qt.QFormLayout(panel)
    button_layout = Qt.QVBoxLayout()
    arrowWidget = QWheelEdit(panel)
    isb, dsb = Qt.QSpinBox(panel), Qt.QSpinBox(panel)
    minv, maxv = Qt.QDoubleSpinBox(panel), Qt.QDoubleSpinBox(panel)
    resetbutton = Qt.QPushButton("Reset", panel)
    resetbutton.setDefault(True)
    nanbutton = Qt.QPushButton("Set NAN", panel)
    nonebutton = Qt.QPushButton("Set None", panel)
    hideEditCB = Qt.QCheckBox()
    hideEditCB.setChecked(True)
    showarrowbutton = Qt.QCheckBox("", panel)

    l.addRow("Value", arrowWidget)
    l.addRow("Integer digits:", isb)
    l.addRow("Decimal digits:", dsb)
    l.addRow("Minimum value:", minv)
    l.addRow("Maximum value:", maxv)
    l.addRow("Show arrows:", showarrowbutton)
    l.addRow("hideEditCB", hideEditCB)
    l.addRow(button_layout)
    button_layout.addWidget(nanbutton)
    button_layout.addWidget(nonebutton)
    button_layout.addWidget(resetbutton)
    isb.setValue(arrowWidget.getIntDigitCount())
    dsb.setValue(arrowWidget.getDecDigitCount())
    minv.setRange(numpy.finfo('d').min, numpy.finfo('d').max)
    maxv.setRange(numpy.finfo('d').min, numpy.finfo('d').max)
    minv.setValue(arrowWidget.getMinValue())
    maxv.setValue(arrowWidget.getMaxValue())
    showarrowbutton.setChecked(arrowWidget.getShowArrowButtons())
    isb.valueChanged.connect(arrowWidget.setIntDigitCount)
    dsb.valueChanged.connect(arrowWidget.setDecDigitCount)
    minv.valueChanged.connect(arrowWidget.setMinValue)
    showarrowbutton.stateChanged.connect(arrowWidget.setShowArrowButtons)
    nanbutton.clicked.connect(setNAN)
    nonebutton.clicked.connect(setNone)
    hideEditCB.toggled.connect(arrowWidget.setHideEditWidget)
    resetbutton.clicked.connect(resetAll)
    panel.setVisible(True)
    a.exec_()
Exemple #2
0
def test1():
    '''tests taurusForm'''
    import sys
    if len(sys.argv) > 1:
        models = sys.argv[1:]
    else:
        models = None
    app = Qt.QApplication(sys.argv)
    if models is None:
        models = [
            'sys/tg_test/1/state', 'sys/tg_test/1/float_scalar',
            'sys/tg_test/1/boolean_image', 'sys/tg_test/1/float_spectrum',
            'sys/tg_test/1/status'
        ]
    dialog = TaurusForm()
    dialog.setModel(models)
    dialog.setModifiableByUser(True)
    for i, tv in enumerate(dialog.getItems()):
        tv.setDangerMessage("Booooo scaring %d!!!" % i)
    dialog.show()

    dialog2 = TaurusForm()
    dialog2.show()
    dialog2.setModifiableByUser(True)
    sys.exit(app.exec_())
    def _buildWidgets(self, module_name, path, recursive=True):
        import taurus.qt.qtgui.base

        if Qt.QApplication.instance() is None:
            app = Qt.QApplication([])
            # raise Exception("Cannot build widget list without an instance of "\
            #                "QApplication. Please create one before.")

        elems = os.listdir(path)
        taurus_ret, qt_ret = {}, {}
        if not '__init__.py' in elems:
            return taurus_ret, qt_ret

        try:
            m = __import__(module_name, fromlist=['*'], level=0)
            dir_names = dir(m)
            for dir_name in dir_names:
                if dir_name.startswith("_"):
                    continue
                try:
                    attr = getattr(m, dir_name)
                    if issubclass(attr, Qt.QWidget):
                        package = m.__package__
                        qt_ret[dir_name] = package, attr
                        if issubclass(attr, taurus.qt.qtgui.base.TaurusBaseWidget):
                            taurus_ret[dir_name] = package, attr
                except Exception, e:
                    pass
        except Exception, e:
            return taurus_ret, qt_ret
Exemple #4
0
def main():
    global digitWidget
    a = Qt.QApplication([])
    panel = Qt.QWidget()
    l = Qt.QFormLayout(panel)
    digitWidget = Q7SegDigit()
    digitWidget.setStyleSheet("background-color:red;")
    valueLineEdit = Qt.QLineEdit(digitWidget.getValue())
    valueLineEdit.setMaxLength(1)
    ledPenWidthWidget = Qt.QSpinBox()
    ledPenWidthWidget.setRange(0, 20)
    ledPenWidthWidget.setValue(digitWidget.getLedPenWidth())
    bgBrushWidget = Qt.QPushButton("Bg brush")
    LedOnPenColor = Qt.QPushButton("ON pen color")
    LedOnBgColor = Qt.QPushButton("ON bg color")
    LedOffPenColor = Qt.QPushButton("OFF pen color")
    LedOffBgColor = Qt.QPushButton("OFF bg color")

    l.addRow("Value", digitWidget)
    l.addRow("Digit", valueLineEdit)
    l.addRow("Pen width", ledPenWidthWidget)
    l.addRow(bgBrushWidget)
    l.addRow(LedOnPenColor)
    l.addRow(LedOnBgColor)
    l.addRow(LedOffPenColor)
    l.addRow(LedOffBgColor)
    valueLineEdit.textChanged.connect(digitWidget.setValue)
    ledPenWidthWidget.valueChanged.connect(digitWidget.setLedPenWidth)
    bgBrushWidget.clicked.connect(__setBgBrush)
    LedOnPenColor.clicked.connect(__setLedOnPenColor)
    LedOnBgColor.clicked.connect(__setLedOnBgColor)
    LedOffPenColor.clicked.connect(__setLedOffPenColor)
    LedOffBgColor.clicked.connect(__setLedOffBgColor)
    panel.setVisible(True)
    a.exec_()
def main():
    import sys
    attr_name = sys.argv[1]
    a = Qt.QApplication([])
    d = TaurusConfigurationDialog()
    d.setModel(attr_name)
    return a.exec_()
Exemple #6
0
def main():
    """hello"""

    app = Qt.QApplication.instance()
    owns_app = app is None

    if owns_app:
        app = Qt.QApplication(sys.argv)

    w = Qt.QWidget()
    layout = Qt.QGridLayout()
    layout.setContentsMargins(2, 2, 2, 2)
    layout.setSpacing(2)
    w.setLayout(layout)
    for i, color in enumerate(LedColor.keys()):
        led = QLed()
        led.ledColor = color
        led.ledStatus = True
        layout.addWidget(led, i, 0)
        led = QLed()
        led.ledColor = color
        led.ledStatus = False
        layout.addWidget(led, i, 1)
        led = QLed()
        led.ledColor = color
        led.blinkingInterval = 500
        layout.addWidget(led, i, 2)
    w.show()

    if owns_app:
        sys.exit(app.exec_())
    else:
        return w
Exemple #7
0
def main():
    import sys

    app = Qt.QApplication([])
    window = Qt.QWidget()
    layout = Qt.QHBoxLayout(window)
    goButton = Qt.QPushButton("Activate help", window)
    terminateButton = Qt.QPushButton("Close help", window)
    textEdit = Qt.QLineEdit(window)
    layout.addWidget(textEdit)
    layout.addWidget(goButton)
    layout.addWidget(terminateButton)

    def go():
        assistant = Assistant(textEdit.text(), parent=window)
        assistant.start()
        assistant.waitForStarted()
        assistant.assistantShow(Widgets.bookmarks)

    def terminate():
        assistant = Assistant(textEdit.text(),
                              auto_create=False,
                              parent=window)
        if assistant:
            assistant.terminate()

    goButton.clicked.connect(go)
    terminateButton.clicked.connect(terminate)
    window.show()
    sys.exit(app.exec_())
Exemple #8
0
def main():
    import taurus.qt.qtgui.application

    Application = taurus.qt.qtgui.application.TaurusApplication

    app = Application.instance()
    owns_app = app is None

    if owns_app:
        app = Qt.QApplication([])
        app.setApplicationName("Taurus input dialog demo")
        app.setApplicationVersion("1.0")

    d1 = dict(prompt="What's your name?", data_type="String")
    d2 = dict(prompt="What's your age?", data_type="Integer",
              default_value=4, maximum=100, key="Age", unit="years")
    d3 = dict(prompt="What's your favourite number?", data_type="Float",
              default_value=0.1, maximum=88.8, key="Number")
    d4 = dict(prompt="What's your favourite car brand?",
              data_type=["Mazda", "Skoda", "Citroen",
                         "Mercedes", "Audi", "Ferrari"],
              default_value="Mercedes")
    d5 = dict(prompt="Select some car brands", allow_multiple=True,
              data_type=["Mazda", "Skoda", "Citroen",
                         "Mercedes", "Audi", "Ferrari"],
              default_value=["Mercedes", "Citroen"])
    d6 = dict(prompt="What's your favourite color?", key="Color",
              data_type=["blue", "red", "green"], default_value="red")
    d7 = dict(prompt="Do you like bears?",
              data_type='Boolean', key="Yes/No", default_value=True)
    d8 = dict(prompt="Please write your memo",
              data_type='Text', key="Memo", default_value="By default a memo is\na long thing")

    for d in [d1, d2, d3, d4, d5, d6, d7, d8]:
        print(get_input(input_data=d, title=d['prompt']))
Exemple #9
0
def jdraw_view_main():
    import sys, time
    import taurus.qt.qtgui.graphic
    taurus.setLogLevel(taurus.Info)

    app = Qt.QApplication(sys.argv)

    #form = Qt.QDialog()
    #ly=Qt.QVBoxLayout(form)
    #container=Qt.QWidget()
    #ly.addWidget(container)
    #for m in sys.argv[1:]:
    #tv=TaurusJDrawSynopticsView(container, designMode=False)
    #tv.setModel(m)
    #print "\n\n\n form \n\n\n"
    form = taurus.qt.qtgui.graphic.TaurusJDrawSynopticsView(designMode=False)
    #form = TaurusJDrawSynopticsView(designMode=False)
    form.show()

    #Tomek start
    print "TEST: " + '%s setModel(%s)' % (time.ctime(), sys.argv[1])
    #Tomek end

    form.setModel(sys.argv[1])

    #print "\n\n\n FORM: \n\n", form
    form.setWindowTitle(sys.argv[1].rsplit('.', 1)[0])

    #Tomek start
    #def kk(*args):print("\tgraphicItemSelected(%s)"%str(args))
    #form.connect(form,Qt.SIGNAL("graphicItemSelected(QString)"), kk)
    #Tomek stop

    form.fitting()
    sys.exit(app.exec_())
Exemple #10
0
def main():
    global arrowWidget

    def resetAll():
        arrowWidget.resetIntDigitCount()
        arrowWidget.resetDecDigitCount()
        arrowWidget.resetMinValue()
        arrowWidget.resetMaxValue()
        arrowWidget.resetValue()

    def setNAN():
        arrowWidget.setValue(float('nan'))

    def setNone():
        arrowWidget.setValue(None)

    a = Qt.QApplication([])
    panel = Qt.QWidget()
    l = Qt.QFormLayout(panel)
    button_layout = Qt.QVBoxLayout()
    arrowWidget = QWheelEdit(panel)
    isb, dsb = Qt.QSpinBox(panel), Qt.QSpinBox(panel)
    minv, maxv = Qt.QDoubleSpinBox(panel), Qt.QDoubleSpinBox(panel)
    resetbutton = Qt.QPushButton("Reset", panel)
    resetbutton.setDefault(True)
    nanbutton = Qt.QPushButton("Set NAN", panel)
    nonebutton = Qt.QPushButton("Set None", panel)
    showarrowbutton = Qt.QCheckBox("", panel)

    l.addRow("Value", arrowWidget)
    l.addRow("Integer digits:", isb)
    l.addRow("Decimal digits:", dsb)
    l.addRow("Minimum value:", minv)
    l.addRow("Maximum value:", maxv)
    l.addRow("Show arrows:", showarrowbutton)
    l.addRow(button_layout)
    button_layout.addWidget(nanbutton)
    button_layout.addWidget(nonebutton)
    button_layout.addWidget(resetbutton)
    isb.setValue(arrowWidget.getIntDigitCount())
    dsb.setValue(arrowWidget.getDecDigitCount())
    minv.setRange(numpy.finfo('d').min, numpy.finfo('d').max)
    maxv.setRange(numpy.finfo('d').min, numpy.finfo('d').max)
    minv.setValue(arrowWidget.getMinValue())
    maxv.setValue(arrowWidget.getMaxValue())
    showarrowbutton.setChecked(arrowWidget.getShowArrowButtons())
    Qt.QObject.connect(isb, Qt.SIGNAL("valueChanged(int)"),
                       arrowWidget.setIntDigitCount)
    Qt.QObject.connect(dsb, Qt.SIGNAL("valueChanged(int)"),
                       arrowWidget.setDecDigitCount)
    Qt.QObject.connect(minv, Qt.SIGNAL("valueChanged(double)"),
                       arrowWidget.setMinValue)
    Qt.QObject.connect(showarrowbutton, Qt.SIGNAL("stateChanged(int)"),
                       arrowWidget.setShowArrowButtons)
    Qt.QObject.connect(nanbutton, Qt.SIGNAL("clicked()"), setNAN)
    Qt.QObject.connect(nonebutton, Qt.SIGNAL("clicked()"), setNone)
    Qt.QObject.connect(resetbutton, Qt.SIGNAL("clicked()"), resetAll)
    panel.setVisible(True)
    a.exec_()
Exemple #11
0
def main2():
    import sys
    a = Qt.QApplication([])
    dw = Q7SegDigit()
    dw.setValue(int(sys.argv[1]))
    dw.setVisible(True)
    print dw
    a.exec_()
Exemple #12
0
def main():
    import sys
    app = Qt.QApplication([])
    help_panel = HelpPanel()
    if len(sys.argv) > 1:
        help_panel.setCollectionFile(sys.argv[1])
    help_panel.show()
    sys.exit(app.exec_())
Exemple #13
0
 def __test__(klass, arg=None):
     qapp = Qt.QApplication([])
     i = klass()
     print i
     print klass
     i.show()
     if arg: i.setTable(arg)
     qapp.exec_()
Exemple #14
0
def taurusAttrListTest():
    '''tests taurusAttrList. Model: an attribute containing a list of strings'''
    model = sys.argv[1]
    a = Qt.QApplication([])
    w = TaurusAttrListComboBox()
    w.setModel(model)
    w.show()
    return a.exec_()
Exemple #15
0
def main(args):
    if len(sys.argv) > 1:
        host = sys.argv[1]
    else:
        host = None

    app = Qt.QApplication(args)
    print(TaurusModelChooser.modelChooserDlg(host=host))
    sys.exit()
def main():
    import sys
    attr_name = sys.argv[1]
    a = Qt.QApplication([])
    w1 = TaurusConfigurationPanel()
    w1._ui.pushButtonOk.setVisible(True)
    w1._ui.pushButtonCancel.setVisible(True)
    w1.setModel(attr_name)
    w1.show()
    return a.exec_()
Exemple #17
0
def main():
    qapp = Qt.QApplication([])

    # We need to give the absolute path to the HTML file
    # because our webview is setup to load assets from the
    # svgsynoptic library's path, not from the module's path.
    path = os.path.dirname(__file__)
    widget = ExampleSynopticWidget(os.path.join(path, "example1.html"))

    widget.show()
    qapp.exec_()
Exemple #18
0
def main():
    app = Qt.QApplication([])
    app.setApplicationName("Example GUI")
    app.setApplicationVersion("1.2.3")
    app.setOrganizationName("Taurus")
    app.setOrganizationDomain("http://www.taurus-scada.org/")
    about_dialog = AboutDialog()
    #    about_dialog.setText(txt)
    pixmap = Qt.QIcon.fromTheme("folder-open").pixmap(64, 64)
    about_dialog.setPixmap(pixmap)
    about_dialog.exec_()
Exemple #19
0
 def run(self, conn):
     # child process
     self._conn = conn
     app = Qt.QApplication.instance()
     if app is None:
         app = Qt.QApplication(['spock'])
     app.setQuitOnLastWindowClosed(False)
     self._msg_handler = MessageHandler(conn)
     TaurusManager().addJob(self.run_forever, None)
     app.exec_()
     conn.close()
     print("Quit input handler")
def test():
    import sys
    from sardana.taurus.core.tango.sardana.macroserver import registerExtensions
    registerExtensions()
    app = Qt.QApplication(sys.argv)
    taurusMacroDescriptionView = TaurusMacroDescriptionViewer(designMode=1)
    if len(sys.argv) != 2:
        taurusMacroDescriptionView.setModel("macroserver/zreszela/1")
    else:
        taurusMacroDescriptionView.setModel(sys.argv[1])
    taurusMacroDescriptionView.onMacroChanged("mv")
    taurusMacroDescriptionView.show()
    sys.exit(app.exec_())
Exemple #21
0
def main1():
    import sys
    a = Qt.QApplication([])
    panel = Qt.QWidget()
    l = Qt.QHBoxLayout(panel)
    digitWidget = Q7SegDigit()
    digitWidget.setValue(int(sys.argv[1]))
    l.addWidget(digitWidget)
    l.addWidget(Q7SegDigit())
    l.addWidget(Q7SegDigit())
    l.setSpacing(0)
    panel.setVisible(True)
    a.exec_()
Exemple #22
0
def main():
    app = Qt.QApplication(sys.argv)

    dlg = QDoubleListDlg(winTitle='foo',
                         mainLabel='bla, bla',
                         label1='1',
                         label2='2',
                         list1=['11', '22'],
                         list2=['123', '33'])
    result = dlg.exec_()

    print "Result", result
    print "list1", dlg.getAll1()
    print "list2", dlg.getAll2()
Exemple #23
0
def test2():
    '''tests taurusAttrForm'''
    import sys
    if len(sys.argv) > 1:
        model = sys.argv[1]
    else:
        model = None

    if model is None:
        model = 'bl97/pc/dummy-01'
    app = Qt.QApplication(sys.argv)
    dialog = TaurusAttrForm()
    dialog.setModel(model)
    dialog.show()
    sys.exit(app.exec_())
def main():
    import sys
    import taurus.qt.qtgui.resource
    app = Qt.QApplication(sys.argv)

    pixmaps = {}
    choices = [['TaurusForm', 'TaurusTrend'], ['TaurusPlot', 'Qub']]
    for row in choices:
        for k in row:
            pixmaps[k] = taurus.qt.qtgui.resource.getPixmap(
                ':/snapshot/%s.png' % k)

    print GraphicalChoiceDlg.getChoice(parent=None, title='Panel chooser', msg='Choose the type of Panel:', choices=choices, pixmaps=pixmaps)

    sys.exit()
def main3():
    asMimeData = True
    app = Qt.QApplication([])
    dlg = Qt.QDialog()
    dlg.setWindowTitle('Archiving Tree')
    dlg.setWindowIcon(Qt.QIcon("logos:taurus.png"))
    layout = Qt.QVBoxLayout()
    w = TaurusModelChooser(
        parent=dlg
    )  #, selectables=selectables, host=host, singleModel=singleModel)
    layout.addWidget(w)
    dlg.setLayout(layout)
    w.updateModels.connect(dlg.accept)
    dlg.exec_()
    return w.getListedModels(
        asMimeData=asMimeData), (dlg.result() == dlg.Accepted)
Exemple #26
0
def TaurusValueComboboxTest():
    '''tests TaurusValueCombobox '''
    model = sys.argv[1]
    names = [
        ('name0', 0),
        ('name1', 1),
        ('name2', 2),
        ('name3', 3)
    ]
    a = Qt.QApplication([])
    w = TaurusValueComboBox()
    w.setModel(model)
    w.addValueNames(names)
    # w.setModel(model)
    #w.autoApply = True
    w.show()
    return a.exec_()
Exemple #27
0
def test3():
    '''tests taurusCommandsForm'''
    import sys
    if len(sys.argv) > 1:
        model = sys.argv[1]
    else:
        model = None

    if model is None:
        model = 'bl97/pc/dummy-01'
    app = Qt.QApplication(sys.argv)
    dialog = TaurusCommandsForm()
    dialog.setModel(model)
    dialog.show()
    #    dialog.getSplitter().setSizes([10,220])

    sys.exit(app.exec_())
Exemple #28
0
def main():
    app = Qt.QApplication([])

    class Listener(object):
        def on_accept(self):
            print "user selected", self.panel.value()

    d = dict(
        prompt="What's your favourite car brand?",
        data_type=["Mazda", "Skoda", "Citroen", "Mercedes", "Audi", "Ferrari"],
        default_value="Mercedes")
    w = TaurusInputPanel(d)
    l = Listener()
    l.panel = w
    w.buttonBox().accepted.connect(l.on_accept)
    w.show()
    app.exec_()
Exemple #29
0
def main2():
    app = Qt.QApplication(sys.argv)

    curves = [
        curveprops.CurveConf(xsrc='',
                             ysrc='tango://host:1000/a/b/c/d',
                             properties=None,
                             title="tangocurve",
                             vis=Qwt5.QwtPlot.yLeft),
        curveprops.CurveConf(xsrc='=[1,2,3]',
                             ysrc='=#2.x**2',
                             properties=None,
                             title="parab",
                             vis=Qwt5.QwtPlot.yLeft)
    ]
    form = TaurusPlotConfDlg(curves=curves)
    form.show()
    sys.exit(app.exec_())
Exemple #30
0
    def _buildWidgets(self, module_name, path, recursive=True):
        import taurus.qt.qtgui.base

        if Qt.QApplication.instance() is None:
            app = Qt.QApplication([])

        elems = os.listdir(path)
        taurus_ret, qt_ret = {}, {}
        if not '__init__.py' in elems:
            return taurus_ret, qt_ret

        try:
            m = __import__(module_name, fromlist=['*'], level=0)
            dir_names = dir(m)
            for dir_name in dir_names:
                if dir_name.startswith("_"):
                    continue
                try:
                    attr = getattr(m, dir_name)
                    if issubclass(attr, Qt.QWidget):
                        package = m.__package__
                        qt_ret[dir_name] = package, attr
                        if issubclass(attr,
                                      taurus.qt.qtgui.base.TaurusBaseWidget):
                            taurus_ret[dir_name] = package, attr
                except Exception as e:
                    pass
        except Exception as e:
            return taurus_ret, qt_ret

        if not recursive:
            return taurus_ret, qt_ret

        for elem in elems:
            abs_elem = os.path.join(path, elem)
            if (not elem.startswith('.')) and os.path.isdir(abs_elem) and \
               (not elem in self.skip_modules):
                m_name = os.path.splitext(elem)[0]
                new_module_name = '%s.%s' % (module_name, m_name)
                new_taurus_ret, new_qt_ret = self._buildWidgets(
                    new_module_name, abs_elem, True)
                taurus_ret.update(new_taurus_ret)
                qt_ret.update(new_qt_ret)
        return taurus_ret, qt_ret