コード例 #1
0
    def __init__(self, chb_names, parent=None):
        """Set up the ui and create connections."""
        super().__init__(parent)
        self.setWindowTitle(_QCoreApplication.translate('', "Select Tabs"))
        self.resize(250, 400)
        self.setFont(_font)

        main_layout = _QVBoxLayout()
        vertical_layout = _QVBoxLayout()
        group_box = _QGroupBox(
            _QCoreApplication.translate('', "Select Tabs to Show"))
        group_box.setLayout(vertical_layout)
        group_box.setFont(_font_bold)
        main_layout.addWidget(group_box)
        self.setLayout(main_layout)

        self.chb_names = chb_names
        for name in self.chb_names:
            name_split = name.split('_')
            label = ' '.join([s.capitalize() for s in name_split])
            chb = _QCheckBox(_QCoreApplication.translate('', label))
            setattr(self, 'chb_' + name, chb)
            vertical_layout.addWidget(chb)
            chb.setFont(_font)

        self.pbt_apply = _QPushButton(
            _QCoreApplication.translate('', "Apply Changes"))
        self.pbt_apply.setMinimumSize(_QSize(0, 40))
        self.pbt_apply.setFont(_font_bold)
        vertical_layout.addWidget(self.pbt_apply)

        self.pbt_apply.clicked.connect(self.emit_tab_selection_signal)
コード例 #2
0
 def __init__(self, parent=None):
     """Initialize widget and add figure canvas."""
     super(MplWidget, self).__init__(parent)
     self.canvas = MplCanvas()
     self.vbl = _QVBoxLayout()
     self.vbl.addWidget(self.canvas)
     self.toolbar = _Toolbar(self.canvas, self)
     self.vbl.addWidget(self.toolbar)
     self.setLayout(self.vbl)
コード例 #3
0
    def __init__(self, parent=None):
        """Add figure canvas to layout."""
        super().__init__(parent)
        self.setFont(_font)
        self.figure = _Figure()
        self.canvas = _FigureCanvas(self.figure)
        self.ax = self.figure.add_subplot(111)

        _layout = _QVBoxLayout()
        _layout.addWidget(self.canvas)
        self.toolbar = _Toolbar(self.canvas, self)
        _layout.addWidget(self.toolbar)
        self.setLayout(_layout)
コード例 #4
0
    def add_widgets_next_to_plot(self, widget_list):
        """Add widgets on the side of plot 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 = _QVBoxLayout()
            _layout.setContentsMargins(0, 0, 0, 0)
            for wg in lt:
                if isinstance(wg, _QPushButton):
                    wg.setMinimumHeight(45)
                    wg.setFont(_font_bold)
                _layout.addWidget(wg)
            self.horizontal_layout_1.insertLayout(idx, _layout)
コード例 #5
0
    def __init__(self, parent=None):
        """Add table widget and copy button."""
        super().__init__(parent)
        self.setFont(_font)

        self.setWindowTitle(_QCoreApplication.translate('', "Statistics"))
        self.tbl_results = _QTableWidget()
        self.tbl_results.setAlternatingRowColors(True)
        self.tbl_results.horizontalHeader().setStretchLastSection(True)
        self.tbl_results.horizontalHeader().setDefaultSectionSize(120)

        self.pbt_copy = _QPushButton(
            _QCoreApplication.translate('', "Copy to clipboard"))
        self.pbt_copy.clicked.connect(self.copy_to_clipboard)
        self.pbt_copy.setFont(_font_bold)

        _layout = _QVBoxLayout()
        _layout.addWidget(self.tbl_results)
        _layout.addWidget(self.pbt_copy)
        self.setLayout(_layout)
        self.table_df = None

        self.resize(500, 200)
コード例 #6
0
ファイル: databasewidgets.py プロジェクト: lnls-ima/ima-utils
    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()
コード例 #7
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)