def __init__(self, parent=None):
     super().__init__(parent=parent)
     self.main_widget = AdvancedOptionsWidget(parent=parent)
     self.main_layout = _QHBoxLayout()
     self.main_layout.addWidget(self.main_widget)
     self.setLayout(self.main_layout)
     self.setWindowTitle(_QCoreApplication.translate(
         '', "Advanced Options"))
     self.setWhatsThis(
         _QCoreApplication.translate(
             '', 'Advanced devices and measurement options.'))
Beispiel #2
0
 def __init__(self, parent=None):
     """Set up the ui."""
     super().__init__(parent)
     self.setWindowTitle(_QCoreApplication.translate('', "Log"))
     self.resize(1000, 460)
     self.setFont(_font)
     self.te_text = _QTextEdit()
     self.te_text.setReadOnly(True)
     self.te_text.setVerticalScrollBarPolicy(_Qt.ScrollBarAlwaysOn)
     main_layout = _QHBoxLayout()
     main_layout.addWidget(self.te_text)
     self.setLayout(main_layout)
Beispiel #3
0
    def add_widgets_next_to_table(self, widget_list):
        """Add widgets on the side of table widget."""
        if not isinstance(widget_list, (list, tuple)):
            widget_list = [[widget_list]]

        if not isinstance(widget_list[0], (list, tuple)):
            widget_list = [widget_list]

        for idx, lt in enumerate(widget_list):
            _layout = _QHBoxLayout()
            for wg in lt:
                if isinstance(wg, _QPushButton):
                    wg.setMinimumHeight(45)
                    wg.setFont(_font_bold)
                _layout.addWidget(wg)
            self.vertical_layout_2.insertLayout(idx, _layout)
Beispiel #4
0
    def __init__(self,
                 parent=None,
                 database_name=None,
                 table_name=None,
                 mongo=None,
                 server=None,
                 number_rows=100,
                 max_number_rows=1000,
                 max_str_size=100,
                 hidden_columns=None):
        """Set up the ui."""
        super().__init__(parent)

        if hidden_columns is None:
            self._hidden_columns = []
        else:
            self._hidden_columns = hidden_columns

        self.database_name = database_name
        self.table_name = table_name
        self.mongo = mongo
        self.server = server
        self.database_collection = _database.DatabaseCollection(
            database_name=self.database_name,
            collection_name=self.table_name,
            mongo=self.mongo,
            server=self.server)

        self._number_rows = number_rows
        self._max_number_rows = max_number_rows
        self._max_str_size = max_str_size

        vlayout = _QVBoxLayout()
        hlayout = _QHBoxLayout()

        self.table = _QTableWidget()
        self.table.setAlternatingRowColors(True)
        self.table.verticalHeader().hide()
        self.table.horizontalHeader().setStretchLastSection(True)
        self.table.horizontalHeader().setDefaultSectionSize(120)
        self.table.setSelectionBehavior(_QAbstractItemView.SelectRows)

        self.sb_initial_id = _QSpinBox()
        self.sb_initial_id.setMinimumWidth(100)
        self.sb_initial_id.setButtonSymbols(2)
        self.sb_initial_id.editingFinished.connect(self.change_initial_id)
        hlayout.addStretch(0)
        hlayout.addWidget(_QLabel("Initial ID:"))
        hlayout.addWidget(self.sb_initial_id)

        self.sb_max_number_rows = _QSpinBox()
        self.sb_max_number_rows.setMinimumWidth(100)
        self.sb_max_number_rows.setButtonSymbols(2)
        self.sb_max_number_rows.setMaximum(self._max_number_rows)
        self.sb_max_number_rows.setValue(self._number_rows)
        self.sb_max_number_rows.editingFinished.connect(self.change_max_rows)
        hlayout.addWidget(_QLabel("Maximum number of rows:"))
        hlayout.addWidget(self.sb_max_number_rows)

        self.sb_number_rows = _QSpinBox()
        self.sb_number_rows.setMinimumWidth(100)
        self.sb_number_rows.setButtonSymbols(2)
        self.sb_number_rows.setReadOnly(True)
        self.sb_number_rows.setMaximum(self._max_number_rows)
        self.sb_number_rows.setValue(self._number_rows)
        hlayout.addWidget(_QLabel("Current number of rows:"))
        hlayout.addWidget(self.sb_number_rows)

        vlayout.addWidget(self.table)
        vlayout.addLayout(hlayout)
        self.setLayout(vlayout)

        self.column_names = []
        self.data_types = []
        self.data = []
        self.update_table()
Beispiel #5
0
    def add_widgets(self):
        """Add widgets and layouts."""
        # Layouts
        self.vertical_layout_1 = _QVBoxLayout()
        self.vertical_layout_2 = _QVBoxLayout()
        self.vertical_layout_2.setSpacing(20)
        self.vertical_layout_3 = _QVBoxLayout()
        self.horizontal_layout_1 = _QHBoxLayout()
        self.horizontal_layout_2 = _QHBoxLayout()
        self.horizontal_layout_3 = _QHBoxLayout()
        self.horizontal_layout_4 = _QHBoxLayout()

        # Plot Widget
        self.pw_plot = _pyqtgraph.PlotWidget()
        brush = _QBrush(_QColor(255, 255, 255))
        brush.setStyle(_Qt.NoBrush)
        self.pw_plot.setBackgroundBrush(brush)
        self.pw_plot.setForegroundBrush(brush)
        self.horizontal_layout_1.addWidget(self.pw_plot)

        # Read button
        self.pbt_read = _QPushButton(_QCoreApplication.translate('', "Read"))
        self.pbt_read.setMinimumSize(_QSize(0, 45))
        self.pbt_read.setFont(_font_bold)
        self.vertical_layout_2.addWidget(self.pbt_read)

        # Monitor button
        self.pbt_monitor = _QPushButton(
            _QCoreApplication.translate('', "Monitor"))
        self.pbt_monitor.setMinimumSize(_QSize(0, 45))
        self.pbt_monitor.setFont(_font_bold)
        self.pbt_monitor.setCheckable(True)
        self.pbt_monitor.setChecked(False)
        self.vertical_layout_2.addWidget(self.pbt_monitor)

        # Monitor frequency
        label = _QLabel(_QCoreApplication.translate('', "Frequency [Hz]:"))
        label.setAlignment(_Qt.AlignRight | _Qt.AlignTrailing
                           | _Qt.AlignVCenter)
        self.horizontal_layout_3.addWidget(label)

        self.sbd_monitor_freq = _QDoubleSpinBox()
        self.sbd_monitor_freq.setDecimals(2)
        self.sbd_monitor_freq.setMinimum(0.01)
        self.sbd_monitor_freq.setMaximum(100.00)
        self.sbd_monitor_freq.setProperty("value", 1)
        self.horizontal_layout_3.addWidget(self.sbd_monitor_freq)
        self.vertical_layout_2.addLayout(self.horizontal_layout_3)

        # Group box with read and monitor buttons
        self.group_box = _QGroupBox()
        self.group_box.setMinimumSize(_QSize(270, 0))
        self.group_box.setTitle("")
        self.group_box.setLayout(self.vertical_layout_2)

        # Table widget
        self.tbl_table = _QTableWidget()
        sizePolicy = _QSizePolicy(_QSizePolicy.Expanding,
                                  _QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.tbl_table.sizePolicy().hasHeightForWidth())
        self.tbl_table.setSizePolicy(sizePolicy)
        self.tbl_table.setVerticalScrollBarPolicy(_Qt.ScrollBarAlwaysOn)
        self.tbl_table.setHorizontalScrollBarPolicy(_Qt.ScrollBarAsNeeded)
        self.tbl_table.setEditTriggers(_QAbstractItemView.NoEditTriggers)
        self.tbl_table.setColumnCount(0)
        self.tbl_table.setRowCount(0)
        self.tbl_table.horizontalHeader().setVisible(True)
        self.tbl_table.horizontalHeader().setCascadingSectionResizes(False)
        self.tbl_table.horizontalHeader().setDefaultSectionSize(200)
        self.tbl_table.horizontalHeader().setHighlightSections(True)
        self.tbl_table.horizontalHeader().setMinimumSectionSize(80)
        self.tbl_table.horizontalHeader().setStretchLastSection(True)
        self.tbl_table.verticalHeader().setVisible(False)
        self.horizontal_layout_4.addWidget(self.tbl_table)

        # Tool buttons
        self.tbt_autorange = _QToolButton()
        self.tbt_autorange.setIcon(_utils.get_icon(_autorange_icon_file))
        self.tbt_autorange.setIconSize(_icon_size)
        self.tbt_autorange.setCheckable(True)
        self.tbt_autorange.setToolTip(
            _QCoreApplication.translate('', 'Turn on plot autorange.'))
        self.vertical_layout_3.addWidget(self.tbt_autorange)

        self.tbt_save = _QToolButton()
        self.tbt_save.setIcon(_utils.get_icon(_save_icon_file))
        self.tbt_save.setIconSize(_icon_size)
        self.tbt_save.setToolTip(
            _QCoreApplication.translate('', 'Save table data to file.'))
        self.vertical_layout_3.addWidget(self.tbt_save)

        self.tbt_copy = _QToolButton()
        self.tbt_copy.setIcon(_utils.get_icon(_copy_icon_file))
        self.tbt_copy.setIconSize(_icon_size)
        self.tbt_copy.setToolTip(
            _QCoreApplication.translate('', 'Copy table data.'))
        self.vertical_layout_3.addWidget(self.tbt_copy)

        self.pbt_stats = _QToolButton()
        self.pbt_stats.setIcon(_utils.get_icon(_stats_icon_file))
        self.pbt_stats.setIconSize(_icon_size)
        self.pbt_stats.setToolTip(
            _QCoreApplication.translate('', 'Show data statistics.'))
        self.vertical_layout_3.addWidget(self.pbt_stats)

        self.pbt_remove = _QToolButton()
        self.pbt_remove.setIcon(_utils.get_icon(_delete_icon_file))
        self.pbt_remove.setIconSize(_icon_size)
        self.pbt_remove.setToolTip(
            _QCoreApplication.translate('',
                                        'Remove selected lines from table.'))
        self.vertical_layout_3.addWidget(self.pbt_remove)

        self.tbt_clear = _QToolButton()
        self.tbt_clear.setIcon(_utils.get_icon(_clear_icon_file))
        self.tbt_clear.setIconSize(_icon_size)
        self.tbt_clear.setToolTip(
            _QCoreApplication.translate('', 'Clear table data.'))
        self.vertical_layout_3.addWidget(self.tbt_clear)

        spacer_item = _QSpacerItem(20, 100, _QSizePolicy.Minimum,
                                   _QSizePolicy.Fixed)
        self.vertical_layout_3.addItem(spacer_item)
        self.horizontal_layout_4.addLayout(self.vertical_layout_3)

        self.horizontal_layout_2.addWidget(self.group_box)
        self.horizontal_layout_2.addLayout(self.horizontal_layout_4)
        self.vertical_layout_1.addLayout(self.horizontal_layout_1)
        self.vertical_layout_1.addLayout(self.horizontal_layout_2)
        self.setLayout(self.vertical_layout_1)