예제 #1
0
파일: model.py 프로젝트: floubar/datalogger
 def tickStrings(self, values, scale, spacing):
     # PySide's QTime() initialiser fails miserably and dismisses args/kwargs
     return [
         QtCore.QDateTime(1970, 1, 1, 1,
                          0).addSecs(value).toString('hh:mm:ss')
         for value in values
     ]
예제 #2
0
 def makeWidget(self):
     opts = self.param.opts
     w = QtWidgets.QDateTimeEdit(
         QtCore.QDateTime(QtCore.QDate.currentDate(),
                          QtCore.QTime.currentTime()))
     w.setCalendarPopup(True)
     if 'format' not in opts:
         opts['format'] = 'dd/MM/yyyy hh:mm'
     w.setDisplayFormat(opts['format'])
     w.sigChanged = w.dateTimeChanged
     w.value = w.dateTime
     w.setValue = w.setDateTime
     return w
예제 #3
0
 def param_to_dict(cls, param):
     config = dict()
     for child in param.children():
         if 'group' in child.opts['type']:
             config[child.name()] = cls.param_to_dict(child)
         else:
             if child.opts['type'] == 'datetime':
                 config[child.name()] = datetime.fromtimestamp(
                     child.value().toSecsSinceEpoch()
                 )  # convert QDateTime to python datetime
             elif child.opts['type'] == 'date':
                 qdt = QtCore.QDateTime()
                 qdt.setDate(child.value())
                 pdt = datetime.fromtimestamp(qdt.toSecsSinceEpoch())
                 config[child.name()] = pdt.date()
             elif child.opts['type'] == 'list':
                 config[child.name()] = child.opts['limits']
             else:
                 config[child.name()] = child.value()
     return config
예제 #4
0
    def edit_entry(self):
        row = self.ui.tabel_erfolge.selectedItems()[0].row()

        self.ui.mw_delete_button.setEnabled(False)
        self.ui.mw_edit_button.setEnabled(False)
        self.ui.mw_button_new.setEnabled(False)
        self.ui.mw_sammeln_button.setEnabled(False)
        self.ui.mw_button_save.setEnabled(False)

        date = self.ui.tabel_erfolge.item(row, 1).text()
        qdate = QtCore.QDateTime(int(date[0:4]), int(date[5:7]), int(date[8:]),
                                 0, 0, 0, 0)
        self.ui.mw_ae_date.setDateTime(qdate)
        self.ui.mw_ae_text.setText(self.ui.tabel_erfolge.item(row, 4).text())
        self.ui.mw_ae_cat.setCurrentText('Sonstige')
        self.ui.mw_ae_cat.setCurrentText(
            self.ui.tabel_erfolge.item(row, 3).text())
        self._show_entry_widgets()
        self.ui.mw_button_save_edit.show()
        self.ui.tabel_erfolge.removeRow(row)
예제 #5
0
class ParameterEx:
    params = [
        {'title': 'Groups:', 'name': 'groups', 'type': 'group', 'children': [
            {'title': 'A visible group:', 'name': 'agroup', 'type': 'group', 'children': []},
            {'title': 'An hidden group:', 'name': 'bgroup', 'type': 'group', 'children': [], 'visible': False},  # this
            # visible option is not available in usual pyqtgraph group
        ]},

        {'title': 'Numbers:', 'name': 'numbers', 'type': 'group', 'children': [
            {'title': 'Standard float', 'name': 'afloat', 'type': 'float', 'value': 20., 'min': 1.,
             'tip': 'displays this text as a tooltip'},
            {'title': 'Linear Slide float', 'name': 'linearslidefloat', 'type': 'slide', 'value': 50, 'default': 50,
             'min': 0,
             'max': 123, 'subtype': 'linear'},
            {'title': 'Log Slide float', 'name': 'logslidefloat', 'type': 'slide', 'value': 50, 'default': 50,
             'min': 1e-5,
             'max': 1e5, 'subtype': 'log'},
        ]},

        {'title': 'Booleans:', 'name': 'booleans', 'type': 'group', 'children': [
            {'title': 'Standard bool', 'name': 'abool', 'type': 'bool', 'value': True},
            {'title': 'bool push', 'name': 'aboolpush', 'type': 'bool_push', 'value': True, 'label': 'action'},
            {'title': 'A led', 'name': 'aled', 'type': 'led', 'value': False, 'tip': 'a led you cannot toggle'},
            {'title': 'A led', 'name': 'anotherled', 'type': 'led_push', 'value': True, 'tip': 'a led you can toggle'},
        ]},

        {'title': 'DateTime:', 'name': 'datetimes', 'type': 'group', 'children': [
            {'title': 'Time:', 'name': 'atime', 'type': 'time', 'value': QtCore.QTime.currentTime()},
            {'title': 'Date:', 'name': 'adate', 'type': 'date', 'value': QtCore.QDate.currentDate(),
             'format': 'dd/MM/yyyy'},
            {'title': 'DateTime:', 'name': 'adatetime', 'type': 'date_time',
             'value': QtCore.QDateTime(QtCore.QDate.currentDate(), QtCore.QTime.currentTime()),
             'format': 'MM/dd/yyyy hh:mm', 'tip': 'displays this text as a tooltip'},
        ]},
        {'title': 'An action', 'name': 'action', 'type': 'action'},  # action whose displayed text corresponds to title

        {'title': 'Lists:', 'name': 'lists', 'type': 'group', 'children': [
            {'title': 'Standard list:', 'name': 'alist', 'type': 'list', 'limits': ['a value', 'another one']},
            {'title': 'List with add:', 'name': 'anotherlist', 'type': 'list', 'limits': ['a value', 'another one'],
             'show_pb': True, 'tip': 'when using the "show_pb" option, displays a plus button to add elt to the list'},
        ]},
        {'title': 'Browsing files:', 'name': 'browser', 'type': 'group', 'children': [
            {'title': 'Look for a file:', 'name': 'afile', 'type': 'browsepath', 'value': '', 'filetype': True,
             'tip': 'If filetype is True select a file otherwise a directory'},
            {'title': 'Look for a dir:', 'name': 'adir', 'type': 'browsepath', 'value': '', 'filetype': False,
             'tip': 'If filetype is True select a file otherwise a directory'},

        ]},
        {'title': 'Selectable items:', 'name': 'itemss', 'type': 'group', 'children': [
            {'title': 'Selectable items', 'name': 'items', 'type': 'itemselect',
             'value': dict(all_items=['item1', 'item2', 'item3'], selected=['item2']),
             'tip': 'Press Ctrl+click  to select items in any order'},
            {'title': 'Selectable items', 'name': 'itemsbis', 'type': 'itemselect',
             'value': dict(all_items=['item1', 'item2', 'item3'], selected=['item2']),
             'tip': 'If show_pb is True, user can add items to the list', 'show_pb': True},
        ]},
        {'title': 'Plain text:', 'name': 'texts', 'type': 'group', 'children': [
            {'title': 'Standard str', 'name': 'atte', 'type': 'str', 'value': 'this is a string you can edit'},
            {'title': 'Plain text', 'name': 'text', 'type': 'text', 'value': 'this is some text'},
            {'title': 'Plain text', 'name': 'textpb', 'type': 'text_pb', 'value': 'this is some text',
             'tip': 'If text_pb type is used, user can add text to the parameter'},
        ]},

        {'title': 'Tables:', 'name': 'tables', 'type': 'group', 'children': [
            {'title': 'Table widget', 'name': 'tablewidget', 'type': 'table', 'value':
                OrderedDict(key1='data1', key2=24), 'header': ['keys', 'limits'], 'height': 100},
            {'title': 'Table view', 'name': 'tabular_table', 'type': 'table_view',
             'delegate': pymodaq.daq_utils.gui_utils.widgets.table.SpinBoxDelegate, 'menu': True,
             'value': pymodaq.daq_utils.gui_utils.widgets.table.TableModel([[0.1, 0.2, 0.3]], ['value1', 'value2', 'value3']),
             'tip': 'The advantage of the Table model lies in its modularity.\n For concrete examples see the'
                    'TableModelTabular and the TableModelSequential custom models in the'
                    ' pymodaq.daq_utils.scanner module'},
        ]},  # The advantage of the Table model lies in its modularity for concrete examples see the
        # TableModelTabular and the TableModelSequential custom models in the pymodaq.daq_utils.scanner module
    ]

    def __init__(self, tree):
        self.parameter_tree = tree

        self.settings = Parameter.create(name='settings', type='group', children=self.params)
        self.parameter_tree.setParameters(self.settings, showTop=False)

        self.settings.sigTreeStateChanged.connect(self.parameter_tree_changed)

    def parameter_tree_changed(self, param, changes):
        """
        """

        for param, change, data in changes:
            path = self.settings.childPath(param)
            if change == 'childAdded':
                pass  # Triggered when parameter is added to the tree

            elif change == 'value':
                print(f'The parameter {param.name()} changed its value to {data}')

            elif change == 'parent':
                pass  # triggered when a param is removed from the tree
예제 #6
0
 def _interpretValue(self, v):
     return QtCore.QDateTime(v)
예제 #7
0
objects = {
    "QtWidgets": {
        "QWidget": QtWidgets.QWidget(),
        "QCheckBox": QtWidgets.QCheckBox(checked=True),
        "QDoubleSpinBox": QtWidgets.QDoubleSpinBox(value=10.0),
        "QLineEdit": QtWidgets.QLineEdit("coucou"),
        "QPlainTextEdit": QtWidgets.QPlainTextEdit("coucou"),
        "QSpinBox": QtWidgets.QSpinBox(value=20),
        "QPushButton": QtWidgets.QPushButton(),
    },
    "PyQt_pickable": {
        "QByteArray": QtCore.QByteArray(bytes(range(256))),
        "QColor": QtGui.QColor(10, 20, 30, 40),
        ## "QChar": # n'a plus l'air d'exister dans PyQt5
        "QDate": QtCore.QDate(2020, 10, 31),
        "QDateTime": QtCore.QDateTime(2020, 10, 31, 20, 30),
        "QKeySequence": QtGui.QKeySequence(),
        ## "QLatin1Char": # n'a plus l'air d'exister dans PyQt5
        ## "QLatin1String"# n'a plus l'air d'exister dans PyQt5
        "QLine": QtCore.QLine(QtCore.QPoint(0, 1), QtCore.QPoint(2, 3)),
        "QLineF": QtCore.QLineF(QtCore.QPoint(0.0, 1.1), QtCore.QPoint(2.2, 3.3)),
        "QPen": QtGui.QPen(),
        "QBrush": QtGui.QBrush(),
        "QPoint": QtCore.QPoint(0, 1),
        "QPointF": QtCore.QPointF(0.0, 1.1),
        "QPolygon": QtGui.QPolygon([QtCore.QPoint(0, 1), QtCore.QPoint(2, 3)]),
        "QPolygonF": QtGui.QPolygonF([QtCore.QPoint(0.0, 1.1), QtCore.QPoint(2.2, 3.3)]),
        "QRect": QtCore.QRect(QtCore.QPoint(0, 1), QtCore.QPoint(2, 3)),
        "QRectF": QtCore.QRectF(QtCore.QPoint(0.0, 1.1), QtCore.QPoint(2.2, 3.3)),
        "QSize": QtCore.QSize(10, 20),
        "QSizeF": QtCore.QSizeF(10.5, 20.5),