Пример #1
1
    def __init__(self):
        QMainWindow.__init__(self)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
        self.setWindowTitle("application main window")

        self.file_menu = QMenu('&File', self)
        self.file_menu.addAction('&Quit', self.fileQuit,
                                 QtCore.Qt.CTRL + QtCore.Qt.Key_Q)
        self.menuBar().addMenu(self.file_menu)

        self.help_menu = QMenu('&Help', self)
        self.menuBar().addSeparator()
        self.menuBar().addMenu(self.help_menu)

        self.help_menu.addAction('&About', self.about)



        self.filename = "Fields_global.h5"
        self.f=h5.File(self.filename)
        dset = self.f["/1d_global/potential"]

        print "Attention: the dataset must be 4 dimensions"

        #> the main layout: left part (for the hdf5 tree view) and right part (for the plot area)
        self.main_widget = QWidget(self)

        #> if not putting splitter into a layout, the widgets in splitter do not fill the main windows
        #> (may exceed the app windows, so that the figures are partially shown ).
        layout = QVBoxLayout(self.main_widget)
        hSplitter = QSplitter(self.main_widget)
        layout.addWidget(hSplitter)


        #> the left part: the hdf5 tree view
        h5tree = QWidget()
        treeview = QTreeView(h5tree)
        self.model = HDFTreeModel([])
        self.model.openFile(self.filename, 'r+')
        treeview.setModel(self.model)

        treeview.doubleClicked.connect(self.redraw)

        hSplitter.addWidget(treeview)


        #> the right part: the plot area
        plotArea = QWidget(self.main_widget)
        sizePolicy = QSizePolicy();
        sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding);
        sizePolicy.setVerticalPolicy(QSizePolicy.Expanding);
        plotArea.setSizePolicy(sizePolicy);

        hSplitter.addWidget(plotArea)



        plotVboxlayout = QVBoxLayout(plotArea)
        self.sc = MyStaticMplCanvas(self.main_widget, dset, width=5, height=4, dpi=100)
        self.dc = MyDynamicMplCanvas(self.main_widget, dset, width=5, height=4, dpi=100)
        plotVboxlayout.addWidget(self.sc)
        plotVboxlayout.addWidget(self.dc)


        self.main_widget.setFocus()
        self.setCentralWidget(self.main_widget)

        self.statusBar().showMessage("All hail matplotlib!", 2000)
Пример #2
0
    def __init__(self):
        super().__init__()
        self.path_label = QLabel()
        self.selection_made = False
        self.old_stylesheet = self.styleSheet()
        self.path = None
        # give all space to the label
        expanding = QSizePolicy()
        expanding.setHorizontalPolicy(QSizePolicy.Expanding)
        self.path_label.setSizePolicy(expanding)
        self.file_chooser = FileChooserButton("Choose replay",
                                              QFileDialog.ExistingFile,
                                              ["osu! Replay File (*.osr)"])
        self.folder_chooser = FileChooserButton("Choose folder",
                                                QFileDialog.Directory)

        # the buttons will steal the mousePressEvent so connect them manually
        self.file_chooser.clicked.connect(self.reset_required)
        self.folder_chooser.clicked.connect(self.reset_required)

        self.file_chooser.path_chosen_signal.connect(self.handle_new_path)
        self.folder_chooser.path_chosen_signal.connect(self.handle_new_path)

        layout = QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.path_label)
        layout.addWidget(self.file_chooser)
        layout.addWidget(self.folder_chooser)
        self.setLayout(layout)
Пример #3
0
 def __init__(self):
     super().__init__()
     self.bundle = None
     self.manual_change = True
     size_policy = QSizePolicy()
     size_policy.setHorizontalPolicy(QSizePolicy.Expanding)
     size_policy.setVerticalPolicy(QSizePolicy.Expanding)
     self.setSizePolicy(size_policy)
     layout = QVBoxLayout()
     layout.setContentsMargins(0, 4, 0, 0)
     this_row = QHBoxLayout()
     this_row.addSpacing(4)
     selection_label = QLabel()
     selection_label.setText("Dieses Bild: ")
     this_row.addWidget(selection_label)
     self.keep_button = QRadioButton()
     self.keep_button.setText("behalten")
     self.keep_button.setMaximumHeight(14)
     self.keep_button.toggled.connect(self.mark_bundle)
     this_row.addWidget(self.keep_button)
     self.discard_button = QRadioButton()
     self.discard_button.setText("löschen")
     self.discard_button.setMaximumHeight(14)
     this_row.addWidget(self.discard_button)
     this_row.addStretch(1)
     layout.addLayout(this_row)
     img_scroll_area = QScrollArea()
     img_scroll_area.setSizePolicy(
         QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
     self.img_widget = ImageWidget(None)
     img_scroll_area.setWidget(self.img_widget)
     layout.addWidget(img_scroll_area, stretch=1)
     layout.addStretch()
     self.setLayout(layout)
Пример #4
0
class BatchStepList(QWidget):
    """List displayed to the left of the main Batch widgets to show the
    user which tracking setup step they are on."""
    active_style = "QLabel { background-color : #eff0f1; color : #31363b; }"
    inactive_style = "QLabel { background-color : #31363b; color : #eff0f1; }"

    def __init__(self, highlight=0, parent=None):
        super(BatchStepList, self).__init__(parent)

        self.layout = QVBoxLayout()
        self.highlight = highlight
        self.size_policy = QSizePolicy()
        self.size_policy.setHorizontalPolicy(QSizePolicy.Minimum)
        self.size_policy.setVerticalPolicy(QSizePolicy.Expanding)

        self.labels = [QLabel(l) for l in \
            ['1. Select Files',
            '2. Define Arena',
            '3. Define Female',
            '4. Set Tight Threshold',
            '5. Set Loose Threshold',
            '6. Track']]

        self.update_layout()
        
    def update_layout(self):
        for i, label in enumerate(self.labels):
            if i == self.highlight:
                label.setStyleSheet(self.active_style)
            else:
                label.setStyleSheet(self.inactive_style)
            label.setSizePolicy(self.size_policy)
            label.setFixedWidth(160)
            self.layout.addWidget(label)
        self.setLayout(self.layout)
Пример #5
0
    def __init__(self, url, *args, **kwargs):
        QWebEngineView.__init__(self, *args, **kwargs)

        self._page = QWebEnginePage(get_profile())
        self.setPage(self._page)
        self.load(url)

        # Shortcut to manually reload
        self.reload_shortcut = QShortcut('CTRL+R', self)
        self.reload_shortcut.activated.connect(self.reload)

        # Check if pages is correctly loaded
        self.loadFinished.connect(self._load_finished)

        # Shortcut to close
        self.quit_shortcut = QShortcut('CTRL+ALT+DELETE', self)
        self.quit_shortcut.activated.connect(lambda: self.close())

        # Stretch the browser
        policy = QSizePolicy()
        policy.setVerticalStretch(1)
        policy.setHorizontalStretch(1)
        policy.setVerticalPolicy(QSizePolicy.Preferred)
        policy.setHorizontalPolicy(QSizePolicy.Preferred)
        self.setSizePolicy(policy)
Пример #6
0
    def __init__(self, parent, args):
        super(CentralWidget, self).__init__(parent)
        self.layout = QHBoxLayout()
        self.setLayout(self.layout)

        self.annotator_config = AnnotatorConfigurationModel(args.config)
        self.annotation = AnnotationModel(args.video, args.output,
                                          self.annotator_config)

        splitter = QSplitter(Qt.Horizontal)

        self.canvas = ImageCanvas(self, self.annotator_config, self.annotation)
        splitter.addWidget(self.canvas)

        self.sidebar = QWidget(self)
        self.sidebar.setMinimumWidth(450)
        splitter.addWidget(self.sidebar)
        self.sidebar_layout = QVBoxLayout()
        self.sidebar.setLayout(self.sidebar_layout)

        self.video_control = VideoControl(self, self.annotation, self.canvas)
        self.sidebar_layout.addWidget(self.video_control)
        self.config_editor = ConfigurationEditor(self, self.annotator_config)
        self.sidebar_layout.addWidget(self.config_editor)
        self.ann_editor = AnnotationEditor(self, self.annotation, self.canvas)
        self.sidebar_layout.addWidget(self.ann_editor)

        policy = QSizePolicy()
        policy.setHorizontalPolicy(QSizePolicy.Maximum)
        policy.setVerticalPolicy(QSizePolicy.Maximum)
        self.canvas.setSizePolicy(policy)
        splitter.setStretchFactor(0, 1)
        splitter.setStretchFactor(1, 0)

        self.layout.addWidget(splitter)
Пример #7
0
    def __init__(self):
        super().__init__()

        visualize_button = PushButton("Visualization")
        visualize_button.clicked.connect(self.visualize_button_clicked)
        # to style it in our stylesheet
        visualize_button.setObjectName("bigButton")

        bulk_investigation_button = PushButton("Investigation / Settings")
        bulk_investigation_button.clicked.connect(
            self.bulk_investigation_button_clicked)
        bulk_investigation_button.setObjectName("bigButton")

        for button in [visualize_button, bulk_investigation_button]:
            font = button.font()
            font.setPointSize(30)
            button.setFont(font)

            expanding = QSizePolicy()
            expanding.setHorizontalPolicy(QSizePolicy.Expanding)
            expanding.setVerticalPolicy(QSizePolicy.Expanding)
            button.setSizePolicy(expanding)

        layout = QHBoxLayout()
        layout.addWidget(visualize_button)
        layout.addWidget(bulk_investigation_button)
        layout.setContentsMargins(15, 15, 15, 10)
        self.setLayout(layout)
Пример #8
0
    def __init__(self, parent, binpath):
        super().__init__(parent)
        sizePolicy = QSizePolicy()
        sizePolicy.setHorizontalPolicy(QSizePolicy.Maximum)
        sizePolicy.setVerticalPolicy(QSizePolicy.Maximum)
        #self.setSizePolicy(sizePolicy)
        self.setMouseTracking(True)

        self.on_selection = False
        self.selected = False
        self.c = Communicate()

        self.start_position = QPoint(0,0)
        self.last_position = QPoint(0,0)

        image = (
            b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
            b"\x00\x00\xFF\xFF\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00"
            b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00"
            b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00"
            b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00"
            b"\x00\x00\xFF\xFF\x00\x00\x00\x00\x00\x00\x00\x00\xFF\xFF\x00\x00"
            b"\x00\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00\x00\xFF\xFF\x00\x00"
            b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00")
        im = QImage(image, 8,8, QImage.Format_RGB16)
        im = im.scaled(64,64)
        self.crop = QPixmap()
        self.crop.convertFromImage(im)
Пример #9
0
    def __init__(self, parent=None):
        super(PlotWidget1D, self).__init__()
        self.parent = parent

        # data4d has four dimensions, the first is time
        self.prefix = 'data'
        self.data4d = collect("/Fields/", "Phi_global_avg", prefix=self.prefix)
        self.dataName = "electric potential"

        sizePolicy = QSizePolicy()
        sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding)
        sizePolicy.setVerticalPolicy(QSizePolicy.Expanding)
        self.setSizePolicy(sizePolicy)

        self.plotVboxlayout = QVBoxLayout(self)

        self.tab_widget = QTabWidget(self)
        self.plotVboxlayout.addWidget(self.tab_widget)

        # matplotlib figure tab

        self.sc = MyStaticMplCanvas1D(self, self.data4d, title=self.dataName)
        self.sc.draw()
        self.tab_widget.addTab(self.sc, "Figures")

        # data tab
        self.data_widget = QTableWidget(self)
        self.set_data_widget(self.data4d[0, 0, :, :])
        self.tab_widget.addTab(self.data_widget, "data")

        #> The slider
        self.sp_widget = QWidget(self)
        self.sp_layout = QHBoxLayout(self.sp_widget)

        self.label = QLabel("time")
        self.plainTextEdit = QTextEdit("0")
        self.plainTextEdit.setMaximumHeight(20)
        self.plainTextEdit.setMaximumWidth(100)
        self.sp = QSlider(QtCore.Qt.Horizontal)
        self.sp.setMinimum(0)
        self.sp.setMaximum(self.data4d.shape[0] - 1)
        self.sp.setTickPosition(QSlider.TicksBelow)
        self.sp.setTickInterval(1)
        self.sp.valueChanged.connect(self.timeChange)
        self.sp_layout.addWidget(self.label)
        self.sp_layout.addWidget(self.plainTextEdit)
        self.sp_layout.addWidget(self.sp)

        self.save_widget = QWidget(self)
        self.save_layout = QHBoxLayout(self.save_widget)
        self.button_saveFig = QPushButton("Save Figure")
        self.button_saveAnimation = QPushButton("Save Animation")
        self.save_layout.addWidget(self.button_saveFig)
        self.save_layout.addWidget(self.button_saveAnimation)
        self.button_saveAnimation.clicked.connect(self.save_animation)
        self.button_saveFig.clicked.connect(self.save_fig)

        #self.plotVboxlayout.addWidget(self.sc)
        self.plotVboxlayout.addWidget(self.sp_widget)
        self.plotVboxlayout.addWidget(self.save_widget)
    def on_add_button_to_list(self, button_group, layout, textedit, overide_str=None):
        """
        Adds a button to a specified button group and layout.
        :param button_group: QButtonGroup button is to be added to.
        :param layout: QLayout button is to be added to.
        :param lineedit: QLineEdit containing the new button string.
        :return:
        """
        if overide_str is not None:
            new_btn_str = overide_str
        else:
            new_btn_str = textedit.toPlainText()
            textedit.clear()
        new_btn = QPushButton(new_btn_str)
        new_btn.setFont(self.edit_font)
        new_btn.setFlat(True)
        new_btn.setCheckable(True)
        new_btn.toggle()
        size_policy = QSizePolicy()
        size_policy.setHorizontalPolicy(QSizePolicy.Expanding)
        size_policy.setVerticalPolicy(QSizePolicy.Preferred)
        new_btn.setSizePolicy(size_policy)

        button_group.addButton(new_btn)
        inset_pos = layout.count() - 2
        layout.insertWidget(inset_pos, new_btn)
Пример #11
0
 def __init__(self, task):
     self.task = task
     super().__init__(flags=Qt.WindowTitleHint | Qt.WindowCloseButtonHint
                      | Qt.WindowMinimizeButtonHint
                      | Qt.WindowMaximizeButtonHint)
     size_policy = QSizePolicy()
     size_policy.setHorizontalPolicy(QSizePolicy.MinimumExpanding)
     size_policy.setHorizontalStretch(255)
     self.setSizePolicy(size_policy)
     self.setMinimumSize(120, 36)
     self.setCursor(Qt.OpenHandCursor)
     task_layout = QVBoxLayout()
     task_layout.setContentsMargins(25, 6, 6, 6)
     first_line = QHBoxLayout()
     self.name_widget = QLabel()
     self.name_widget.setText(self.task.text)
     first_line.addWidget(self.name_widget,
                          stretch=255,
                          alignment=Qt.AlignLeading)
     self.edit_name = QLineEdit()
     self.edit_name.setText(self.task.text)
     self.edit_name.textChanged.connect(self.setTaskText)
     self.edit_name.returnPressed.connect(self.leaveEditMode)
     first_line.addWidget(self.edit_name)
     self.edit_button = QPushButton()
     self.edit_button.setFlat(True)
     self.edit_button.setIcon(QIcon("Icon/Edit.png"))
     self.edit_button.clicked.connect(self.enterEditMode)
     first_line.addWidget(self.edit_button, alignment=Qt.AlignRight)
     self.leave_edit_mode_button = QPushButton()
     self.leave_edit_mode_button.setFlat(True)
     self.leave_edit_mode_button.setIcon(QIcon("Icon/Collapse.png"))
     self.leave_edit_mode_button.clicked.connect(self.leaveEditMode)
     first_line.addWidget(self.leave_edit_mode_button,
                          alignment=Qt.AlignRight)
     del_button = QPushButton()
     del_button.setFlat(True)
     #del_button.setIcon(QCommonStyle().standardIcon(QStyle.SP_TrashIcon))
     del_button.setIcon(QIcon("Icon/Trash.png"))
     del_button.clicked.connect(self.delete_task)
     first_line.addWidget(del_button, alignment=Qt.AlignRight)
     task_layout.addLayout(first_line)
     second_line = QHBoxLayout()
     self.due_date_box = QGroupBox("Due Date")
     due_date_box_layout = QVBoxLayout()
     self.due_date_calendar = QCalendarWidget()
     if self.task.due_date:
         self.due_date_calendar.setSelectedDate(self.task.due_date)
     self.due_date_calendar.selectionChanged.connect(self.setDueDate)
     due_date_box_layout.addWidget(self.due_date_calendar)
     self.due_date_time = TimeSelector(self.task.get_due_date_time())
     self.due_date_time.time_changed.connect(self.setDueDateTime)
     due_date_box_layout.addWidget(self.due_date_time)
     self.due_date_box.setLayout(due_date_box_layout)
     second_line.addWidget(self.due_date_box, alignment=Qt.AlignLeft)
     task_layout.addLayout(second_line)
     self.setLayout(task_layout)
     self.setEditMode(False)
Пример #12
0
 def __init__(self, orientation):
     super().__init__()
     self.setOrientation(orientation)
     self.setRange(0, 0)
     self.setValue(0)
     self.setFocusPolicy(Qt.StrongFocus)
     sizePolicy = QSizePolicy()
     sizePolicy.setHorizontalPolicy(QSizePolicy.Fixed)
     sizePolicy.setVerticalPolicy(QSizePolicy.Fixed)
     self.setSizePolicy(sizePolicy)
     self.setMinimumSize(QSize(800, 25))
     self.setMaximumSize(QSize(800, 25))
     self.gatedFrames = []
Пример #13
0
 def __init__(self):
     super().__init__()
     self.frame = 0
     self.image = QImage(QPixmap(500, 500).toImage())
     self.lumen = ([], [])
     self.plaque = ([], [])
     self.hide = True
     sizePolicy = QSizePolicy()
     sizePolicy.setHorizontalPolicy(QSizePolicy.Fixed)
     sizePolicy.setVerticalPolicy(QSizePolicy.Fixed)
     self.setSizePolicy(sizePolicy)
     self.setMinimumSize(QSize(500, 500))
     self.setMaximumSize(QSize(500, 500))
    def file_specific_info_layout(self, article_dicts):

        window_size = self.geometry()

        # Fonts
        # - Label Font
        s = window_size.height() / 20
        min_s = 10
        if s < min_s:
            lbl_font_size = min_s
        else:
            lbl_font_size = s
        lbl_font = QFont('SansSerif', lbl_font_size)
        lbl_font.setBold(True)

        # - Edit Font
        s = window_size.height() / 25
        min_s = 7
        if s < min_s:
            edit_font_size = min_s
        else:
            edit_font_size = s
        edit_font = QFont('SansSerif', edit_font_size)

        # - Expand Horizontally
        horSizePolicy = QSizePolicy()
        horSizePolicy.setVerticalPolicy(QSizePolicy.Preferred)
        horSizePolicy.setHorizontalPolicy(QSizePolicy.Expanding)

        file_info_widget = QWidget()
        vbox = QVBoxLayout(file_info_widget)

        for dictionary in article_dicts:

            for key, value in dictionary.items():
                lbl = QLabel(str(key))
                lbl.setFont(lbl_font)
                lbl.setSizePolicy(horSizePolicy)
                vbox.addWidget(lbl)

                edit = QLineEdit()
                edit.setFont(edit_font)
                edit.setText(str(value))
                edit.setSizePolicy(horSizePolicy)
                vbox.addWidget(edit)

        scroll_area = QScrollArea()
        scroll_area.setWidget(file_info_widget)
        scroll_area.setWidgetResizable(True)

        return scroll_area
Пример #15
0
    def __init__(self):
        super().__init__()
        self._cg = None
        self.visualizer = None
        self.old_api_key = get_setting("api_key")
        self.loadables_q = Queue()
        # this thread continually checks for new loadables to load
        self.cg_load_thread = threading.Thread(target=self._load_loadables)
        # we never kill this thread, so allow the application to quit while it's
        # still alive
        self.cg_load_thread.daemon = True
        self.cg_load_thread.start()
        self.loadable_loaded = threading.Event()
        self.show_visualizer_window.connect(self.show_visualizer)
        self.show_exception_signal.connect(self.show_exception)

        expanding = QSizePolicy()
        expanding.setHorizontalPolicy(QSizePolicy.Expanding)
        expanding.setVerticalPolicy(QSizePolicy.Expanding)

        self.drop_area = ReplayDropArea()
        self.drop_area.setSizePolicy(expanding)
        da_scroll_area = QScrollArea(self)
        da_scroll_area.setWidget(self.drop_area)
        da_scroll_area.setWidgetResizable(True)
        da_scroll_area.setFrameShape(QFrame.NoFrame)

        self.replay_map_creation = ReplayMapCreation()
        self.replay_map_creation.setSizePolicy(expanding)
        rmc_scroll_area = QScrollArea(self)
        rmc_scroll_area.setWidget(self.replay_map_creation)
        rmc_scroll_area.setWidgetResizable(True)
        rmc_scroll_area.setFrameShape(QFrame.NoFrame)

        visualize_button = PushButton("Visualize")
        visualize_button.setObjectName("bigButton")
        visualize_button.clicked.connect(self.visualize)
        font = visualize_button.font()
        font.setPointSize(30)
        visualize_button.setFont(font)
        expanding = QSizePolicy()
        expanding.setHorizontalPolicy(QSizePolicy.Expanding)
        expanding.setVerticalPolicy(QSizePolicy.Expanding)
        visualize_button.setSizePolicy(expanding)

        layout = QGridLayout()
        layout.addWidget(da_scroll_area, 0, 0, 6, 1)
        layout.addWidget(rmc_scroll_area, 0, 1, 6, 1)
        layout.addWidget(visualize_button, 6, 0, 2, 2)
        self.setLayout(layout)
Пример #16
0
def _createExpandingSizePolicy(horizontal=True, vertical=True) -> QSizePolicy:
    """Creates a size policy that expands based on the given parameters

    Args:
        horizontal: When 'True', the returned size policy expands horizontally
        vertical: When 'True', the returned size policy expands vertically.

    Returns:
        A QSizePolicy representative of the given parameters.
    """
    sizePolicy = QSizePolicy()
    if horizontal:
        sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding)
    if vertical:
        sizePolicy.setVerticalPolicy(QSizePolicy.Expanding)
    return sizePolicy
Пример #17
0
    def initUI(self):

        # create hbox for stat_groupbox
        self.stats_hbox = QHBoxLayout()

        # set up stats groupboxes
        self.stats_groupbox = QGroupBox('Statistics')
        self.stats_groupbox.setLayout(self.stats_hbox)

        # set up scrollArea for the compare widget
        #self.compare_frame = QFrame()
        #self.analyse_window_scroll_area = QScrollArea()
        #self.analyse_window_scroll_area.setWidget(self.compare_frame)
        #self.compare_frame.setFrameStyle(QFrame.WinPanel | QFrame.Raised)
        #self.compare_frame.setLineWidth(3)
        #self.analyse_window_scroll_area.setWidgetResizable(True)

        # set up comapre vbox
        self.compare_vbox = QVBoxLayout()
        #self.compare_vbox.addWidget(self.analyse_window_scroll_area)

        # set up compare groupbox
        self.compare_groupbox = QGroupBox('Compare Results')
        self.compare_groupbox.setLayout(self.compare_vbox)

        # create analyse_window_body_widget
        self.analyse_window_body_splitter = QSplitter(Qt.Vertical)
        #self.analyse_window_body_splitter.setLayout(self.analyse_window_body_vbox)
        self.analyse_window_body_splitter.addWidget(self.stats_groupbox)
        self.analyse_window_body_splitter.addWidget(self.compare_groupbox)

        #stats_groupbox_size_policy = QSizePolicy(self.stats_groupbox.sizePolicy())
        #print(stats_groupbox_size_policy.Policy())
        compare_groupbox_size_policy = QSizePolicy(
            self.compare_groupbox.sizePolicy())
        compare_groupbox_size_policy.setHorizontalPolicy(
            QSizePolicy.MinimumExpanding)
        #print(compare_groupbox_size_policy.Policy())
        self.compare_groupbox.setSizePolicy(compare_groupbox_size_policy)
        #self.compare_groupbox.setMinimumWidth(200)

        # set up body vbox
        self.analyse_window_vbox = QVBoxLayout()
        self.analyse_window_vbox.addWidget(self.analyse_window_body_splitter)

        self.setWindowTitle('Analyse Window')
        self.setLayout(self.analyse_window_vbox)
Пример #18
0
    def __init__(self, press_button):
        super(CaptivePortalMessage, self).__init__()

        self._label = QLabel()
        labelPolicy = QSizePolicy()
        labelPolicy.setHorizontalStretch(1)
        labelPolicy.setHorizontalPolicy(QSizePolicy.Preferred)
        self._label.setSizePolicy(labelPolicy)

        self._button = QPushButton()
        self._button.clicked.connect(press_button)

        self._layout = QHBoxLayout()
        self._layout.addWidget(self._label)
        self._layout.addWidget(self._button)

        self.setLayout(self._layout)
Пример #19
0
    def __init__(self, parent = None, dataset = None):
        super(PlotWidget, self).__init__()

        self.parent = parent

        sizePolicy = QSizePolicy();
        sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding);
        sizePolicy.setVerticalPolicy(QSizePolicy.Expanding);
        self.setSizePolicy(sizePolicy);

        self.plotVboxlayout = QVBoxLayout(self)

        #> the up part, including sc and slider
        self.sc = None
        if (dataset.shape[2] == 1):
            self.sc = MyStaticMplCanvas1D(self, dataset, width=10, height=4, dpi=100)
        elif (dataset.shape[1] == 1):
            self.sc = MyStaticMplCanvas2D(self, dataset, width=5, height=4, dpi=100)

        #> The slider
        self.sp_widget = QWidget(self)
        self.sp_layout = QHBoxLayout(self.sp_widget)

        self.label = QLabel("time")
        self.plainTextEdit = QTextEdit("0")
        self.plainTextEdit.setMaximumHeight(20)
        self.plainTextEdit.setMaximumWidth(100)
        self.sp = QSlider(QtCore.Qt.Horizontal)
        self.sp.setMinimum(0)
        self.sp.setMaximum(dataset[...].shape[0]-1)
        self.sp.setTickPosition(QSlider.TicksBelow)
        self.sp.setTickInterval(1)
        self.sp.valueChanged.connect(self.timeChange)
        self.sp_layout.addWidget(self.label)
        self.sp_layout.addWidget(self.plainTextEdit)
        self.sp_layout.addWidget(self.sp)

        self.button_saveAnimation = QPushButton("Save Animation")
        self.button_saveAnimation.clicked.connect(self.save_animation)


        self.plotVboxlayout.addWidget(self.sc)
        self.plotVboxlayout.addWidget(self.sp_widget)
        self.plotVboxlayout.addWidget(self.button_saveAnimation)
Пример #20
0
 def createSizePolicy(hPolicy=QSizePolicy.Expanding,
                      vPolicy=QSizePolicy.Expanding,
                      hStretch=1,
                      vStretch=1):
     """
     创建QSizePolicy
     :param hPolicy: 水平缩放策略
     :param vPolicy: 垂直缩放策略
     :param hStretch: 水平缩放因子
     :param vStretch: 垂直缩放因子
     :return: QSizePolicy
     """
     sizePolicy = QSizePolicy()
     # 水平和垂直方向的大小策略
     sizePolicy.setHorizontalPolicy(hPolicy)
     sizePolicy.setVerticalPolicy(vPolicy)
     # 缩放因子
     sizePolicy.setHorizontalStretch(hStretch)
     sizePolicy.setVerticalStretch(vStretch)
     return sizePolicy
Пример #21
0
    def __init__(self, url, get_current_proxy, *args, **kwargs):
        QWebEngineView.__init__(self, *args, **kwargs)

        # Register proxy authentication handler
        self.page().proxyAuthenticationRequired.connect(
            lambda url, auth, proxyHost: self._proxy_auth(
                get_current_proxy, url, auth, proxyHost))

        # Override user agent
        self.page().profile().setHttpUserAgent(
            user_agent_with_system(
                user_agent=self.page().profile().httpUserAgent(),
                system_name=system.NAME,
                system_version=system.VERSION))

        # Allow sound playback without user gesture
        self.page().settings().setAttribute(
            QWebEngineSettings.PlaybackRequiresUserGesture, False)

        # Load url
        self.page().setUrl(url)

        # Shortcut to manually reload
        self.reload_shortcut = QShortcut('CTRL+R', self)
        self.reload_shortcut.activated.connect(self.reload)

        # Check if pages is correctly loaded
        self.loadFinished.connect(self._load_finished)

        # Shortcut to close
        self.quit_shortcut = QShortcut('CTRL+ALT+DELETE', self)
        self.quit_shortcut.activated.connect(lambda: self.close())

        # Stretch the browser
        policy = QSizePolicy()
        policy.setVerticalStretch(1)
        policy.setHorizontalStretch(1)
        policy.setVerticalPolicy(QSizePolicy.Preferred)
        policy.setHorizontalPolicy(QSizePolicy.Preferred)
        self.setSizePolicy(policy)
Пример #22
0
    def _create_style_view(self, style_path, path_to_icon, style_name):
        pixmap = self._read_input_pixmap(path_to_icon)
        if pixmap is not None:

            # create a scene which will handle the graphical image
            scene = QGraphicsScene(self)
            scene.addPixmap(pixmap)

            # create the the widget which will display the image
            graphics_view = SelectableGraphicsView(scene, self, style_path, path_to_icon)

            # set its maximum size to 100 by 100 pixels
            graphics_view.setMaximumSize(QSize(90, 90))

            # set the size policy to fixed so the widgets wont change their size
            size_policy = QSizePolicy()
            size_policy.setHorizontalPolicy(QSizePolicy.Fixed)
            size_policy.setVerticalPolicy(QSizePolicy.Fixed)
            graphics_view.setSizePolicy(size_policy)

            # disable the scrollbars for the graphics view
            graphics_view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
            graphics_view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

            # display the widget with a label indicating the stlye name
            frame = QFrame(self.ui.scrollArea)
            vertical_layout = QVBoxLayout(frame)
            frame.setLayout(vertical_layout)
            frame.setMaximumSize(QSize(120, 150))
            vertical_layout.addWidget(graphics_view)
            title_label = QLabel(style_name, frame)
            title_label.setAlignment(Qt.AlignHCenter)
            vertical_layout.addWidget(title_label)
            self.ui.horizontalLayout_2.addWidget(frame)

            # connect the signal and slots
            graphics_view.on_focus.connect(self._style_selector)

            return graphics_view
Пример #23
0
 def showRenderControls(self):
     if not self._control_dialog:
         dprint(1, "creating control dialog")
         self._control_dialog = ImageControlDialog(self, self._rc,
                                                   self._imgman)
         # line below allows window to be resized by the user
         self._control_dialog.setSizeGripEnabled(True)
         # get and set sizing
         self._control_dialog.setMinimumWidth(396)
         # create size policy for control dialog
         colour_ctrl_policy = QSizePolicy()
         colour_ctrl_policy.setHorizontalPolicy(QSizePolicy.Minimum)
         self._control_dialog.setSizePolicy(colour_ctrl_policy)
         # setup dockable colour control dialog
         self._dockable_colour_ctrl = TDockWidget(
             title=f"{self._rc.image.name}",
             parent=self.parent().mainwin,
             bind_widget=self._control_dialog,
             close_slot=self.colourctrl_dockwidget_closed,
             toggle_slot=self.colourctrl_dockwidget_toggled)
         self.addDockWidgetToTab()
         dprint(1, "done")
     # set dockable widget visibility in sync with control dialog
     if not self._control_dialog.isVisible():
         dprint(1, "showing control dialog")
         self._control_dialog.show()
         self._dockable_colour_ctrl.setVisible(True)
         self.addDockWidgetToTab()
         self._dockable_colour_ctrl.show()
         self._dockable_colour_ctrl.raise_()
     else:
         self._control_dialog.hide()
         self._dockable_colour_ctrl.setVisible(False)
         self.parent().mainwin.setMaximumWidth(
             self.parent().mainwin.width() +
             self._dockable_colour_ctrl.width())
    def add_dropdownlist(self, layout, label, values, row=None, column=None, rowspan=None, columnspan=None):
        """
        Adds a drop down list to the given layout.
        :param layout: QLayout to add widget to.
        :param label: String containing the list title.
        :param values: List containing dropdown items.
        Optional
        :param row: int. If layout is a QGridLayout then the row must be given.
        :param column: int. If the layout is a QGridLayout then the column must be given.
        :param rowspan: int. For how many rows widget will span in QGridLayout.
        :param columnspan: int. For how many columns widget will span in QGridLayout.
        :return:
        """
        size_policy = QSizePolicy()
        size_policy.setHorizontalPolicy(QSizePolicy.Expanding)
        size_policy.setVerticalPolicy(QSizePolicy.Preferred)

        lbl = QLabel(label)
        lbl.setFont(self.label_font)
        lbl.setSizePolicy(size_policy)

        drop_menu = QComboBox()
        drop_menu.addItems(values)
        drop_menu.setFont(self.edit_font)
        drop_menu.setSizePolicy(size_policy)

        if type(layout) is QGridLayout:
            if rowspan is not None and columnspan is not None:
                layout.addWidget(lbl, row, column, rowspan, columnspan)
                layout.addWidget(drop_menu, row + rowspan + 1, column, rowspan, columnspan)
            else:
                layout.addWidget(lbl, row, column)
                layout.addWidget(drop_menu, row + 1, column)
        else:
            layout.addWidget(lbl)
            layout.addWidget(drop_menu)
Пример #25
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     
     sp = QSizePolicy()
     sp.setHorizontalPolicy(QSizePolicy.Expanding)
     sp.setVerticalPolicy(QSizePolicy.Expanding)
     sp.setVerticalStretch(1)
     
     wb_city_data = load_workbook(filename=r'DSTU-H_B_V.1.1-27_2010.xlsx', 
                                  read_only=True, data_only=True)
     self.__ws_city_I_ser_m_sj = wb_city_data['Лист1']
     self.__ws_city_t_z = wb_city_data['Т2. Температура зовн. пов.']
     
     self.__cityChoice = QComboBox()
     self.__cityChoice.addItems(c[0].value for c in 
                                self.__ws_city_I_ser_m_sj['A6':'A605'] if c[0].value)
     
     self.__q_0Edit = KwNumberEdit(.5)
     self.__V_budEdit = KwNumberEdit(480)
     
     self.__NEdit = QSpinBox()
     self.__NEdit.setRange(1, 999)
     self.__NEdit.setSuffix(' чол')
     self.__NEdit.setValue(6)
     
     self.__t_gvEdit = QSpinBox()
     self.__t_gvEdit.setRange(25, 70)
     self.__t_gvEdit.setSingleStep(5)
     self.__t_gvEdit.setSuffix(' \N{DEGREE CELSIUS}')
     self.__t_gvEdit.setValue(45)
     
     self.__a_gvEdit = QSpinBox()
     self.__a_gvEdit.setRange(15, 99)
     self.__a_gvEdit.setSuffix(' л/добу')
     self.__a_gvEdit.setValue(35)
     
     self.__f_zEdit = KwNumberEdit(.8)
     self.__varthetaEdit = KwNumberEdit(1.7)
     self.__S_0Edit = KwNumberEdit(1.723)
     self.__F_rEdit = KwNumberEdit(1)
     self.__eta_0Edit = KwNumberEdit(0.813)
     self.__ULEdit = KwNumberEdit(4.6)
     self.__aEdit = KwNumberEdit(.007)
     self.__bEdit = KwNumberEdit(1.27E-5)
     self.__c_paEdit = KwNumberEdit(3.16)
     
     self.__P_tpEdit = KwNumberEdit(14.1)
     self.__epsilon_tpEdit = KwNumberEdit(5.5)
     self.__epsilon_elEdit = KwNumberEdit(.88)
     self.__P_elEdit = KwNumberEdit(2.6)
     
     self.__t_co_1Edit = QSpinBox()
     self.__t_co_1Edit.setRange(25, 70)
     self.__t_co_1Edit.setSingleStep(5)
     self.__t_co_1Edit.setSuffix(' \N{DEGREE CELSIUS}')
     self.__t_co_1Edit.setValue(35)
     
     self.__t_co_2Edit = QSpinBox()
     self.__t_co_2Edit.setRange(20, 60)
     self.__t_co_2Edit.setSingleStep(5)
     self.__t_co_2Edit.setSuffix(' \N{DEGREE CELSIUS}')
     self.__t_co_2Edit.setValue(30)
     
     self.__eta_KEdit = KwNumberEdit(.93)
     self.__Q_n_rEdit = KwNumberEdit(35600)
     self.__c_gazEdit = KwNumberEdit(.55)
     self.__c_elEdit = KwNumberEdit(.25)
     
     self.__q_gruEdit = KwNumberEdit(21)
     
     self.__d_gruEdit = QSpinBox()
     self.__d_gruEdit.setRange(5, 99)
     self.__d_gruEdit.setSuffix('  мм')
     self.__d_gruEdit.setValue(25)
     
     self.__l_0_gruEdit = KwNumberEdit(1.7)
     
     calcButton = QPushButton('Визначити')
     calcButton.setObjectName('calcButton')
     
     self.__outputConsoleBrowser = KwConsoleBrowser(setup={'font': {'name': 
           QFont('Hack').family(), 'size': 8}, 'color': 'rgb(255, 255, 255)', 
           'background_color': 'rgba(0, 0, 0, 218)', 'line_wrap': False})
     self.__outputConsoleBrowser.setSizePolicy(sp)
     
     graphWidget = QMainWindow()
     graphWidget.setMinimumWidth(380)
     
     self.__graphCanvas = self.__createFigureCanvas()
     self.__graphNavigationToolbar = NavigationToolbar(self.__graphCanvas, self)
     graphWidget.addToolBar(Qt.TopToolBarArea, self.__graphNavigationToolbar)
     
     graphWidget.setCentralWidget(self.__graphCanvas)
     
     cityLayout = QFormLayout()
     cityLayout.addRow('Місто:', self.__cityChoice)
     
     soGroup = QGroupBox('Для системи опалення (СО):')
     soInputLayout = QFormLayout(soGroup)
     
     soInputLayout.addRow('Питома потужність тепловтрат, q<sub>0</sub>, '
                          'Вт/(м<sup>3</sup>\N{MIDDLE DOT}\N{DEGREE CELSIUS}):', 
                          self.__q_0Edit)
     soInputLayout.addRow("Об'єм будинку по зовнішніх обмірах, V<sub>буд</sub>, "
                          "м<sup>3</sup>:", self.__V_budEdit)
     
     sgvGroup = QGroupBox(u'Для системи гарячого водопостачання (СГК):')
     sgvInputLayout = QFormLayout(sgvGroup)
     sgvInputLayout.addRow('Кількість мешканців у будинку, N:', self.__NEdit)
     sgvInputLayout.addRow('Температура гарячої води, t<sub>гв</sub>:', self.__t_gvEdit)
     sgvInputLayout.addRow('Добова витрата гарячої води на 1 особу, a<sub>гв</sub>:',
                           self.__a_gvEdit)
     
     sgkGroup = QGroupBox('Для системи геліоколекторів (СГК):')
     sgkInputLayout = QFormLayout(sgkGroup)
     sgkInputLayout.addRow('Ступінь заміщення тепловтрат СГВ, f<sub>з</sub>:', self.__f_zEdit)
     sgkInputLayout.addRow('Параметр, \u03D1:', self.__varthetaEdit)
     sgkInputLayout.addRow('Площа 1-го геліоколектора, S<sub>0</sub>, м<sup>2</sup>:',
                           self.__S_0Edit)
     sgkInputLayout.addRow('F<sub>r</sub>:', self.__F_rEdit)
     sgkInputLayout.addRow('Оптичний ККД, \N{GREEK SMALL LETTER ETA}:', self.__eta_0Edit)
     sgkInputLayout.addRow('Коефіцієнт тепловтрат, UL, Вт/(м<sup>2</sup>)'
                           '\N{MIDDLE DOT}\N{DEGREE CELSIUS}):', self.__ULEdit)
     sgkInputLayout.addRow('a:', self.__aEdit)
     sgkInputLayout.addRow('b:', self.__bEdit)
     sgkInputLayout.addRow('c<sub>pa</sub>, кДж/(кг\N{MIDDLE DOT}\N{DEGREE CELSIUS}):',
                           self.__c_paEdit)
     
     tpGroup = QGroupBox('Для теплової помпи (ТП):')
     tpInputLayout = QFormLayout(tpGroup)
     tpInputLayout.addRow('Теплова потужність, P<sub>тп</sub>, кВт:', self.__P_tpEdit)
     tpInputLayout.addRow('Тепловий к.к.д, \N{GREEK SMALL LETTER EPSILON}'
                          '<sub>тп</sub>', self.__epsilon_tpEdit)
     tpInputLayout.addRow('Електричний к.к.д., \N{GREEK SMALL LETTER EPSILON}'
                          '<sub>ел</sub>:', self.__epsilon_elEdit)
     tpInputLayout.addRow('Електрична потужність, P<sub>ел</sub>, кВт:', self.__P_elEdit)
     tpInputLayout.addRow('Т-ра нагрітої води для СО підлоги, t<sub>co 1</sub>:',
                          self.__t_co_1Edit)
     tpInputLayout.addRow('Т-ра охолодженої води для СО підлоги, t<sub>co 2</sub>:',
                          self.__t_co_2Edit)
     tpInputLayout.addRow('К.к.д. згоряння палива, eta_K:', self.__eta_KEdit)
     tpInputLayout.addRow('Нижча теплота згоряння палива, Q<sub>n r</sub>, кДж/м<sup>3</sup>:',
                          self.__Q_n_rEdit)
     tpInputLayout.addRow('Вартість 1 м<sup>3</sup> газу, c<sub>газ</sub>, грн/м<sup>3</sup>:',
                          self.__c_gazEdit)
     tpInputLayout.addRow('Вартість 1 кВт\N{MIDDLE DOT}год, c<sub>ел</sub>, '
                          'грн/м<sup>3</sup>:', self.__c_elEdit)
     
     gruGroup = QGroupBox('Для ґрунту і контуру СО підлоги:')
     gruInputEdit = QFormLayout(gruGroup)
     gruInputEdit.addRow('Питома тепловіддача ґрунту, q<sub>ґр</sub>, '
                         'Вт/м<sup>2</sup>:', self.__q_gruEdit)
     gruInputEdit.addRow('Внутрішній діаметр, d, мм:', self.__d_gruEdit)
     gruInputEdit.addRow('Питома довжина тепловідбору, l<sub>0</sub>, '
                         'м/м<sup>2</sup>:', self.__l_0_gruEdit)
     
     inputScrollArea = QScrollArea()
     inputScrollArea.setWidgetResizable(True)
     inputScrollArea.setSizePolicy(sp)
     
     inputDataPanel = QWidget()
     inputDataLayout = QVBoxLayout(inputDataPanel)
     
     inputDataLayout.addLayout(cityLayout)
     inputDataLayout.addWidget(soGroup)
     inputDataLayout.addWidget(sgvGroup)
     inputDataLayout.addWidget(sgkGroup)
     inputDataLayout.addWidget(tpGroup)
     inputDataLayout.addWidget(gruGroup)
     
     inputScrollArea.setWidget(inputDataPanel)
     
     inputWidget = QWidget()
     inputLayout = QFormLayout(inputWidget)
     #inputLayout.setContentsMargins(0, 0, 0, 0)
     inputLayout.setRowWrapPolicy(QFormLayout.WrapAllRows)
     inputLayout.addRow('Вхідні дані:', inputScrollArea)
     inputLayout.addWidget(calcButton)
     
     consoleViewWidget = QWidget()
     consoleViewLayout = QFormLayout(consoleViewWidget)
     consoleViewLayout.setRowWrapPolicy(QFormLayout.WrapAllRows)
     consoleViewLayout.addRow(u'Результати:', self.__outputConsoleBrowser)
     
     contentSplitter = QSplitter(Qt.Horizontal)
     contentSplitter.setStretchFactor(0, 1)
     contentSplitter.setStretchFactor(1, 0)
     contentSplitter.setSizes([350, 380])
     contentSplitter.setChildrenCollapsible(False)
     
     ioSplitter = QSplitter(Qt.Vertical)
     ioSplitter.setStretchFactor(0, 1)
     ioSplitter.setStretchFactor(1, 0)
     ioSplitter.setSizes([200, 320])
     ioSplitter.setChildrenCollapsible(False)
     ioSplitter.setMinimumWidth(380)
     
     ioSplitter.addWidget(inputWidget)
     ioSplitter.addWidget(consoleViewWidget)
     
     contentSplitter.addWidget(ioSplitter)
     contentSplitter.addWidget(graphWidget)
     
     self.setCentralWidget(contentSplitter)
     
     self.resize(1200, 640)
     
     # <<<
     for inputValueWidget in inputWidget.findChildren((QAbstractSpinBox,
                                                       KwNumberEdit)):
         inputValueWidget.valueChanged.connect(self._reset_output_data)
     
     for inputValueWidget in inputWidget.findChildren(QComboBox):
         inputValueWidget.activated.connect(self._reset_output_data)
     
     calcButton.clicked.connect(self.calc_script)
Пример #26
0
    def __init__(self, *args):
        super().__init__(BrickletIndustrialDualAnalogInV2, *args)

        self.analog_in = self.device

        self.cbe_voltage0 = CallbackEmulator(
            self.analog_in.get_voltage,
            0,
            self.cb_voltage,
            self.increase_error_count,
            pass_arguments_to_result_callback=True)

        self.cbe_voltage1 = CallbackEmulator(
            self.analog_in.get_voltage,
            1,
            self.cb_voltage,
            self.increase_error_count,
            pass_arguments_to_result_callback=True)

        self.calibration = None

        self.sample_rate_label = QLabel('Sample Rate:')
        self.sample_rate_combo = QComboBox()
        self.sample_rate_combo.addItem('976 Hz')
        self.sample_rate_combo.addItem('488 Hz')
        self.sample_rate_combo.addItem('244 Hz')
        self.sample_rate_combo.addItem('122 Hz')
        self.sample_rate_combo.addItem('61 Hz')
        self.sample_rate_combo.addItem('4 Hz')
        self.sample_rate_combo.addItem('2 Hz')
        self.sample_rate_combo.addItem('1 Hz')

        self.current_voltage = [CurveValueWrapper(),
                                CurveValueWrapper()]  # float, V
        self.calibration_button = QPushButton('Calibration...')

        self.sample_rate_combo.currentIndexChanged.connect(
            self.sample_rate_combo_index_changed)
        self.calibration_button.clicked.connect(
            self.calibration_button_clicked)

        plots = [
            ('Channel 0', Qt.red, self.current_voltage[0], format_voltage),
            ('Channel 1', Qt.blue, self.current_voltage[1], format_voltage)
        ]
        self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001)

        # Define lines
        line = QFrame()
        line.setObjectName("line")
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)

        line1 = QFrame()
        line1.setObjectName("line1")
        line1.setFrameShape(QFrame.HLine)
        line1.setFrameShadow(QFrame.Sunken)

        line2 = QFrame()
        line2.setObjectName("line2")
        line2.setFrameShape(QFrame.HLine)
        line2.setFrameShadow(QFrame.Sunken)

        # Define channel LED status config widgets
        self.led_config_ch0_label = QLabel('Channel 0')
        self.led_config_ch1_label = QLabel('Channel 1')
        self.led_config_label = QLabel('LED Config:')
        self.led_status_config_label = QLabel('LED Status Config:')
        self.led_status_config_ch0_min_label = QLabel('Min:')
        self.led_status_config_ch0_max_label = QLabel('Max:')
        self.led_status_config_ch1_min_label = QLabel('Min:')
        self.led_status_config_ch1_max_label = QLabel('Max:')

        self.led_config_ch0_combo = QComboBox()
        self.led_config_ch0_combo.addItem('Off')
        self.led_config_ch0_combo.addItem('On')
        self.led_config_ch0_combo.addItem('Show Heartbeat')
        self.led_config_ch0_combo.addItem('Show Channel Status')
        self.led_config_ch0_combo.currentIndexChanged.connect(
            self.led_config_ch0_combo_changed)

        self.led_config_ch1_combo = QComboBox()
        self.led_config_ch1_combo.addItem('Off')
        self.led_config_ch1_combo.addItem('On')
        self.led_config_ch1_combo.addItem('Show Heartbeat')
        self.led_config_ch1_combo.addItem('Show Channel Status')
        self.led_config_ch1_combo.currentIndexChanged.connect(
            self.led_config_ch1_combo_changed)

        self.led_status_config_ch0_combo = QComboBox()
        self.led_status_config_ch0_combo.addItem('Threshold')
        self.led_status_config_ch0_combo.addItem('Intensity')
        self.led_status_config_ch0_combo.currentIndexChanged.connect(
            self.led_status_config_ch0_combo_changed)

        self.led_status_config_ch1_combo = QComboBox()
        self.led_status_config_ch1_combo.addItem('Threshold')
        self.led_status_config_ch1_combo.addItem('Intensity')
        self.led_status_config_ch1_combo.currentIndexChanged.connect(
            self.led_status_config_ch1_combo_changed)

        self.led_status_config_ch0_min_sbox = QSpinBox()
        self.led_status_config_ch0_min_sbox.setMinimum(-35000)
        self.led_status_config_ch0_min_sbox.setMaximum(35000)
        self.led_status_config_ch0_min_sbox.setValue(0)
        self.led_status_config_ch0_min_sbox.setSingleStep(1)
        self.led_status_config_ch0_min_sbox.setSuffix(' mV')
        self.led_status_config_ch0_min_sbox.valueChanged.connect(
            self.led_status_config_ch0_min_sbox_changed)

        self.led_status_config_ch0_max_sbox = QSpinBox()
        self.led_status_config_ch0_max_sbox.setMinimum(-35000)
        self.led_status_config_ch0_max_sbox.setMaximum(35000)
        self.led_status_config_ch0_max_sbox.setValue(0)
        self.led_status_config_ch0_max_sbox.setSingleStep(1)
        self.led_status_config_ch0_max_sbox.setSuffix(' mV')
        self.led_status_config_ch0_max_sbox.valueChanged.connect(
            self.led_status_config_ch0_max_sbox_changed)

        self.led_status_config_ch1_min_sbox = QSpinBox()
        self.led_status_config_ch1_min_sbox.setMinimum(-35000)
        self.led_status_config_ch1_min_sbox.setMaximum(35000)
        self.led_status_config_ch1_min_sbox.setValue(0)
        self.led_status_config_ch1_min_sbox.setSingleStep(1)
        self.led_status_config_ch1_min_sbox.setSuffix(' mV')
        self.led_status_config_ch1_min_sbox.valueChanged.connect(
            self.led_status_config_ch1_min_sbox_changed)

        self.led_status_config_ch1_max_sbox = QSpinBox()
        self.led_status_config_ch1_max_sbox.setMinimum(-35000)
        self.led_status_config_ch1_max_sbox.setMaximum(35000)
        self.led_status_config_ch1_max_sbox.setValue(0)
        self.led_status_config_ch1_max_sbox.setSingleStep(1)
        self.led_status_config_ch1_max_sbox.setSuffix(' mV')
        self.led_status_config_ch1_max_sbox.valueChanged.connect(
            self.led_status_config_ch1_max_sbox_changed)

        # Define size policies
        h_sp = QSizePolicy()
        h_sp.setHorizontalPolicy(QSizePolicy.Expanding)

        # Set size policies
        self.sample_rate_combo.setSizePolicy(h_sp)
        self.led_config_ch0_combo.setSizePolicy(h_sp)
        self.led_config_ch1_combo.setSizePolicy(h_sp)
        self.led_status_config_ch0_combo.setSizePolicy(h_sp)
        self.led_status_config_ch1_combo.setSizePolicy(h_sp)
        self.led_status_config_ch0_min_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch0_max_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch1_min_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch1_max_sbox.setSizePolicy(h_sp)

        # Define layouts
        hlayout = QHBoxLayout()
        vlayout = QVBoxLayout()
        glayout = QGridLayout()
        layout = QVBoxLayout(self)
        hlayout_ch0_min_max = QHBoxLayout()
        hlayout_ch1_min_max = QHBoxLayout()

        # Populate layouts
        vlayout.addWidget(self.calibration_button)
        hlayout.addWidget(self.sample_rate_label)
        hlayout.addWidget(self.sample_rate_combo)
        vlayout.addLayout(hlayout)
        vlayout.addWidget(line1)

        hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_min_label)
        hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_min_sbox)
        hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_max_label)
        hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_max_sbox)

        hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_min_label)
        hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_min_sbox)
        hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_max_label)
        hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_max_sbox)

        glayout.addWidget(self.led_config_ch0_label, 0, 1, 1,
                          1)  # R, C, RS, CS
        glayout.addWidget(self.led_config_ch1_label, 0, 2, 1, 1)

        glayout.addWidget(line2, 1, 0, 1, 3)

        glayout.addWidget(self.led_config_label, 2, 0, 1, 1)
        glayout.addWidget(self.led_config_ch0_combo, 2, 1, 1, 1)
        glayout.addWidget(self.led_config_ch1_combo, 2, 2, 1, 1)

        glayout.addWidget(self.led_status_config_label, 3, 0, 1, 1)
        glayout.addWidget(self.led_status_config_ch0_combo, 3, 1, 1, 1)
        glayout.addWidget(self.led_status_config_ch1_combo, 3, 2, 1, 1)

        glayout.addLayout(hlayout_ch0_min_max, 4, 1, 1, 1)
        glayout.addLayout(hlayout_ch1_min_max, 4, 2, 1, 1)

        layout.addWidget(self.plot_widget)
        layout.addWidget(line)
        layout.addLayout(vlayout)
        layout.addLayout(glayout)

        self.ui_group_ch_status_ch0 = [
            self.led_status_config_ch0_combo,
            self.led_status_config_ch0_min_sbox,
            self.led_status_config_ch0_max_sbox
        ]

        self.ui_group_ch_status_ch1 = [
            self.led_status_config_ch1_combo,
            self.led_status_config_ch1_min_sbox,
            self.led_status_config_ch1_max_sbox
        ]
Пример #27
0
    def initUI(self):
        self.setGeometry(300, 100, 1000, 750)
        self.lumen = ()
        self.plaque = ()
        layout = QHBoxLayout()
        vbox1 = QVBoxLayout()
        vbox2 = QVBoxLayout()
        vbox1.setContentsMargins(0, 0, 100, 100)
        vbox2.setContentsMargins(100, 0, 0, 100)
        vbox2hbox1 = QHBoxLayout()
        vbox2.addLayout(vbox2hbox1)
        layout.addLayout(vbox1)
        layout.addLayout(vbox2)

        dicomButton = QPushButton('Read DICOM')
        contoursButton = QPushButton('Read Contours')
        gatingButton = QPushButton('Extract Diastolic Frames')
        segmentButton = QPushButton('Segment')
        writeButton = QPushButton('Write Report')

        self.infoTable = QTableWidget()
        self.infoTable.setRowCount(8)
        self.infoTable.setColumnCount(2)
        self.infoTable.setItem(0, 0, QTableWidgetItem('Patient Name'))
        self.infoTable.setItem(1, 0, QTableWidgetItem('Patient DOB'))
        self.infoTable.setItem(2, 0, QTableWidgetItem('Patient Sex'))
        self.infoTable.setItem(3, 0, QTableWidgetItem('Pullback Speed'))
        self.infoTable.setItem(4, 0, QTableWidgetItem('Resolution'))
        self.infoTable.setItem(5, 0, QTableWidgetItem('Dimensions'))
        self.infoTable.setItem(6, 0, QTableWidgetItem('Manufacturer'))
        self.infoTable.setItem(7, 0, QTableWidgetItem('Model'))

        dicomButton.clicked.connect(self.readDICOM)
        contoursButton.clicked.connect(self.readContours)
        segmentButton.clicked.connect(self.segment)
        gatingButton.clicked.connect(self.gate)
        """
        self.lumen, self.plaque, self.stent, self.resolution, frames = read_xml.read('/home/ubuntu/Documents/Qt/1-63/1-63.xml')
        self.lumen = self.mapToList(self.lumen)
        self.plaque = self.mapToList(self.plaque)
        self.stent = self.mapToList(self.stent)
        dicom = dcm.read_file('/home/ubuntu/Documents/Qt/1-63/2.16.840.1.114380.1.1.347327.186.1.1.20100506085134890.3.dcm')
        self.images = dicom.pixel_array
        """

        self.slider = QSlider(Qt.Horizontal)
        #self.slider.setRange(0, self.images.shape[0])
        self.slider.setRange(0, 100)
        self.slider.setValue(0)
        self.slider.setFocusPolicy(Qt.StrongFocus)
        sizePolicy = QSizePolicy()
        sizePolicy.setHorizontalPolicy(QSizePolicy.Fixed)
        sizePolicy.setVerticalPolicy(QSizePolicy.Fixed)
        self.slider.setSizePolicy(sizePolicy)
        self.slider.setMinimumSize(QSize(500, 25))
        self.slider.setMaximumSize(QSize(500, 25))
        self.slider.valueChanged[int].connect(self.changeValue)
        #self.slider.keyPressEvent = self.keyPressEvent()

        self.hideBox = QCheckBox('Hide Contours')
        self.hideBox.setChecked(True)
        self.hideBox.stateChanged[int].connect(self.changeState)
        self.useGatedBox = QCheckBox('Display Gated Frames')
        self.useGatedBox.stateChanged[int].connect(self.useGated)

        self.wid = Display()
        #self.wid.setData(self.lumen, self.plaque, self.images)

        self.c = Communicate()
        self.c.updateBW[int].connect(self.wid.setFrame)
        self.c.updateBool[bool].connect(self.wid.setDisplay)

        self.text = QLabel()
        self.text.setAlignment(Qt.AlignCenter)
        self.text.setText("Frame {}".format(self.slider.value()))

        vbox1.addWidget(self.wid)
        vbox1.addWidget(self.slider)
        vbox1.addWidget(self.text)

        vbox2.addWidget(self.hideBox)
        vbox2.addWidget(self.useGatedBox)
        vbox2.addWidget(dicomButton)
        vbox2.addWidget(contoursButton)
        vbox2.addWidget(gatingButton)
        vbox2.addWidget(segmentButton)
        vbox2.addWidget(writeButton)
        vbox2hbox1.addWidget(self.infoTable)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)
        self.setCentralWidget(centralWidget)
        self.show()
Пример #28
0
    def createFormMatchDataBox(self):
        """Create the froms for the match data."""
        try:

            self.max_no_sets = hwctool.settings.max_no_sets
            self.scoreWidth = 35
            self.raceWidth = 100
            self.labelWidth = 25
            self.mimumLineEditWidth = 130

            self.fromMatchDataBox = QGroupBox(_("Match Data"))
            layout2 = QVBoxLayout()

            self.le_league = MonitoredLineEdit()
            self.le_league.setText("League TBD")
            self.le_league.setAlignment(Qt.AlignCenter)
            self.le_league.setPlaceholderText("League TBD")
            self.le_league.textModified.connect(self.league_changed)
            policy = QSizePolicy()
            policy.setHorizontalStretch(3)
            policy.setHorizontalPolicy(QSizePolicy.Expanding)
            policy.setVerticalStretch(1)
            policy.setVerticalPolicy(QSizePolicy.Fixed)
            self.le_league.setSizePolicy(policy)
            self.le_player = [[
                MonitoredLineEdit() for x in range(self.max_no_sets)
            ] for y in range(2)]
            self.cb_race = [[QComboBox() for x in range(self.max_no_sets)]
                            for y in range(2)]
            self.sl_score = [
                QSlider(Qt.Horizontal) for y in range(self.max_no_sets)
            ]
            self.label_set = [
                QLabel('#{}'.format(y + 1), self)
                for y in range(self.max_no_sets)
            ]
            self.setContainer = [
                QHBoxLayout() for y in range(self.max_no_sets)
            ]

            container = QGridLayout()

            button = QPushButton()
            pixmap = QIcon(hwctool.settings.getResFile('update.png'))
            button.setIcon(pixmap)
            button.clicked.connect(lambda: self.controller.swapTeams())
            button.setFixedWidth(self.labelWidth)
            button.setToolTip(_("Swap players."))
            container.addWidget(button, 0, 0, 1, 1)

            label = QLabel(_("League:"))
            label.setAlignment(Qt.AlignCenter)
            label.setFixedWidth(self.raceWidth)
            container.addWidget(label, 0, 1, 1, 1)

            container.addWidget(self.le_league, 0, 2, 1, 3)

            label = QLabel("")
            label.setFixedWidth(self.raceWidth)
            container.addWidget(label, 0, 5, 1, 1)

            layout2.addLayout(container)

            for player_idx in range(self.max_no_sets):
                for team_idx in range(2):
                    self.cb_race[team_idx][player_idx].\
                        currentIndexChanged.connect(
                        lambda idx,
                        t=team_idx,
                        p=player_idx: self.race_changed(t, p))
                    self.le_player[team_idx][player_idx].textModified.connect(
                        lambda t=team_idx, p=player_idx: self.player_changed(
                            t, p))
                    self.le_player[team_idx][player_idx].setText("TBD")
                    self.le_player[team_idx][player_idx].setAlignment(
                        Qt.AlignCenter)
                    self.le_player[team_idx][player_idx].setPlaceholderText(
                        _("Player {} of team {}").format(
                            player_idx + 1, team_idx + 1))
                    self.le_player[team_idx][player_idx].setMinimumWidth(
                        self.mimumLineEditWidth)

                    for race in hwctool.settings.races:
                        self.cb_race[team_idx][player_idx].addItem(race)

                    self.cb_race[team_idx][player_idx].setFixedWidth(
                        self.raceWidth)

                self.sl_score[player_idx].setMinimum(-1)
                self.sl_score[player_idx].setMaximum(1)
                self.sl_score[player_idx].setValue(0)
                self.sl_score[player_idx].setTickPosition(
                    QSlider.TicksBothSides)
                self.sl_score[player_idx].setTickInterval(1)
                self.sl_score[player_idx].setTracking(False)
                self.sl_score[player_idx].valueChanged.connect(
                    lambda x, player_idx=player_idx: self.sl_changed(
                        player_idx, x))
                self.sl_score[player_idx].setToolTip(_('Set the score'))
                self.sl_score[player_idx].setFixedWidth(self.scoreWidth)

                self.setContainer[player_idx] = QHBoxLayout()
                # self.label_set[player_idx].setText("#" + str(player_idx + 1))
                self.label_set[player_idx].setAlignment(Qt.AlignCenter)
                self.label_set[player_idx].setFixedWidth(self.labelWidth)
                self.setContainer[player_idx].addWidget(
                    self.label_set[player_idx], 0)
                self.setContainer[player_idx].addWidget(
                    self.cb_race[0][player_idx], 0)
                self.setContainer[player_idx].addWidget(
                    self.le_player[0][player_idx], 4)
                self.setContainer[player_idx].addWidget(
                    self.sl_score[player_idx], 0)
                self.setContainer[player_idx].addWidget(
                    self.le_player[1][player_idx], 4)
                self.setContainer[player_idx].addWidget(
                    self.cb_race[1][player_idx], 0)
                layout2.addLayout(self.setContainer[player_idx])

            layout2.addItem(
                QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding))
            self.fromMatchDataBox.setLayout(layout2)

            self.updatePlayerCompleters()

        except Exception as e:
            module_logger.exception("message")
    def __init__(self, *args):
        super().__init__(BrickletIndustrialDualAnalogInV2, *args)

        self.analog_in = self.device

        self.cbe_voltage0 = CallbackEmulator(self.analog_in.get_voltage,
                                             0,
                                             self.cb_voltage,
                                             self.increase_error_count,
                                             pass_arguments_to_result_callback=True)

        self.cbe_voltage1 = CallbackEmulator(self.analog_in.get_voltage,
                                             1,
                                             self.cb_voltage,
                                             self.increase_error_count,
                                             pass_arguments_to_result_callback=True)

        self.calibration = None

        self.sample_rate_label = QLabel('Sample Rate:')
        self.sample_rate_combo = QComboBox()
        self.sample_rate_combo.addItem('976 Hz')
        self.sample_rate_combo.addItem('488 Hz')
        self.sample_rate_combo.addItem('244 Hz')
        self.sample_rate_combo.addItem('122 Hz')
        self.sample_rate_combo.addItem('61 Hz')
        self.sample_rate_combo.addItem('4 Hz')
        self.sample_rate_combo.addItem('2 Hz')
        self.sample_rate_combo.addItem('1 Hz')

        self.current_voltage = [CurveValueWrapper(), CurveValueWrapper()] # float, V
        self.calibration_button = QPushButton('Calibration...')

        self.sample_rate_combo.currentIndexChanged.connect(self.sample_rate_combo_index_changed)
        self.calibration_button.clicked.connect(self.calibration_button_clicked)

        plots = [('Channel 0', Qt.red, self.current_voltage[0], format_voltage),
                 ('Channel 1', Qt.blue, self.current_voltage[1], format_voltage)]
        self.plot_widget = PlotWidget('Voltage [V]', plots, y_resolution=0.001)

        # Define lines
        line = QFrame()
        line.setObjectName("line")
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)

        line1 = QFrame()
        line1.setObjectName("line1")
        line1.setFrameShape(QFrame.HLine)
        line1.setFrameShadow(QFrame.Sunken)

        line2 = QFrame()
        line2.setObjectName("line2")
        line2.setFrameShape(QFrame.HLine)
        line2.setFrameShadow(QFrame.Sunken)

        # Define channel LED status config widgets
        self.led_config_ch0_label = QLabel('Channel 0')
        self.led_config_ch1_label = QLabel('Channel 1')
        self.led_config_label = QLabel('LED Config:')
        self.led_status_config_label = QLabel('LED Status Config:')
        self.led_status_config_ch0_min_label = QLabel('Min:')
        self.led_status_config_ch0_max_label = QLabel('Max:')
        self.led_status_config_ch1_min_label = QLabel('Min:')
        self.led_status_config_ch1_max_label = QLabel('Max:')

        self.led_config_ch0_combo = QComboBox()
        self.led_config_ch0_combo.addItem('Off')
        self.led_config_ch0_combo.addItem('On')
        self.led_config_ch0_combo.addItem('Show Heartbeat')
        self.led_config_ch0_combo.addItem('Show Channel Status')
        self.led_config_ch0_combo.currentIndexChanged.connect(self.led_config_ch0_combo_changed)

        self.led_config_ch1_combo = QComboBox()
        self.led_config_ch1_combo.addItem('Off')
        self.led_config_ch1_combo.addItem('On')
        self.led_config_ch1_combo.addItem('Show Heartbeat')
        self.led_config_ch1_combo.addItem('Show Channel Status')
        self.led_config_ch1_combo.currentIndexChanged.connect(self.led_config_ch1_combo_changed)

        self.led_status_config_ch0_combo = QComboBox()
        self.led_status_config_ch0_combo.addItem('Threshold')
        self.led_status_config_ch0_combo.addItem('Intensity')
        self.led_status_config_ch0_combo.currentIndexChanged.connect(self.led_status_config_ch0_combo_changed)

        self.led_status_config_ch1_combo = QComboBox()
        self.led_status_config_ch1_combo.addItem('Threshold')
        self.led_status_config_ch1_combo.addItem('Intensity')
        self.led_status_config_ch1_combo.currentIndexChanged.connect(self.led_status_config_ch1_combo_changed)

        self.led_status_config_ch0_min_sbox = QSpinBox()
        self.led_status_config_ch0_min_sbox.setMinimum(-35000)
        self.led_status_config_ch0_min_sbox.setMaximum(35000)
        self.led_status_config_ch0_min_sbox.setValue(0)
        self.led_status_config_ch0_min_sbox.setSingleStep(1)
        self.led_status_config_ch0_min_sbox.setSuffix(' mV')
        self.led_status_config_ch0_min_sbox.valueChanged.connect(self.led_status_config_ch0_min_sbox_changed)

        self.led_status_config_ch0_max_sbox = QSpinBox()
        self.led_status_config_ch0_max_sbox.setMinimum(-35000)
        self.led_status_config_ch0_max_sbox.setMaximum(35000)
        self.led_status_config_ch0_max_sbox.setValue(0)
        self.led_status_config_ch0_max_sbox.setSingleStep(1)
        self.led_status_config_ch0_max_sbox.setSuffix(' mV')
        self.led_status_config_ch0_max_sbox.valueChanged.connect(self.led_status_config_ch0_max_sbox_changed)

        self.led_status_config_ch1_min_sbox = QSpinBox()
        self.led_status_config_ch1_min_sbox.setMinimum(-35000)
        self.led_status_config_ch1_min_sbox.setMaximum(35000)
        self.led_status_config_ch1_min_sbox.setValue(0)
        self.led_status_config_ch1_min_sbox.setSingleStep(1)
        self.led_status_config_ch1_min_sbox.setSuffix(' mV')
        self.led_status_config_ch1_min_sbox.valueChanged.connect(self.led_status_config_ch1_min_sbox_changed)

        self.led_status_config_ch1_max_sbox = QSpinBox()
        self.led_status_config_ch1_max_sbox.setMinimum(-35000)
        self.led_status_config_ch1_max_sbox.setMaximum(35000)
        self.led_status_config_ch1_max_sbox.setValue(0)
        self.led_status_config_ch1_max_sbox.setSingleStep(1)
        self.led_status_config_ch1_max_sbox.setSuffix(' mV')
        self.led_status_config_ch1_max_sbox.valueChanged.connect(self.led_status_config_ch1_max_sbox_changed)

        # Define size policies
        h_sp = QSizePolicy()
        h_sp.setHorizontalPolicy(QSizePolicy.Expanding)

        # Set size policies
        self.sample_rate_combo.setSizePolicy(h_sp)
        self.led_config_ch0_combo.setSizePolicy(h_sp)
        self.led_config_ch1_combo.setSizePolicy(h_sp)
        self.led_status_config_ch0_combo.setSizePolicy(h_sp)
        self.led_status_config_ch1_combo.setSizePolicy(h_sp)
        self.led_status_config_ch0_min_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch0_max_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch1_min_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch1_max_sbox.setSizePolicy(h_sp)

        # Define layouts
        hlayout = QHBoxLayout()
        vlayout = QVBoxLayout()
        glayout = QGridLayout()
        layout = QVBoxLayout(self)
        hlayout_ch0_min_max = QHBoxLayout()
        hlayout_ch1_min_max = QHBoxLayout()

        # Populate layouts
        vlayout.addWidget(self.calibration_button)
        hlayout.addWidget(self.sample_rate_label)
        hlayout.addWidget(self.sample_rate_combo)
        vlayout.addLayout(hlayout)
        vlayout.addWidget(line1)

        hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_min_label)
        hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_min_sbox)
        hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_max_label)
        hlayout_ch0_min_max.addWidget(self.led_status_config_ch0_max_sbox)

        hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_min_label)
        hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_min_sbox)
        hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_max_label)
        hlayout_ch1_min_max.addWidget(self.led_status_config_ch1_max_sbox)

        glayout.addWidget(self.led_config_ch0_label, 0, 1, 1, 1) # R, C, RS, CS
        glayout.addWidget(self.led_config_ch1_label, 0, 2, 1, 1)

        glayout.addWidget(line2, 1, 0, 1, 3)

        glayout.addWidget(self.led_config_label, 2, 0, 1, 1)
        glayout.addWidget(self.led_config_ch0_combo, 2, 1, 1, 1)
        glayout.addWidget(self.led_config_ch1_combo, 2, 2, 1, 1)

        glayout.addWidget(self.led_status_config_label, 3, 0, 1, 1)
        glayout.addWidget(self.led_status_config_ch0_combo, 3, 1, 1, 1)
        glayout.addWidget(self.led_status_config_ch1_combo, 3, 2, 1, 1)

        glayout.addLayout(hlayout_ch0_min_max, 4, 1, 1, 1)
        glayout.addLayout(hlayout_ch1_min_max, 4, 2, 1, 1)

        layout.addWidget(self.plot_widget)
        layout.addWidget(line)
        layout.addLayout(vlayout)
        layout.addLayout(glayout)

        self.ui_group_ch_status_ch0 = [self.led_status_config_ch0_combo,
                                       self.led_status_config_ch0_min_sbox,
                                       self.led_status_config_ch0_max_sbox]

        self.ui_group_ch_status_ch1 = [self.led_status_config_ch1_combo,
                                       self.led_status_config_ch1_min_sbox,
                                       self.led_status_config_ch1_max_sbox]
    def __init__(self, *args):
        super().__init__(BrickletIndustrialDual020mAV2, *args)

        self.dual020 = self.device

        self.str_connected = 'Channel {0} is <font color="green">connected</font>'
        self.str_not_connected = 'Channel {0} is <font color="red">not connected</font>'

        self.cbe_current0 = CallbackEmulator(self.dual020.get_current,
                                             0,
                                             self.cb_current,
                                             self.increase_error_count,
                                             pass_arguments_to_result_callback=True)
        self.cbe_current1 = CallbackEmulator(self.dual020.get_current,
                                             1,
                                             self.cb_current,
                                             self.increase_error_count,
                                             pass_arguments_to_result_callback=True)

        self.connected_labels = [FixedSizeLabel(self.str_not_connected.format(0)),
                                 FixedSizeLabel(self.str_not_connected.format(1))]

        self.current_current = [CurveValueWrapper(), CurveValueWrapper()] # float, mA

        plots = [('Channel 0',
                  Qt.red,
                  self.current_current[0],
                  lambda value: '{:.03f} mA'.format(round(value, 3))),
                 ('Channel 1',
                  Qt.blue,
                  self.current_current[1],
                  lambda value: '{:.03f} mA'.format(round(value, 3)))]

        self.plot_widget = PlotWidget('Current [mA]', plots, extra_key_widgets=self.connected_labels, y_resolution=0.001)

        h_sp = QSizePolicy()
        h_sp.setHorizontalPolicy(QSizePolicy.Expanding)

        self.sample_rate_label = QLabel('Sample Rate:')
        self.sample_rate_combo = QComboBox()
        self.sample_rate_combo.addItem('240 Hz')
        self.sample_rate_combo.addItem('60 Hz')
        self.sample_rate_combo.addItem('15 Hz')
        self.sample_rate_combo.addItem('4 Hz')
        self.sample_rate_combo.currentIndexChanged.connect(self.sample_rate_combo_index_changed)
        self.sample_rate_combo.setSizePolicy(h_sp)

        self.gain_label = QLabel('Gain:')
        self.gain_combo = QComboBox()
        self.gain_combo.addItem('x1')
        self.gain_combo.addItem('x2')
        self.gain_combo.addItem('x4')
        self.gain_combo.addItem('x8')
        self.gain_combo.currentIndexChanged.connect(self.gain_combo_index_changed)
        self.gain_combo.setSizePolicy(h_sp)

        self.led_config_ch0_label = QLabel('Channel 0')
        self.led_config_ch1_label = QLabel('Channel 1')
        self.led_config_label = QLabel('LED Config:')
        self.led_status_config_label = QLabel('LED Status Config:')
        self.led_status_config_ch0_min_label = QLabel('Min:')
        self.led_status_config_ch0_max_label = QLabel('Max:')
        self.led_status_config_ch1_min_label = QLabel('Min:')
        self.led_status_config_ch1_max_label = QLabel('Max:')

        self.led_config_ch0_combo = QComboBox()
        self.led_config_ch0_combo.addItem('Off')
        self.led_config_ch0_combo.addItem('On')
        self.led_config_ch0_combo.addItem('Show Heartbeat')
        self.led_config_ch0_combo.addItem('Show Channel Status')
        self.led_config_ch0_combo.setSizePolicy(h_sp)
        self.led_config_ch0_combo.currentIndexChanged.connect(self.led_config_ch0_combo_changed)

        self.led_config_ch1_combo = QComboBox()
        self.led_config_ch1_combo.addItem('Off')
        self.led_config_ch1_combo.addItem('On')
        self.led_config_ch1_combo.addItem('Show Heartbeat')
        self.led_config_ch1_combo.addItem('Show Channel Status')
        self.led_config_ch1_combo.setSizePolicy(h_sp)
        self.led_config_ch1_combo.currentIndexChanged.connect(self.led_config_ch1_combo_changed)

        self.led_status_config_ch0_combo = QComboBox()
        self.led_status_config_ch0_combo.addItem('Threshold')
        self.led_status_config_ch0_combo.addItem('Intensity')
        self.led_status_config_ch0_combo.setSizePolicy(h_sp)
        self.led_status_config_ch0_combo.currentIndexChanged.connect(self.led_status_config_ch0_combo_changed)

        self.led_status_config_ch1_combo = QComboBox()
        self.led_status_config_ch1_combo.addItem('Threshold')
        self.led_status_config_ch1_combo.addItem('Intensity')
        self.led_status_config_ch1_combo.setSizePolicy(h_sp)
        self.led_status_config_ch1_combo.currentIndexChanged.connect(self.led_status_config_ch1_combo_changed)

        self.led_status_config_ch0_min_sbox = QDoubleSpinBox()
        self.led_status_config_ch0_max_sbox = QDoubleSpinBox()
        self.led_status_config_ch1_min_sbox = QDoubleSpinBox()
        self.led_status_config_ch1_max_sbox = QDoubleSpinBox()

        self.led_status_config_ch0_min_sbox.setValue(0)
        self.led_status_config_ch0_min_sbox.setMinimum(0)
        self.led_status_config_ch0_min_sbox.setSingleStep(0.5)
        self.led_status_config_ch0_min_sbox.setDecimals(3)
        self.led_status_config_ch0_min_sbox.setSuffix(' mA')
        self.led_status_config_ch0_min_sbox.setMaximum(22.5)
        self.led_status_config_ch0_min_sbox.valueChanged.connect(self.led_status_config_ch0_min_sbox_changed)

        self.led_status_config_ch0_max_sbox.setValue(0)
        self.led_status_config_ch0_max_sbox.setMinimum(0)
        self.led_status_config_ch0_max_sbox.setSingleStep(0.5)
        self.led_status_config_ch0_max_sbox.setDecimals(3)
        self.led_status_config_ch0_max_sbox.setSuffix(' mA')
        self.led_status_config_ch0_max_sbox.setMaximum(22.5)
        self.led_status_config_ch0_max_sbox.valueChanged.connect(self.led_status_config_ch0_max_sbox_changed)

        self.led_status_config_ch1_min_sbox.setValue(0)
        self.led_status_config_ch1_min_sbox.setMinimum(0)
        self.led_status_config_ch1_min_sbox.setSingleStep(0.5)
        self.led_status_config_ch1_min_sbox.setDecimals(3)
        self.led_status_config_ch1_min_sbox.setSuffix(' mA')
        self.led_status_config_ch1_min_sbox.setMaximum(22.5)
        self.led_status_config_ch1_min_sbox.valueChanged.connect(self.led_status_config_ch1_min_sbox_changed)

        self.led_status_config_ch1_max_sbox.setValue(0)
        self.led_status_config_ch1_max_sbox.setMinimum(0)
        self.led_status_config_ch1_max_sbox.setSingleStep(0.5)
        self.led_status_config_ch1_max_sbox.setDecimals(3)
        self.led_status_config_ch1_max_sbox.setSuffix(' mA')
        self.led_status_config_ch1_max_sbox.setMaximum(22.5)
        self.led_status_config_ch1_max_sbox.valueChanged.connect(self.led_status_config_ch1_max_sbox_changed)

        hlayout = QHBoxLayout()
        self.led_status_config_ch0_min_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch0_max_sbox.setSizePolicy(h_sp)
        hlayout.addWidget(self.led_status_config_ch0_min_label)
        hlayout.addWidget(self.led_status_config_ch0_min_sbox)
        hlayout.addWidget(self.led_status_config_ch0_max_label)
        hlayout.addWidget(self.led_status_config_ch0_max_sbox)

        hlayout1 = QHBoxLayout()
        self.led_status_config_ch1_min_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch1_max_sbox.setSizePolicy(h_sp)
        hlayout1.addWidget(self.led_status_config_ch1_min_label)
        hlayout1.addWidget(self.led_status_config_ch1_min_sbox)
        hlayout1.addWidget(self.led_status_config_ch1_max_label)
        hlayout1.addWidget(self.led_status_config_ch1_max_sbox)

        line = QFrame()
        line.setObjectName("line")
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)

        line1 = QFrame()
        line1.setObjectName("line1")
        line1.setFrameShape(QFrame.HLine)
        line1.setFrameShadow(QFrame.Sunken)

        line2 = QFrame()
        line2.setObjectName("line2")
        line2.setFrameShape(QFrame.HLine)
        line2.setFrameShadow(QFrame.Sunken)

        glayout = QGridLayout()

        glayout.addWidget(line, 0, 0, 1, 3) # line-1
        glayout.addWidget(self.sample_rate_label, 1, 0, 1, 1)
        glayout.addWidget(self.sample_rate_combo, 1, 1, 1, 2)
        glayout.addWidget(self.gain_label, 2, 0, 1, 1)
        glayout.addWidget(self.gain_combo, 2, 1, 1, 2)
        glayout.addWidget(line1, 3, 0, 1, 3) # line-2
        glayout.addWidget(self.led_config_ch0_label, 4, 1, 1, 1)
        glayout.addWidget(self.led_config_ch1_label, 4, 2, 1, 1)
        glayout.addWidget(line2, 5, 0, 1, 3) # line-3
        glayout.addWidget(self.led_config_label, 6, 0, 1, 1)
        glayout.addWidget(self.led_config_ch0_combo, 6, 1, 1, 1)
        glayout.addWidget(self.led_config_ch1_combo, 6, 2, 1, 1)
        glayout.addWidget(self.led_status_config_label, 7, 0, 1, 1)
        glayout.addWidget(self.led_status_config_ch0_combo, 7, 1, 1, 1)
        glayout.addWidget(self.led_status_config_ch1_combo, 7, 2, 1, 1)
        glayout.addLayout(hlayout, 8, 1, 1, 1)
        glayout.addLayout(hlayout1, 8, 2, 1, 1)

        layout = QVBoxLayout(self)
        layout.addWidget(self.plot_widget)
        layout.addLayout(glayout)

        self.ui_group_ch_status_ch0 = [self.led_status_config_ch0_combo,
                                       self.led_status_config_ch0_min_sbox,
                                       self.led_status_config_ch0_max_sbox]

        self.ui_group_ch_status_ch1 = [self.led_status_config_ch1_combo,
                                       self.led_status_config_ch1_min_sbox,
                                       self.led_status_config_ch1_max_sbox]
    def add_buttonlist(self, layout, label, values, key=None, row=None, column = None, rowspan=None,
                       columnspan=None):
        """
        Add an array of buttons to a layout that can be used to display arrays of data, e.g. tags or categories.
        The ability to add and remove items from the array is also added.
        :param layout: QLayout. Layout to add widgets to.
        :param label: String. Name of the field, e.g. tags, or categories.
        :param values: list. List of either strings or dictionary objects.
        Optional
        :param key: Dictionary Key. If the values given are in a dictionary object a dictionary key must also be provided.
        :param row: int. QGridLayout row from which to add widgets.
        :param column: int. QGridLayout column to add widgets to.
        :param rowspan: int. Number of rows to span widgets.
        :param columnspan: int. Number of columns to span widgets.
        :return:
        """
        # Create Qlabel for edit field.
        lbl = QLabel(label)
        lbl.setFont(self.label_font)
        # Create layout for buttons.
        hbox = QHBoxLayout()
        # Define a size policy for the buttons
        btn_sizePolicy = QSizePolicy()
        btn_sizePolicy.setHorizontalPolicy(QSizePolicy.Expanding)
        btn_sizePolicy.setVerticalPolicy(QSizePolicy.Preferred)
        # Create a QButtonGroup
        btn_group = QButtonGroup()
        self.button_groups[label] = btn_group
        btn_group_id = 1
        # Create buttons and add to group and layout.
        list_element_type = type(values[0])
        if list_element_type is dict:
            for element in values:
                btn_str = str(element[key])
                btn = QPushButton(btn_str)
                btn.setFont(self.edit_font)
                btn.setFlat(True)
                btn.setSizePolicy(btn_sizePolicy)
                btn_group.addButton(btn, btn_group_id)
                hbox.addWidget(btn)
                btn_group_id += 1
        elif list_element_type is list:
            for element in values:
                btn_str = str(element)
                btn = QPushButton(btn_str)
                btn.setFont(self.edit_font)
                btn.setSizePolicy(btn_sizePolicy)
                btn_group.addButton(btn, btn_group_id)
                hbox.addWidget(btn)
                btn_group_id += 1

        txt_sizePolicy = QSizePolicy()
        txt_sizePolicy.setVerticalPolicy(QSizePolicy.Preferred)
        txt_sizePolicy.setHorizontalPolicy(QSizePolicy.Preferred)

        new_btn = QTextEdit()
        new_btn.setFont(self.edit_font)
        new_btn.setSizePolicy(txt_sizePolicy)
        hbox.addWidget(new_btn)

        options_layout = QVBoxLayout()

        options_btn_size_policy = QSizePolicy()
        options_btn_size_policy.setHorizontalPolicy(QSizePolicy.Preferred)
        options_btn_size_policy.setVerticalPolicy(QSizePolicy.Expanding)

        delete_btn = QPushButton()
        delete_btn.setIcon(QIcon(os.path.abspath(__file__ + '/../..' + '/img/exit.png')))
        delete_btn.setSizePolicy(options_btn_size_policy)
        delete_btn.pressed.connect(lambda: self.on_delete_button_from_list(btn_group, hbox))
        options_layout.addWidget(delete_btn)

        add_btn = QPushButton()
        add_btn.setIcon(QIcon(os.path.abspath(__file__ + '/../..' + '/img/Plus-50.png')))
        add_btn.setSizePolicy(options_btn_size_policy)
        add_btn.pressed.connect(lambda: self.on_add_button_to_list(btn_group, hbox, new_btn))
        options_layout.addWidget(add_btn)

        hbox.addLayout(options_layout)

        if type(layout) is QGridLayout:
            if rowspan is not None and columnspan is not None:
                layout.addWidget(lbl, row, column, rowspan, columnspan)
                layout.addLayout(hbox, row + rowspan + 1, column, rowspan, columnspan)
            else:
                layout.addWidget(lbl, row, column)
                layout.addLayout(hbox, row + 1, column)
        else:
            layout.addWidget(lbl)
            layout.addLayout(hbox)
Пример #32
0
    def __init__(self, selector: CellSelector):
        super().__init__("Plotting")
        self.selector = selector
        self.setStyleSheet(
            "QDockWidget > QWidget { border: 1px solid lightgray; }")
        self.roiDrawer = None
        self.setObjectName('PlottingWidget')
        self._plots = []
        self.cellMetas = []
        self._widget = QWidget()
        self._widget.setLayout(QHBoxLayout())
        self._plotScroll = QScrollArea()
        self._plotScroll.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOn)
        self._plotScroll.setWidgetResizable(True)
        self._plotScroll.horizontalScrollBar().setEnabled(False)
        self._plotScroll.horizontalScrollBar().setVisible(False)
        self._plotScroll.setMinimumWidth(75)
        self._plotScroll.setMaximumWidth(600)
        self._scrollContents = AspectRatioWidget(1, self)
        self._scrollContents.setLayout(QVBoxLayout())
        a = QSizePolicy()
        # a.setHeightForWidth(True)
        a.setHorizontalPolicy(
            QSizePolicy.Maximum)  #Stretch out as much as possible horizontally
        self._scrollContents.setSizePolicy(a)

        self._plotScroll.setWidget(self._scrollContents)
        buttons = QWidget()
        buttons.setMaximumWidth(100)
        buttons.setLayout(QVBoxLayout())
        _ = buttons.layout().addWidget
        self._anNameEdit = QLineEdit(self)
        self._oldPattern = ''
        self._oldCells = None
        self._anNameEdit.editingFinished.connect(self._anNameEditFinished)
        self._buttonGroup = QButtonGroup()
        self._lastButton = None
        self._buttonGroup.buttonReleased.connect(self._handleButtons)
        self._plotThumbnailButton = QPushButton("Thumbnail")
        self._plotRMSButton = QPushButton("RMS")
        self._plotRButton = QPushButton('R')
        self._buttonGroup.addButton(self._plotThumbnailButton)
        self._buttonGroup.addButton(self._plotRMSButton)
        self._buttonGroup.addButton(self._plotRButton)
        [i.setCheckable(True) for i in self._buttonGroup.buttons()]
        self._buttonGroup.buttons()[0].setChecked(True)
        frame = QFrame(parent=self)
        frame.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)
        l = QVBoxLayout()
        [l.addWidget(i) for i in self._buttonGroup.buttons()]
        frame.setLayout(l)
        self._refreshButton = QPushButton("Refresh")
        self._refreshButton.released.connect(
            lambda: self._generatePlots(self.selector.getSelectedCellMetas()))
        self._roiButton = QPushButton("Draw ROI's")
        self._roiButton.released.connect(self._startRoiDrawing)
        label = QLabel("Analysis Name")
        label.setMaximumHeight(20)
        _(label)
        _(self._anNameEdit)
        _(self._refreshButton)
        _(self._roiButton)
        _(frame)

        self._widget.layout().addWidget(self._plotScroll)
        self._widget.layout().addWidget(buttons)
        # self._widget.setMaximumWidth(self.plotScroll.maximumWidth()+buttons.maximumWidth()+10)
        self.setWidget(self._widget)

        self._enableAnalysisPlottingButtons('false')
Пример #33
0
    def _createView(self):

        layout = QVBoxLayout()

        self.le_league = MonitoredLineEdit()
        self.le_league.setText("League TBD")
        self.le_league.setAlignment(Qt.AlignCenter)
        self.le_league.setPlaceholderText("League TBD")
        self.le_league.textModified.connect(self.league_changed)
        policy = QSizePolicy()
        policy.setHorizontalStretch(3)
        policy.setHorizontalPolicy(QSizePolicy.Expanding)
        policy.setVerticalStretch(1)
        policy.setVerticalPolicy(QSizePolicy.Fixed)
        self.le_league.setSizePolicy(policy)

        self.le_team = [MonitoredLineEdit() for y in range(2)]
        self.le_player = [[MonitoredLineEdit() for x in range(
            self.max_no_sets)] for y in range(2)]
        self.cb_race = [[QComboBox() for x in range(self.max_no_sets)]
                        for y in range(2)]
        self.sl_score = [QSlider(Qt.Horizontal)
                         for y in range(self.max_no_sets)]
        self.le_map = [MapLineEdit() for y in range(self.max_no_sets)]
        self.label_set = [QPushButton('#{}'.format(y + 1), self)
                          for y in range(self.max_no_sets)]
        self.setContainer = [QHBoxLayout()
                             for y in range(self.max_no_sets)]

        container = QHBoxLayout()
        for team_idx in range(2):
            self.le_team[team_idx].setText("TBD")
            self.le_team[team_idx].setAlignment(
                Qt.AlignCenter)
            self.le_team[team_idx].setPlaceholderText(
                "Team " + str(team_idx + 1))
            policy = QSizePolicy()
            policy.setHorizontalStretch(4)
            policy.setHorizontalPolicy(
                QSizePolicy.Expanding)
            policy.setVerticalStretch(1)
            policy.setVerticalPolicy(QSizePolicy.Fixed)
            self.le_team[team_idx].setSizePolicy(policy)
            self.le_team[team_idx].setMinimumWidth(self.mimumLineEditWidth)
            self.le_team[team_idx].textModified.connect(
                lambda team_idx=team_idx: self.team_changed(team_idx))

        self.qb_logo1 = IconPushButton()
        self.qb_logo1.setFixedWidth(self.raceWidth)
        self.qb_logo1.clicked.connect(lambda: self.parent.logoDialog(1, self))
        logo = self.controller.logoManager.getTeam1(self._ctrlID)
        self.qb_logo1.setIcon(QIcon(logo.provideQPixmap()))

        self.qb_logo2 = IconPushButton()
        self.qb_logo2.setFixedWidth(self.raceWidth)
        self.qb_logo2.clicked.connect(lambda: self.parent.logoDialog(2, self))
        logo = self.controller.logoManager.getTeam2(self._ctrlID)
        self.qb_logo2.setIcon(QIcon(logo.provideQPixmap()))

        self.sl_team = QSlider(Qt.Horizontal)
        self.sl_team.setTracking(False)
        self.sl_team.setMinimum(-1)
        self.sl_team.setMaximum(1)
        self.sl_team.setValue(0)
        self.sl_team.setTickPosition(
            QSlider.TicksBothSides)
        self.sl_team.setTickInterval(1)
        self.sl_team.valueChanged.connect(lambda x: self.sl_changed(-1, x))
        self.sl_team.setToolTip(_('Choose your team'))
        self.sl_team.setMinimumHeight(5)
        self.sl_team.setFixedWidth(self.scoreWidth)
        policy = QSizePolicy()
        policy.setHorizontalStretch(0)
        policy.setHorizontalPolicy(QSizePolicy.Fixed)
        policy.setVerticalStretch(1)
        policy.setVerticalPolicy(QSizePolicy.Fixed)
        self.sl_team.setSizePolicy(policy)

        container = QGridLayout()

        button = QPushButton()
        pixmap = QIcon(
            scctool.settings.getResFile('update.png'))
        button.setIcon(pixmap)
        button.clicked.connect(
            lambda: self.controller.swapTeams())
        button.setFixedWidth(self.labelWidth)
        button.setToolTip(_("Swap teams and logos."))
        container.addWidget(button, 0, 0, 2, 1)

        label = QLabel(_("League:"))
        label.setAlignment(Qt.AlignCenter)
        policy = QSizePolicy()
        policy.setHorizontalStretch(4)
        policy.setHorizontalPolicy(QSizePolicy.Expanding)
        policy.setVerticalStretch(1)
        policy.setVerticalPolicy(QSizePolicy.Fixed)
        label.setSizePolicy(policy)
        container.addWidget(label, 0, 1, 1, 1)

        label = QLabel(_("Maps \ Teams:"))
        label.setAlignment(Qt.AlignCenter)
        policy = QSizePolicy()
        policy.setHorizontalStretch(4)
        policy.setHorizontalPolicy(QSizePolicy.Expanding)
        policy.setVerticalStretch(1)
        policy.setVerticalPolicy(QSizePolicy.Fixed)
        label.setSizePolicy(policy)
        container.addWidget(label, 1, 1, 1, 1)

        container.addWidget(self.qb_logo1, 0, 2, 2, 1)
        container.addWidget(self.le_league, 0, 3, 1, 3)
        container.addWidget(self.le_team[0], 1, 3, 1, 1)
        container.addWidget(self.sl_team, 1, 4, 1, 1)
        container.addWidget(self.le_team[1], 1, 5, 1, 1)
        container.addWidget(self.qb_logo2, 0, 6, 2, 1)

        layout.addLayout(container)

        for player_idx in range(self.max_no_sets):
            self.le_map[player_idx].textModified.connect(
                lambda player_idx=player_idx: self.map_changed(player_idx))
            for team_idx in range(2):
                self.cb_race[team_idx][player_idx].\
                    currentIndexChanged.connect(
                    lambda idx,
                    t=team_idx,
                    p=player_idx: self.race_changed(t, p))
                self.le_player[team_idx][player_idx].textModified.connect(
                    lambda t=team_idx,
                    p=player_idx: self.player_changed(t, p))
                self.le_player[team_idx][player_idx].setText("TBD")
                self.le_player[team_idx][player_idx].setAlignment(
                    Qt.AlignCenter)
                self.le_player[team_idx][player_idx].setPlaceholderText(
                    _("Player {} of team {}").format(player_idx + 1,
                                                     team_idx + 1))
                self.le_player[team_idx][player_idx].setMinimumWidth(
                    self.mimumLineEditWidth)
                self.le_player[team_idx][player_idx].setContextMenuPolicy(
                    Qt.CustomContextMenu)
                self.le_player[team_idx][player_idx].\
                    customContextMenuRequested.connect(
                    lambda x, team_idx=team_idx,
                    player_idx=player_idx:
                    self.openPlayerContextMenu(team_idx, player_idx))

                for i in range(4):
                    self.cb_race[team_idx][player_idx].addItem(
                        QIcon(scctool.settings.getResFile(
                            str(i) + ".png")), "")

                self.cb_race[team_idx][player_idx].setFixedWidth(
                    self.raceWidth)

            self.sl_score[player_idx].setMinimum(-1)
            self.sl_score[player_idx].setMaximum(1)
            self.sl_score[player_idx].setValue(0)
            self.sl_score[player_idx].setTickPosition(
                QSlider.TicksBothSides)
            self.sl_score[player_idx].setTickInterval(1)
            self.sl_score[player_idx].setTracking(False)
            self.sl_score[player_idx].valueChanged.connect(
                lambda x,
                player_idx=player_idx: self.sl_changed(player_idx, x))
            self.sl_score[player_idx].setToolTip(_('Set the score'))
            self.sl_score[player_idx].setFixedWidth(self.scoreWidth)

            self.le_map[player_idx].setText("TBD")
            self.le_map[player_idx].setAlignment(
                Qt.AlignCenter)
            self.le_map[player_idx].setPlaceholderText(
                _("Map {}").format(player_idx + 1))
            self.le_map[player_idx].setMinimumWidth(
                self.mimumLineEditWidth)

            # self.le_map[player_idx].setReadOnly(True)

            self.setContainer[player_idx] = QHBoxLayout()
            # self.label_set[player_idx].setText("#" + str(player_idx + 1))
            # self.label_set[player_idx].setAlignment(
            #    Qt.AlignCenter)
            self.label_set[player_idx].setToolTip(
                _("Select map on Mapstats Browser Source."))
            self.label_set[player_idx].setEnabled(False)
            self.label_set[player_idx].clicked.connect(
                lambda x,
                player_idx=player_idx:
                self.showMap(player_idx))
            self.label_set[player_idx].setFixedWidth(self.labelWidth)
            self.setContainer[player_idx].addWidget(
                self.label_set[player_idx], 0)
            self.setContainer[player_idx].addWidget(
                self.le_map[player_idx], 4)
            self.setContainer[player_idx].addWidget(
                self.cb_race[0][player_idx], 0)
            self.setContainer[player_idx].addWidget(
                self.le_player[0][player_idx], 4)
            self.setContainer[player_idx].addWidget(
                self.sl_score[player_idx], 0)
            self.setContainer[player_idx].addWidget(
                self.le_player[1][player_idx], 4)
            self.setContainer[player_idx].addWidget(
                self.cb_race[1][player_idx], 0)
            layout.addLayout(self.setContainer[player_idx])

        layout.addItem(QSpacerItem(
            0, 0, QSizePolicy.Minimum,
            QSizePolicy.Expanding))
        self.setLayout(layout)

        self.updateMapCompleters()
        self.updatePlayerCompleters()
        self.updateTeamCompleters()
Пример #34
0
    def __init__(self, *args):
        super().__init__(BrickletIndustrialDual020mAV2, *args)

        self.dual020 = self.device

        self.str_connected = 'Channel {0} is <font color="green">connected (&gt;= 3.9 mA)</font>'
        self.str_not_connected = 'Channel {0} is <font color="red">not connected (&lt; 3.9 mA)</font>'

        self.cbe_current0 = CallbackEmulator(
            self.dual020.get_current,
            0,
            self.cb_current,
            self.increase_error_count,
            pass_arguments_to_result_callback=True)
        self.cbe_current1 = CallbackEmulator(
            self.dual020.get_current,
            1,
            self.cb_current,
            self.increase_error_count,
            pass_arguments_to_result_callback=True)

        self.connected_labels = [
            FixedSizeLabel(self.str_not_connected.format(0)),
            FixedSizeLabel(self.str_not_connected.format(1))
        ]

        self.current_current = [CurveValueWrapper(),
                                CurveValueWrapper()]  # float, mA

        plots = [('Channel 0', Qt.red, self.current_current[0],
                  lambda value: '{:.03f} mA'.format(round(value, 3))),
                 ('Channel 1', Qt.blue, self.current_current[1],
                  lambda value: '{:.03f} mA'.format(round(value, 3)))]

        self.plot_widget = PlotWidget('Current [mA]',
                                      plots,
                                      extra_key_widgets=self.connected_labels,
                                      y_resolution=0.001)

        h_sp = QSizePolicy()
        h_sp.setHorizontalPolicy(QSizePolicy.Expanding)

        self.sample_rate_label = QLabel('Sample Rate:')
        self.sample_rate_combo = QComboBox()
        self.sample_rate_combo.addItem('240 Hz')
        self.sample_rate_combo.addItem('60 Hz')
        self.sample_rate_combo.addItem('15 Hz')
        self.sample_rate_combo.addItem('4 Hz')
        self.sample_rate_combo.currentIndexChanged.connect(
            self.sample_rate_combo_index_changed)
        self.sample_rate_combo.setSizePolicy(h_sp)

        self.gain_label = QLabel('Gain:')
        self.gain_combo = QComboBox()
        self.gain_combo.addItem('x1')
        self.gain_combo.addItem('x2')
        self.gain_combo.addItem('x4')
        self.gain_combo.addItem('x8')
        self.gain_combo.currentIndexChanged.connect(
            self.gain_combo_index_changed)
        self.gain_combo.setSizePolicy(h_sp)

        self.led_config_ch0_label = QLabel('Channel 0')
        self.led_config_ch1_label = QLabel('Channel 1')
        self.led_config_label = QLabel('LED Config:')
        self.led_status_config_label = QLabel('LED Status Config:')
        self.led_status_config_ch0_min_label = QLabel('Min:')
        self.led_status_config_ch0_max_label = QLabel('Max:')
        self.led_status_config_ch1_min_label = QLabel('Min:')
        self.led_status_config_ch1_max_label = QLabel('Max:')

        self.led_config_ch0_combo = QComboBox()
        self.led_config_ch0_combo.addItem('Off')
        self.led_config_ch0_combo.addItem('On')
        self.led_config_ch0_combo.addItem('Show Heartbeat')
        self.led_config_ch0_combo.addItem('Show Channel Status')
        self.led_config_ch0_combo.setSizePolicy(h_sp)
        self.led_config_ch0_combo.currentIndexChanged.connect(
            self.led_config_ch0_combo_changed)

        self.led_config_ch1_combo = QComboBox()
        self.led_config_ch1_combo.addItem('Off')
        self.led_config_ch1_combo.addItem('On')
        self.led_config_ch1_combo.addItem('Show Heartbeat')
        self.led_config_ch1_combo.addItem('Show Channel Status')
        self.led_config_ch1_combo.setSizePolicy(h_sp)
        self.led_config_ch1_combo.currentIndexChanged.connect(
            self.led_config_ch1_combo_changed)

        self.led_status_config_ch0_combo = QComboBox()
        self.led_status_config_ch0_combo.addItem('Threshold')
        self.led_status_config_ch0_combo.addItem('Intensity')
        self.led_status_config_ch0_combo.setSizePolicy(h_sp)
        self.led_status_config_ch0_combo.currentIndexChanged.connect(
            self.led_status_config_ch0_combo_changed)

        self.led_status_config_ch1_combo = QComboBox()
        self.led_status_config_ch1_combo.addItem('Threshold')
        self.led_status_config_ch1_combo.addItem('Intensity')
        self.led_status_config_ch1_combo.setSizePolicy(h_sp)
        self.led_status_config_ch1_combo.currentIndexChanged.connect(
            self.led_status_config_ch1_combo_changed)

        self.led_status_config_ch0_min_sbox = QDoubleSpinBox()
        self.led_status_config_ch0_max_sbox = QDoubleSpinBox()
        self.led_status_config_ch1_min_sbox = QDoubleSpinBox()
        self.led_status_config_ch1_max_sbox = QDoubleSpinBox()

        self.led_status_config_ch0_min_sbox.setValue(0)
        self.led_status_config_ch0_min_sbox.setMinimum(0)
        self.led_status_config_ch0_min_sbox.setSingleStep(0.5)
        self.led_status_config_ch0_min_sbox.setDecimals(3)
        self.led_status_config_ch0_min_sbox.setSuffix(' mA')
        self.led_status_config_ch0_min_sbox.setMaximum(22.5)
        self.led_status_config_ch0_min_sbox.valueChanged.connect(
            self.led_status_config_ch0_min_sbox_changed)

        self.led_status_config_ch0_max_sbox.setValue(0)
        self.led_status_config_ch0_max_sbox.setMinimum(0)
        self.led_status_config_ch0_max_sbox.setSingleStep(0.5)
        self.led_status_config_ch0_max_sbox.setDecimals(3)
        self.led_status_config_ch0_max_sbox.setSuffix(' mA')
        self.led_status_config_ch0_max_sbox.setMaximum(22.5)
        self.led_status_config_ch0_max_sbox.valueChanged.connect(
            self.led_status_config_ch0_max_sbox_changed)

        self.led_status_config_ch1_min_sbox.setValue(0)
        self.led_status_config_ch1_min_sbox.setMinimum(0)
        self.led_status_config_ch1_min_sbox.setSingleStep(0.5)
        self.led_status_config_ch1_min_sbox.setDecimals(3)
        self.led_status_config_ch1_min_sbox.setSuffix(' mA')
        self.led_status_config_ch1_min_sbox.setMaximum(22.5)
        self.led_status_config_ch1_min_sbox.valueChanged.connect(
            self.led_status_config_ch1_min_sbox_changed)

        self.led_status_config_ch1_max_sbox.setValue(0)
        self.led_status_config_ch1_max_sbox.setMinimum(0)
        self.led_status_config_ch1_max_sbox.setSingleStep(0.5)
        self.led_status_config_ch1_max_sbox.setDecimals(3)
        self.led_status_config_ch1_max_sbox.setSuffix(' mA')
        self.led_status_config_ch1_max_sbox.setMaximum(22.5)
        self.led_status_config_ch1_max_sbox.valueChanged.connect(
            self.led_status_config_ch1_max_sbox_changed)

        hlayout = QHBoxLayout()
        self.led_status_config_ch0_min_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch0_max_sbox.setSizePolicy(h_sp)
        hlayout.addWidget(self.led_status_config_ch0_min_label)
        hlayout.addWidget(self.led_status_config_ch0_min_sbox)
        hlayout.addWidget(self.led_status_config_ch0_max_label)
        hlayout.addWidget(self.led_status_config_ch0_max_sbox)

        hlayout1 = QHBoxLayout()
        self.led_status_config_ch1_min_sbox.setSizePolicy(h_sp)
        self.led_status_config_ch1_max_sbox.setSizePolicy(h_sp)
        hlayout1.addWidget(self.led_status_config_ch1_min_label)
        hlayout1.addWidget(self.led_status_config_ch1_min_sbox)
        hlayout1.addWidget(self.led_status_config_ch1_max_label)
        hlayout1.addWidget(self.led_status_config_ch1_max_sbox)

        line = QFrame()
        line.setObjectName("line")
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)

        line1 = QFrame()
        line1.setObjectName("line1")
        line1.setFrameShape(QFrame.HLine)
        line1.setFrameShadow(QFrame.Sunken)

        line2 = QFrame()
        line2.setObjectName("line2")
        line2.setFrameShape(QFrame.HLine)
        line2.setFrameShadow(QFrame.Sunken)

        glayout = QGridLayout()

        glayout.addWidget(line, 0, 0, 1, 3)  # line-1
        glayout.addWidget(self.sample_rate_label, 1, 0, 1, 1)
        glayout.addWidget(self.sample_rate_combo, 1, 1, 1, 2)
        glayout.addWidget(self.gain_label, 2, 0, 1, 1)
        glayout.addWidget(self.gain_combo, 2, 1, 1, 2)
        glayout.addWidget(line1, 3, 0, 1, 3)  # line-2
        glayout.addWidget(self.led_config_ch0_label, 4, 1, 1, 1)
        glayout.addWidget(self.led_config_ch1_label, 4, 2, 1, 1)
        glayout.addWidget(line2, 5, 0, 1, 3)  # line-3
        glayout.addWidget(self.led_config_label, 6, 0, 1, 1)
        glayout.addWidget(self.led_config_ch0_combo, 6, 1, 1, 1)
        glayout.addWidget(self.led_config_ch1_combo, 6, 2, 1, 1)
        glayout.addWidget(self.led_status_config_label, 7, 0, 1, 1)
        glayout.addWidget(self.led_status_config_ch0_combo, 7, 1, 1, 1)
        glayout.addWidget(self.led_status_config_ch1_combo, 7, 2, 1, 1)
        glayout.addLayout(hlayout, 8, 1, 1, 1)
        glayout.addLayout(hlayout1, 8, 2, 1, 1)

        layout = QVBoxLayout(self)
        layout.addWidget(self.plot_widget)
        layout.addLayout(glayout)

        self.ui_group_ch_status_ch0 = [
            self.led_status_config_ch0_combo,
            self.led_status_config_ch0_min_sbox,
            self.led_status_config_ch0_max_sbox
        ]

        self.ui_group_ch_status_ch1 = [
            self.led_status_config_ch1_combo,
            self.led_status_config_ch1_min_sbox,
            self.led_status_config_ch1_max_sbox
        ]