示例#1
0
    def __init__(self, ip, port, sal, parent=None):
        super(EUI, self).__init__(parent)
        self.ip = ip
        self.port = port
        self.client = liveview.AsyncLiveViewClient(self.ip, self.port)
        self.event_loop = asyncio.get_event_loop()
        self.event_loop.run_until_complete(self.client.start())
        # self.sal = salobj.Remote(SALPY_GenericCamera, index=salIndex)
        self.sal = sal
        # self.sal.subscribeEvent

        self.layout = QHBoxLayout()
        self.controlsLayout = QVBoxLayout()
        self.imageLayout = QVBoxLayout()

        layout = QHBoxLayout()
        self.startLiveViewButton = QPushButton("Start Live")
        self.startLiveViewButton.clicked.connect(self.startLiveView)
        self.stopLiveViewButton = QPushButton("Stop Live")
        self.stopLiveViewButton.clicked.connect(self.stopLiveView)
        layout.addWidget(self.startLiveViewButton)
        layout.addWidget(self.stopLiveViewButton)
        self.controlsLayout.addLayout(layout)

        layout = QHBoxLayout()
        layout.addWidget(QLabel("Exposure"))
        self.exposureTimeEdit = QDoubleSpinBox()
        self.exposureTimeEdit.setRange(0, 900.0)
        self.exposureTimeEdit.setDecimals(6)
        layout.addWidget(self.exposureTimeEdit)
        self.controlsLayout.addLayout(layout)

        layout = QVBoxLayout()
        subLayout = QHBoxLayout()
        subLayout.addWidget(QLabel("Top"))
        self.roiTopEdit = QDoubleSpinBox()
        self.roiTopEdit.setRange(0, 4095)
        self.roiTopEdit.setDecimals(0)
        subLayout.addWidget(self.roiTopEdit)
        layout.addLayout(subLayout)
        subLayout = QHBoxLayout()
        subLayout.addWidget(QLabel("Left"))
        self.roiLeftEdit = QDoubleSpinBox()
        self.roiLeftEdit.setRange(0, 4095)
        self.roiLeftEdit.setDecimals(0)
        subLayout.addWidget(self.roiLeftEdit)
        layout.addLayout(subLayout)
        subLayout = QHBoxLayout()
        subLayout.addWidget(QLabel("Width"))
        self.roiWidthEdit = QDoubleSpinBox()
        self.roiWidthEdit.setRange(0, 4095)
        self.roiWidthEdit.setDecimals(0)
        subLayout.addWidget(self.roiWidthEdit)
        layout.addLayout(subLayout)
        subLayout = QHBoxLayout()
        subLayout.addWidget(QLabel("Height"))
        self.roiHeightEdit = QDoubleSpinBox()
        self.roiHeightEdit.setRange(0, 4095)
        self.roiHeightEdit.setDecimals(0)
        subLayout.addWidget(self.roiHeightEdit)
        layout.addLayout(subLayout)
        self.setROIButton = QPushButton("Set")
        self.setROIButton.clicked.connect(self.setROI)
        layout.addWidget(self.setROIButton)
        self.setFullFrameButton = QPushButton("Set Full Frame")
        self.setFullFrameButton.clicked.connect(self.setFullFrame)
        layout.addWidget(self.setFullFrameButton)
        self.controlsLayout.addLayout(layout)

        layout = QVBoxLayout()
        layout.addWidget(QLabel("File Path:"))
        self.filePathEdit = QTextEdit()
        layout.addWidget(self.filePathEdit)
        self.takeExposureButton = QPushButton("Take Images")
        self.takeExposureButton.clicked.connect(self.takeImages)
        layout.addWidget(self.takeExposureButton)
        self.controlsLayout.addLayout(layout)

        img = Image.fromarray(np.zeros((1024, 1014))).convert("I")
        img.save("/tmp/foo.png")

        self.pix = QPixmap("/tmp/foo.png")

        self.imageLabel = QLabel()
        self.imageLabel.setPixmap(self.pix)
        self.imageLabel.setGeometry(QtCore.QRect(40, 40, 800, 800))

        self.imageLayout.addWidget(self.imageLabel)

        self.layout.addLayout(self.controlsLayout)
        self.layout.addLayout(self.imageLayout)

        self.setLayout(self.layout)
        self.setFixedSize(1000, 880)
示例#2
0
    def __init_geometry_widget__(self):
        self.__geometry_widget = QGroupBox("Geometry", self)

        load_geometry_button = QPushButton("Load Geometry")
        load_geometry_button.clicked.connect(self.load_geometry)
        remove_geometry_button = QPushButton("Remove Geometry")
        remove_geometry_button.clicked.connect(self.remove_geometry)
        rotate_x_label = QLabel("Rotate X:", self.__geometry_widget)
        self.rotate_x_slider = QSlider(orientation=Qt.Horizontal,
                                       parent=self.__geometry_widget)
        self.rotate_x_slider.setTickPosition(QSlider.TicksBothSides)
        self.rotate_x_slider.setTickInterval(45)
        self.rotate_x_slider.setRange(-180, 180)
        self.rotate_x_slider.setValue(0)
        self.rotate_x_spin = QSpinBox(self.__geometry_widget)
        self.rotate_x_spin.setMinimum(-180)
        self.rotate_x_spin.setMaximum(180)
        self.rotate_x_spin.setValue(0)
        self.rotate_x_slider.valueChanged.connect(self.rotate_x_spin.setValue)
        self.rotate_x_slider.valueChanged.connect(
            self.__slicer_widget.set_x_rotation)
        self.rotate_x_spin.valueChanged.connect(self.rotate_x_slider.setValue)
        self.rotate_x_spin.valueChanged.connect(
            self.__slicer_widget.set_x_rotation)

        rotate_y_label = QLabel("Rotate Y:", self.__geometry_widget)
        self.rotate_y_slider = QSlider(orientation=Qt.Horizontal,
                                       parent=self.__geometry_widget)
        self.rotate_y_slider.setTickPosition(QSlider.TicksBothSides)
        self.rotate_y_slider.setTickInterval(45)
        self.rotate_y_slider.setRange(-180, 180)
        self.rotate_y_slider.setValue(0)
        self.rotate_y_spin = QSpinBox(self.__geometry_widget)
        self.rotate_y_spin.setMinimum(-180)
        self.rotate_y_spin.setMaximum(180)
        self.rotate_y_spin.setValue(0)
        self.rotate_y_slider.valueChanged.connect(self.rotate_y_spin.setValue)
        self.rotate_y_slider.valueChanged.connect(
            self.__slicer_widget.set_y_rotation)
        self.rotate_y_spin.valueChanged.connect(self.rotate_y_slider.setValue)
        self.rotate_y_spin.valueChanged.connect(
            self.__slicer_widget.set_y_rotation)

        rotate_z_label = QLabel("Rotate Z:", self.__geometry_widget)
        self.rotate_z_slider = QSlider(orientation=Qt.Horizontal,
                                       parent=self.__geometry_widget)
        self.rotate_z_slider.setTickPosition(QSlider.TicksBothSides)
        self.rotate_z_slider.setTickInterval(45)
        self.rotate_z_slider.setRange(-180, 180)
        self.rotate_z_slider.setValue(0)
        self.rotate_z_spin = QSpinBox(self.__geometry_widget)
        self.rotate_z_spin.setMinimum(-180)
        self.rotate_z_spin.setMaximum(180)
        self.rotate_z_spin.setValue(0)
        self.rotate_z_slider.valueChanged.connect(self.rotate_z_spin.setValue)
        self.rotate_z_slider.valueChanged.connect(
            self.__slicer_widget.set_z_rotation)
        self.rotate_z_spin.valueChanged.connect(self.rotate_z_slider.setValue)
        self.rotate_z_spin.valueChanged.connect(
            self.__slicer_widget.set_z_rotation)

        translate_x_label = QLabel("Translate X:", self.__geometry_widget)
        self.translate_x_slider = QSlider(orientation=Qt.Horizontal,
                                          parent=self.__geometry_widget)
        self.translate_x_slider.setTickPosition(QSlider.TicksBothSides)
        self.translate_x_slider.setTickInterval(
            self.dlp_controller.projector_pixel_size)
        self.translate_x_slider.setRange(
            -self.dlp_controller.projector_width *
            self.dlp_controller.projector_pixel_size * 0.5,
            self.dlp_controller.projector_width *
            self.dlp_controller.projector_pixel_size * 0.5)
        self.translate_x_slider.setValue(0)
        self.translate_x_spin = QDoubleSpinBox(self.__geometry_widget)
        self.translate_x_spin.setMinimum(
            -self.dlp_controller.projector_width *
            self.dlp_controller.projector_pixel_size * 0.5)
        self.translate_x_spin.setMaximum(
            self.dlp_controller.projector_width *
            self.dlp_controller.projector_pixel_size * 0.5)
        self.translate_x_spin.setSingleStep(
            self.dlp_controller.projector_pixel_size)
        self.translate_x_spin.setValue(0)
        self.translate_x_slider.valueChanged.connect(
            self.translate_x_spin.setValue)
        self.translate_x_slider.valueChanged.connect(
            self.__slicer_widget.set_x_pos)
        self.translate_x_spin.valueChanged.connect(
            self.translate_x_slider.setValue)
        self.translate_x_spin.valueChanged.connect(
            self.__slicer_widget.set_x_pos)

        translate_z_label = QLabel("Translate Z:", self.__geometry_widget)
        self.translate_z_slider = QSlider(orientation=Qt.Horizontal,
                                          parent=self.__geometry_widget)
        self.translate_z_slider.setTickPosition(QSlider.TicksBothSides)
        self.translate_z_slider.setTickInterval(
            self.dlp_controller.projector_pixel_size)
        self.translate_z_slider.setRange(
            -self.dlp_controller.projector_height *
            self.dlp_controller.projector_pixel_size * 0.5,
            self.dlp_controller.projector_height *
            self.dlp_controller.projector_pixel_size * 0.5)
        self.translate_z_slider.setValue(0)
        self.translate_z_spin = QDoubleSpinBox(self.__geometry_widget)
        self.translate_z_spin.setMinimum(
            -self.dlp_controller.projector_height *
            self.dlp_controller.projector_pixel_size * 0.5)
        self.translate_z_spin.setMaximum(
            self.dlp_controller.projector_height *
            self.dlp_controller.projector_pixel_size * 0.5)
        self.translate_z_spin.setSingleStep(
            self.dlp_controller.projector_pixel_size)
        self.translate_z_spin.setValue(0)
        self.translate_z_slider.valueChanged.connect(
            self.translate_z_spin.setValue)
        self.translate_z_slider.valueChanged.connect(
            self.__slicer_widget.set_z_pos)
        self.translate_z_spin.valueChanged.connect(
            self.translate_z_slider.setValue)
        self.translate_z_spin.valueChanged.connect(
            self.__slicer_widget.set_z_pos)

        scale_x_label = QLabel("Scale X:", self.__geometry_widget)
        self.scale_x_spin = QDoubleSpinBox(self.__geometry_widget)
        self.scale_x_spin.setMinimum(-1000)
        self.scale_x_spin.setMaximum(1000)
        self.scale_x_spin.setDecimals(2)
        self.scale_x_spin.setValue(1)
        self.scale_x_spin.setSingleStep(0.01)
        self.scale_x_spin.setObjectName("scale_x_spin")
        self.scale_x_spin.valueChanged.connect(self.set_scaling)

        scale_y_label = QLabel("Scale Y:", self.__geometry_widget)
        self.scale_y_spin = QDoubleSpinBox(self.__geometry_widget)
        self.scale_y_spin.setMinimum(-1000)
        self.scale_y_spin.setMaximum(1000)
        self.scale_y_spin.setDecimals(2)
        self.scale_y_spin.setValue(1)
        self.scale_y_spin.setSingleStep(0.01)
        self.scale_y_spin.setObjectName("scale_y_spin")
        self.scale_y_spin.valueChanged.connect(self.set_scaling)

        scale_z_label = QLabel("Scale Z:", self.__geometry_widget)
        self.scale_z_spin = QDoubleSpinBox(self.__geometry_widget)
        self.scale_z_spin.setMinimum(-1000)
        self.scale_z_spin.setMaximum(1000)
        self.scale_z_spin.setDecimals(2)
        self.scale_z_spin.setValue(1)
        self.scale_z_spin.setSingleStep(0.01)
        self.scale_z_spin.setObjectName("scale_z_spin")
        self.scale_z_spin.valueChanged.connect(self.set_scaling)

        self.uniform_scaling = QCheckBox("Uniform Scaling",
                                         self.__geometry_widget)
        self.uniform_scaling.setChecked(True)
        # self.uniform_scaling.setLayoutDirection(Qt.RightToLeft)

        list_of_measures = ('\u03BCm', 'mm', 'cm', 'dm', 'm')
        self.list_of_measures_coefficients = [0.001, 1, 10, 100, 1000]
        unit_of_measure_label = QLabel("Unit of Measure",
                                       self.__geometry_widget)
        self.unit_of_measure_combo = QComboBox(self.__geometry_widget)
        for measure in list_of_measures:
            self.unit_of_measure_combo.addItem(measure)
        self.unit_of_measure_combo.setCurrentIndex(1)
        self.unit_of_measure_combo.currentIndexChanged.connect(
            self.update_unit_of_measure)

        rotate_x_row = 0
        rotate_y_row = rotate_x_row + 1
        rotate_z_row = rotate_y_row + 1
        translate_x_row = rotate_z_row + 1
        translate_z_row = translate_x_row + 1
        scale_x_row = translate_z_row + 1
        scale_y_row = scale_x_row + 1
        scale_z_row = scale_y_row + 1
        uniform_scaling_row = scale_x_row
        unit_of_measure_row = scale_y_row
        load_geometry_row = scale_z_row + 1
        remove_geometry_row = load_geometry_row

        geometry_layout = QGridLayout(self.__geometry_widget)
        geometry_layout.addWidget(load_geometry_button, load_geometry_row, 1,
                                  1, 2)
        geometry_layout.addWidget(remove_geometry_button, remove_geometry_row,
                                  3, 1, 2)
        geometry_layout.addWidget(rotate_x_label, rotate_x_row, 0)
        geometry_layout.addWidget(self.rotate_x_slider, rotate_x_row, 1, 1, 4)
        geometry_layout.addWidget(self.rotate_x_spin, rotate_x_row, 5)
        geometry_layout.addWidget(rotate_y_label, rotate_y_row, 0)
        geometry_layout.addWidget(self.rotate_y_slider, rotate_y_row, 1, 1, 4)
        geometry_layout.addWidget(self.rotate_y_spin, rotate_y_row, 5)
        geometry_layout.addWidget(rotate_z_label, rotate_z_row, 0)
        geometry_layout.addWidget(self.rotate_z_slider, rotate_z_row, 1, 1, 4)
        geometry_layout.addWidget(self.rotate_z_spin, rotate_z_row, 5)
        geometry_layout.addWidget(translate_x_label, translate_x_row, 0)
        geometry_layout.addWidget(self.translate_x_slider, translate_x_row, 1,
                                  1, 4)
        geometry_layout.addWidget(self.translate_x_spin, translate_x_row, 5)
        geometry_layout.addWidget(translate_z_label, translate_z_row, 0)
        geometry_layout.addWidget(self.translate_z_slider, translate_z_row, 1,
                                  1, 4)
        geometry_layout.addWidget(self.translate_z_spin, translate_z_row, 5)
        geometry_layout.addWidget(scale_x_label, scale_x_row, 0)
        geometry_layout.addWidget(self.scale_x_spin, scale_x_row, 1)
        geometry_layout.addWidget(scale_y_label, scale_y_row, 0)
        geometry_layout.addWidget(self.scale_y_spin, scale_y_row, 1)
        geometry_layout.addWidget(scale_z_label, scale_z_row, 0)
        geometry_layout.addWidget(self.scale_z_spin, scale_z_row, 1)
        geometry_layout.addWidget(self.uniform_scaling, uniform_scaling_row, 3,
                                  1, 2)
        geometry_layout.addWidget(unit_of_measure_label, unit_of_measure_row,
                                  4)
        geometry_layout.addWidget(self.unit_of_measure_combo,
                                  unit_of_measure_row, 3)
        self.__geometry_widget.setLayout(geometry_layout)
示例#3
0
    def createGeneralTab(self):

        main_window = self.main_window

        # Masking options
        self.maskingCheck = QCheckBox('')
        self.maskingCheck.stateChanged.connect(main_window.toggleMasking)

        self.maskColorButton = QPushButton()
        self.maskColorButton.setCursor(QtCore.Qt.PointingHandCursor)
        self.maskColorButton.setFixedWidth(
            self.font_metric.width("XXXXXXXXXX"))
        self.maskColorButton.setFixedHeight(self.font_metric.height() * 1.5)
        self.maskColorButton.clicked.connect(main_window.editMaskingColor)

        # Highlighting options
        self.hlCheck = QCheckBox('')
        self.hlCheck.stateChanged.connect(main_window.toggleHighlighting)

        self.hlColorButton = QPushButton()
        self.hlColorButton.setCursor(QtCore.Qt.PointingHandCursor)
        self.hlColorButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX"))
        self.hlColorButton.setFixedHeight(self.font_metric.height() * 1.5)
        self.hlColorButton.clicked.connect(main_window.editHighlightColor)

        self.alphaBox = QDoubleSpinBox()
        self.alphaBox.setRange(0, 1)
        self.alphaBox.setSingleStep(.05)
        self.alphaBox.valueChanged.connect(main_window.editAlpha)

        self.seedBox = QSpinBox()
        self.seedBox.setRange(1, 999)
        self.seedBox.valueChanged.connect(main_window.editSeed)

        # General options
        self.bgButton = QPushButton()
        self.bgButton.setCursor(QtCore.Qt.PointingHandCursor)
        self.bgButton.setFixedWidth(self.font_metric.width("XXXXXXXXXX"))
        self.bgButton.setFixedHeight(self.font_metric.height() * 1.5)
        self.bgButton.clicked.connect(main_window.editBackgroundColor)

        self.colorbyBox = QComboBox(self)
        self.colorbyBox.addItem("material")
        self.colorbyBox.addItem("cell")
        self.colorbyBox.addItem("temperature")
        self.colorbyBox.addItem("density")
        self.colorbyBox.currentTextChanged[str].connect(
            main_window.editColorBy)

        self.universeLevelBox = QComboBox(self)
        self.universeLevelBox.addItem('all')
        for i in range(self.model.max_universe_levels):
            self.universeLevelBox.addItem(str(i))
        self.universeLevelBox.currentTextChanged[str].connect(
            main_window.editUniverseLevel)

        # Overlap plotting
        self.overlapCheck = QCheckBox('', self)
        overlap_connector = partial(main_window.toggleOverlaps)
        self.overlapCheck.stateChanged.connect(overlap_connector)

        self.overlapColorButton = QPushButton()
        self.overlapColorButton.setCursor(QtCore.Qt.PointingHandCursor)
        self.overlapColorButton.setFixedWidth(
            self.font_metric.width("XXXXXXXXXX"))
        self.overlapColorButton.setFixedHeight(self.font_metric.height() * 1.5)
        self.overlapColorButton.clicked.connect(main_window.editOverlapColor)

        self.colorResetButton = QPushButton("&Reset Colors")
        self.colorResetButton.setCursor(QtCore.Qt.PointingHandCursor)
        self.colorResetButton.clicked.connect(main_window.resetColors)

        formLayout = QFormLayout()
        formLayout.setAlignment(QtCore.Qt.AlignHCenter)
        formLayout.setFormAlignment(QtCore.Qt.AlignHCenter)
        formLayout.setLabelAlignment(QtCore.Qt.AlignLeft)

        formLayout.addRow('Masking:', self.maskingCheck)
        formLayout.addRow('Mask Color:', self.maskColorButton)
        formLayout.addRow(HorizontalLine())
        formLayout.addRow('Highlighting:', self.hlCheck)
        formLayout.addRow('Highlight Color:', self.hlColorButton)
        formLayout.addRow('Highlight Alpha:', self.alphaBox)
        formLayout.addRow('Highlight Seed:', self.seedBox)
        formLayout.addRow(HorizontalLine())
        formLayout.addRow('Background Color:          ', self.bgButton)
        formLayout.addRow(HorizontalLine())
        formLayout.addRow('Show Overlaps:', self.overlapCheck)
        formLayout.addRow('OVerlap Color:', self.overlapColorButton)
        formLayout.addRow(HorizontalLine())
        formLayout.addRow('Color Plot By:', self.colorbyBox)
        formLayout.addRow('Universe Level:', self.universeLevelBox)
        formLayout.addRow(self.colorResetButton, None)

        generalLayout = QHBoxLayout()
        innerWidget = QWidget()
        generalLayout.setAlignment(QtCore.Qt.AlignVCenter)
        innerWidget.setLayout(formLayout)
        generalLayout.addStretch(1)
        generalLayout.addWidget(innerWidget)
        generalLayout.addStretch(1)

        self.generalTab = QWidget()
        self.generalTab.setLayout(generalLayout)
示例#4
0
    def CreateSliceTabs(self):
        self.showslicecheckbox = QCheckBox()
        self.showslicecheckbox.setText("Show Slice")
        self.showslicecheckbox.clicked.connect(self.showSlice)

        self.sliceindexspinBox = QDoubleSpinBox()
        self.sliceindex = 0
        self.sliceindexspinBox.setValue(self.sliceindex)
        self.sliceindexspinBox.setDecimals(0)
        self.sliceindexspinBox.setSingleStep(1)
        self.sliceindexspinBox.setRange(0, 20)
        self.sliceindexspinBox.valueChanged.connect(self.onSliceIndexChanged)

        self.SliceLabelComboBox = QComboBox()
        self.SliceLabelComboBox.activated.connect(self.onSliceComboSelchange)
        self.sliceaxis = ["h", "k", "l"]
        self.SliceLabelComboBox.addItems(self.sliceaxis)
        self.SliceLabelComboBox.setDisabled(True)
        self.sliceindexspinBox.setDisabled(True)

        self.sliceTabWidget = QTabWidget()
        tab1 = QWidget()
        layout1 = QGridLayout()
        layout1.addWidget(self.showslicecheckbox, 0, 0, 1, 1)
        layout1.addWidget(self.SliceLabelComboBox, 0, 1, 1, 1)
        layout1.addWidget(self.sliceindexspinBox, 0, 2, 1, 1)
        tab1.setLayout(layout1)

        tab2 = QWidget()
        layout2 = QGridLayout()

        self.hvec_spinBox = QDoubleSpinBox(self.sliceTabWidget)
        self.hvecval = 2.0
        self.hvec_spinBox.setValue(self.hvecval)
        self.hvec_spinBox.setDecimals(2)
        self.hvec_spinBox.setSingleStep(0.5)
        self.hvec_spinBox.setRange(-100.0, 10.0)
        self.hvec_spinBox.valueChanged.connect(self.onHvecChanged)
        self.hvec_Label = QLabel()
        self.hvec_Label.setText("H")
        layout2.addWidget(self.hvec_Label, 0, 0, 1, 1)
        layout2.addWidget(self.hvec_spinBox, 0, 1, 1, 1)

        self.kvec_spinBox = QDoubleSpinBox(self.sliceTabWidget)
        self.kvecval = 0.0
        self.kvec_spinBox.setValue(self.kvecval)
        self.kvec_spinBox.setDecimals(2)
        self.kvec_spinBox.setSingleStep(0.5)
        self.kvec_spinBox.setRange(-100.0, 100.0)
        self.kvec_spinBox.valueChanged.connect(self.onKvecChanged)
        self.kvec_Label = QLabel()
        self.kvec_Label.setText("K")
        layout2.addWidget(self.kvec_Label, 1, 0, 1, 1)
        layout2.addWidget(self.kvec_spinBox, 1, 1, 1, 1)

        self.lvec_spinBox = QDoubleSpinBox(self.sliceTabWidget)
        self.lvecval = 0.0
        self.lvec_spinBox.setValue(self.lvecval)
        self.lvec_spinBox.setDecimals(2)
        self.lvec_spinBox.setSingleStep(0.5)
        self.lvec_spinBox.setRange(-100.0, 100.0)
        self.lvec_spinBox.valueChanged.connect(self.onLvecChanged)
        self.lvec_Label = QLabel()
        self.lvec_Label.setText("L")
        layout2.addWidget(self.lvec_Label, 2, 0, 1, 1)
        layout2.addWidget(self.lvec_spinBox, 2, 1, 1, 1)

        self.hkldist_spinBox = QDoubleSpinBox(self.sliceTabWidget)
        self.hkldistval = 0.0
        self.hkldist_spinBox.setValue(self.hkldistval)
        self.hkldist_spinBox.setDecimals(2)
        self.hkldist_spinBox.setSingleStep(0.5)
        self.hkldist_spinBox.setRange(-100.0, 100.0)
        self.hkldist_spinBox.valueChanged.connect(self.onHKLdistChanged)
        self.hkldist_Label = QLabel()
        self.hkldist_Label.setText("Distance from Origin")
        layout2.addWidget(self.hkldist_Label, 3, 0, 1, 1)
        layout2.addWidget(self.hkldist_spinBox, 3, 1, 1, 1)

        self.clipwidth_spinBox = QDoubleSpinBox(self.sliceTabWidget)
        self.clipwidthval = 0.5
        self.clipwidth_spinBox.setValue(self.clipwidthval)
        self.clipwidth_spinBox.setDecimals(2)
        self.clipwidth_spinBox.setSingleStep(0.05)
        self.clipwidth_spinBox.setRange(0.0, 100.0)
        self.clipwidth_spinBox.valueChanged.connect(self.onClipwidthChanged)
        self.clipwidth_Label = QLabel()
        self.clipwidth_Label.setText("Clip Plane Width")
        layout2.addWidget(self.clipwidth_Label, 4, 0, 1, 1)
        layout2.addWidget(self.clipwidth_spinBox, 4, 1, 1, 1)

        self.ClipBox = QGroupBox("Normal Vector to Clip Plane")
        self.ClipBox.setLayout(layout2)

        layout3 = QGridLayout()
        self.ClipPlaneChkBox = QCheckBox(self.sliceTabWidget)
        self.ClipPlaneChkBox.setText(
            "Use clip plane normal to HKL vector pointing out")
        self.ClipPlaneChkBox.clicked.connect(self.onClipPlaneChkBox)

        layout3.addWidget(self.ClipPlaneChkBox, 0, 0)
        layout3.addWidget(self.ClipBox, 1, 0)
        tab2.setLayout(layout3)
        self.sliceTabWidget.addTab(tab1, "Explicit Slicing")
        self.sliceTabWidget.addTab(tab2, "Clip Plane Slicing")
        self.ClipBox.setDisabled(True)
示例#5
0
文件: plots.py 项目: Vidocapt/sherloq
    def __init__(self, image, parent=None):
        super(PlotsWidget, self).__init__(parent)

        choices = ['Red', 'Green', 'Blue', 'Hue', 'Saturation', 'Value']
        self.xaxis_combo = QComboBox()
        self.xaxis_combo.addItems(choices)
        self.xaxis_combo.setCurrentIndex(3)
        self.yaxis_combo = QComboBox()
        self.yaxis_combo.addItems(choices)
        self.yaxis_combo.setCurrentIndex(4)
        self.sampling_spin = QSpinBox()
        levels = int(np.log2(min(image.shape[:-1])))
        self.sampling_spin.setRange(0, levels)
        self.sampling_spin.setSpecialValueText(self.tr('Off'))
        self.sampling_spin.setValue(1)
        self.sampling_spin.setSuffix(self.tr(' level(s)'))
        self.size_spin = QSpinBox()
        self.size_spin.setRange(1, 10)
        self.size_spin.setValue(2)
        self.size_spin.setSuffix(self.tr(' pt'))
        self.style_combo = QComboBox()
        self.markers = [
            ',', '.', 'o', '8', 's', 'p', 'P', '*', 'h', 'H', 'X', 'D'
        ]
        self.style_combo.addItems([
            'pixel', 'point', 'circle', 'octa', 'square', 'penta', 'plus',
            'star', 'hexa1', 'hexa2', 'cross', 'diamond'
        ])
        self.alpha_spin = QDoubleSpinBox()
        self.alpha_spin.setRange(0, 1)
        self.alpha_spin.setDecimals(2)
        self.alpha_spin.setSingleStep(0.05)
        self.alpha_spin.setValue(1)
        self.colors_check = QCheckBox(self.tr('Show colors'))
        self.grid_check = QCheckBox(self.tr('Show grid'))
        self.norm_check = QCheckBox(self.tr('Normalized'))
        self.total_label = QLabel()

        img = np.copy(image)
        self.colors = [None] * (levels + 1)
        for scale in range(levels + 1):
            rgb = cv.cvtColor(img.astype(np.float32) / 255, cv.COLOR_BGR2RGB)
            hsv = cv.cvtColor(rgb, cv.COLOR_RGB2HSV)
            hsv[:, :, 0] /= 360
            shape = (img.shape[0] * img.shape[1], img.shape[2])
            self.colors[scale] = np.concatenate(
                (np.reshape(rgb, shape), np.reshape(hsv, shape)), axis=1)
            img = cv.pyrDown(img)
        figure = Figure()
        plot_canvas = FigureCanvas(figure)
        self.axes = plot_canvas.figure.subplots()
        self.redraw()
        figure.set_tight_layout(True)

        self.xaxis_combo.currentIndexChanged.connect(self.redraw)
        self.yaxis_combo.currentIndexChanged.connect(self.redraw)
        self.sampling_spin.valueChanged.connect(self.redraw)
        self.size_spin.valueChanged.connect(self.redraw)
        self.style_combo.currentIndexChanged.connect(self.redraw)
        self.alpha_spin.valueChanged.connect(self.redraw)
        self.colors_check.stateChanged.connect(self.redraw)
        self.grid_check.stateChanged.connect(self.redraw)
        self.norm_check.stateChanged.connect(self.redraw)

        bottom_layout = QGridLayout()
        bottom_layout.addWidget(NavigationToolbar(plot_canvas, self), 0, 0, 1,
                                5)
        bottom_layout.addWidget(QLabel(self.tr('X axis:')), 1, 0)
        bottom_layout.addWidget(self.xaxis_combo, 1, 1)
        bottom_layout.addWidget(QLabel(self.tr('Y Axis:')), 2, 0)
        bottom_layout.addWidget(self.yaxis_combo, 2, 1)
        bottom_layout.addWidget(QLabel(self.tr('Subsampling:')), 3, 0)
        bottom_layout.addWidget(self.sampling_spin, 3, 1)
        bottom_layout.addWidget(QLabel(self.tr('Point size:')), 1, 2)
        bottom_layout.addWidget(self.size_spin, 1, 3)
        bottom_layout.addWidget(QLabel(self.tr('Point style:')), 2, 2)
        bottom_layout.addWidget(self.style_combo, 2, 3)
        bottom_layout.addWidget(QLabel(self.tr('Point alpha:')), 3, 2)
        bottom_layout.addWidget(self.alpha_spin, 3, 3)
        bottom_layout.addWidget(self.colors_check, 1, 4)
        bottom_layout.addWidget(self.grid_check, 2, 4)
        bottom_layout.addWidget(self.total_label, 3, 4)

        main_layout = QVBoxLayout()
        main_layout.addWidget(plot_canvas)
        main_layout.addLayout(bottom_layout)
        self.setLayout(main_layout)
示例#6
0
    def __init__(self):
        super(WidgetConfig, self).__init__()

        HEIGHT = 40

        grid = QGridLayout()

        # 使用默认摄像头复选框
        self.check_camera = QCheckBox('Use default camera')
        self.check_camera.setChecked(False)
        self.check_camera.stateChanged.connect(self.slot_check_camera)

        grid.addWidget(self.check_camera, 0, 0, 1, 3)  # 一行三列
        

        # 选择视频文件
        label_video = QLabel('Detect File')
        self.line_video = QLineEdit()
        if 'video' in GLOBAL.config:
            self.line_video.setText(GLOBAL.config['video'])
        self.line_video.setFixedHeight(HEIGHT)
        self.line_video.setEnabled(False)
        self.line_video.editingFinished.connect(lambda: GLOBAL.record_config(
            {'video': self.line_video.text()}
        ))

        self.btn_video = QPushButton('Choose')
        self.btn_video.setFixedHeight(HEIGHT)
        self.btn_video.setEnabled(False)
        self.btn_video.clicked.connect(self.choose_video_file)

        self.slot_check_camera()

        grid.addWidget(label_video, 1, 0)
        grid.addWidget(self.line_video, 1, 1)
        grid.addWidget(self.btn_video, 1, 2)

        # 选择权重文件
        label_weights = QLabel('Weights File')
        self.line_weights = QLineEdit()
        if 'weights' in GLOBAL.config:
            self.line_weights.setText(GLOBAL.config['weights'])
        self.line_weights.setFixedHeight(HEIGHT)
        self.line_weights.editingFinished.connect(lambda: GLOBAL.record_config(
            {'weights': self.line_weights.text()}
        ))

        self.btn_weights = QPushButton('Choose')
        self.btn_weights.setFixedHeight(HEIGHT)
        self.btn_weights.clicked.connect(self.choose_weights_file)

        grid.addWidget(label_weights, 2, 0)
        grid.addWidget(self.line_weights, 2, 1)
        grid.addWidget(self.btn_weights, 2, 2)

        # 是否使用GPU
        label_device = QLabel('CUDA device')
        self.line_device = QLineEdit('gpu')
        if 'device' in GLOBAL.config:
            self.line_device.setText(GLOBAL.config['device'])
        else:
            self.line_device.setText('cpu')
        self.line_device.setPlaceholderText('cpu or 0 or 0,1,2,3')
        self.line_device.setFixedHeight(HEIGHT)
        self.line_device.editingFinished.connect(lambda: GLOBAL.record_config(
            {'device': self.line_device.text()}
        ))

        grid.addWidget(label_device, 3, 0)
        grid.addWidget(self.line_device, 3, 1, 1, 2)

        # 设置图像大小
        label_size = QLabel('Img Size')
        self.combo_size = QComboBox()
        self.combo_size.setFixedHeight(HEIGHT)
        self.combo_size.setStyleSheet(
            'QAbstractItemView::item {height: 40px;}')
        self.combo_size.setView(QListView())
        self.combo_size.addItem('320', 320)
        self.combo_size.addItem('416', 416)
        self.combo_size.addItem('480', 480)
        self.combo_size.addItem('544', 544)
        self.combo_size.addItem('640', 640)
        self.combo_size.setCurrentIndex(2)
        self.combo_size.currentIndexChanged.connect(lambda: GLOBAL.record_config(
            {'img_size': self.combo_size.currentData()}
        ))

        grid.addWidget(label_size, 4, 0)
        grid.addWidget(self.combo_size, 4, 1, 1, 2)

        #choose net camera
        label_stream = QLabel('NetVedioStream')
        self.combo_stream = QComboBox()
        self.combo_stream.setFixedHeight(HEIGHT)
        self.combo_stream.setStyleSheet(
            'QAbstractItemView::item {height: 40px;}')
        self.combo_stream.setView(QListView())
        self.combo_stream.addItem('rtsp://*****:*****@192.168.0.65/', 'rtsp://*****:*****@192.168.0.65/')
        self.combo_stream.addItem('rtsp://*****:*****@192.168.0.66/', 'rtsp://*****:*****@192.168.0.66/')
        self.combo_stream.addItem('rtsp://*****:*****@192.168.0.67/', 'rtsp://*****:*****@192.168.0.67/')
        self.combo_stream.addItem('rtsp://*****:*****@192.168.0.68/', 'rtsp://*****:*****@192.168.0.68/')
        self.combo_stream.addItem('rtsp://*****:*****@192.168.0.65/', 'rtsp://*****:*****@192.168.0.65/')
        self.combo_stream.setCurrentIndex(0)
        self.combo_stream.currentIndexChanged.connect(lambda: GLOBAL.record_config(
            {'netstreamvedio': self.combo_stream.currentData()}
        ))

        grid.addWidget(label_stream, 5, 0)
        grid.addWidget(self.combo_stream, 5, 1, 1, 2)

        # 设置置信度阈值
        label_conf = QLabel('Confidence')
        self.spin_conf = QDoubleSpinBox()
        self.spin_conf.setFixedHeight(HEIGHT)
        self.spin_conf.setDecimals(1)
        self.spin_conf.setRange(0.1, 0.9)
        self.spin_conf.setSingleStep(0.1)
        if 'conf_thresh' in GLOBAL.config:
            self.spin_conf.setValue(GLOBAL.config['conf_thresh'])
        else:
            self.spin_conf.setValue(0.4)  # 默认值
            GLOBAL.record_config({'conf_thresh': 0.4})
        self.spin_conf.valueChanged.connect(lambda: GLOBAL.record_config(
            {'conf_thresh': round(self.spin_conf.value(), 1)}
        ))

        grid.addWidget(label_conf, 6, 0)
        grid.addWidget(self.spin_conf, 6, 1, 1, 2)

        # 设置IOU阈值
        label_iou = QLabel('IOU')
        self.spin_iou = QDoubleSpinBox()
        self.spin_iou.setFixedHeight(HEIGHT)
        self.spin_iou.setDecimals(1)
        self.spin_iou.setRange(0.1, 0.9)
        self.spin_iou.setSingleStep(0.1)
        if 'iou_thresh' in GLOBAL.config:
            self.spin_iou.setValue(GLOBAL.config['iou_thresh'])
        else:
            self.spin_iou.setValue(0.5)  # 默认值
            GLOBAL.record_config({'iou_thresh': 0.5})
        self.spin_iou.valueChanged.connect(lambda: GLOBAL.record_config(
            {'iou_thresh': round(self.spin_iou.value(), 1)}
        ))

        grid.addWidget(label_iou, 7, 0)
        grid.addWidget(self.spin_iou, 7, 1, 1, 2)

        # class-agnostic NMS
        self.check_agnostic = QCheckBox('Agnostic')
        if 'agnostic' in GLOBAL.config:
            self.check_agnostic.setChecked(GLOBAL.config['agnostic'])
        else:
            self.check_agnostic.setChecked(True)
        self.check_agnostic.stateChanged.connect(lambda: GLOBAL.record_config(
            {'agnostic': self.check_agnostic.isChecked()}
        ))

        grid.addWidget(self.check_agnostic, 8, 0, 1, 3)  # 一行三列

        # augmented inference
        self.check_augment = QCheckBox('Augment')
        if 'augment' in GLOBAL.config:
            self.check_augment.setChecked(GLOBAL.config['augment'])
        else:
            self.check_augment.setChecked(True)
        self.check_augment.stateChanged.connect(lambda: GLOBAL.record_config(
            {'augment': self.check_augment.isChecked()}
        ))

        grid.addWidget(self.check_augment, 9, 0, 1, 3)  # 一行三列

        self.setLayout(grid)  # 设置布局
示例#7
0
# equationlabel.move(0, 105)

equationinput = QPlainTextEdit(window)
# equationinput.setGeometry(170, 100, 400, 30)

# equationbutton = QPushButton("Set Equation",window)
# equationbutton.setGeometry(575,100,100,30)

#### Minimum #########
minlabel = QLabel(window)
minlabel.setText("Enter Minimum Value for x:")
# minlabel.move(0, 205)

# mininput = QPlainTextEdit(window)
# mininput.setGeometry(170,200,400,30)
mininput = QDoubleSpinBox(window)
# mininput.setGeometry(170, 200, 60, 30)

# minbutton = QPushButton("Set Minimum",window)
# minbutton.setGeometry(575,200,100,30)

######### Maximum ###########
maxlabel = QLabel(window)
maxlabel.setText("Enter Maximum Value for x:")
# maxlabel.move(0, 305)

# maxinput = QPlainTextEdit(window)
# maxinput.setGeometry(170,300,400,30)
maxinput = QDoubleSpinBox(window)
# maxinput.setGeometry(170, 300, 60, 30)
示例#8
0
    def _createOptionsBox(self):

        # Width
        self.widthBox = QDoubleSpinBox(self)
        self.widthBox.setRange(.1, 99999)
        self.widthBox.setDecimals(9)
        self.widthBox.valueChanged.connect(self.main_window.editWidth)

        # Height
        self.heightBox = QDoubleSpinBox(self)
        self.heightBox.setRange(.1, 99999)
        self.heightBox.setDecimals(9)
        self.heightBox.valueChanged.connect(self.main_window.editHeight)

        # ColorBy
        self.colorbyBox = QComboBox(self)
        self.colorbyBox.addItem("material")
        self.colorbyBox.addItem("cell")
        self.colorbyBox.addItem("temperature")
        self.colorbyBox.addItem("density")
        self.colorbyBox.currentTextChanged[str].connect(
            self.main_window.editColorBy)

        # Universe level (applies to cell coloring only)
        self.universeLevelBox = QComboBox(self)
        self.universeLevelBox.addItem('all')
        for i in range(self.model.max_universe_levels):
            self.universeLevelBox.addItem(str(i))
        self.universeLevelBox.currentTextChanged[str].connect(
            self.main_window.editUniverseLevel)

        # Alpha
        self.domainAlphaBox = QDoubleSpinBox(self)
        self.domainAlphaBox.setValue(self.model.activeView.domainAlpha)
        self.domainAlphaBox.setSingleStep(0.05)
        self.domainAlphaBox.setDecimals(2)
        self.domainAlphaBox.setRange(0.0, 1.0)
        self.domainAlphaBox.valueChanged.connect(self.main_window.editPlotAlpha)

        # Visibility
        self.visibilityBox = QCheckBox(self)
        self.visibilityBox.stateChanged.connect(
            self.main_window.editPlotVisibility)

        # Outlines
        self.outlinesBox = QCheckBox(self)
        self.outlinesBox.stateChanged.connect(self.main_window.toggleOutlines)

        # Basis
        self.basisBox = QComboBox(self)
        self.basisBox.addItem("xy")
        self.basisBox.addItem("xz")
        self.basisBox.addItem("yz")
        self.basisBox.currentTextChanged.connect(self.main_window.editBasis)

        # Advanced Color Options
        self.colorOptionsButton = QPushButton('Color Options...')
        self.colorOptionsButton.setMinimumHeight(self.font_metric.height() * 1.6)
        self.colorOptionsButton.clicked.connect(self.main_window.showColorDialog)

        # Options Form Layout
        self.opLayout = QFormLayout()
        self.opLayout.addRow('Width:', self.widthBox)
        self.opLayout.addRow('Height:', self.heightBox)
        self.opLayout.addRow('Basis:', self.basisBox)
        self.opLayout.addRow('Color By:', self.colorbyBox)
        self.opLayout.addRow('Universe Level:', self.universeLevelBox)
        self.opLayout.addRow('Plot alpha:', self.domainAlphaBox)
        self.opLayout.addRow('Visible:', self.visibilityBox)
        self.opLayout.addRow('Outlines:', self.outlinesBox)
        self.opLayout.addRow(self.colorOptionsButton)
        self.opLayout.setLabelAlignment(QtCore.Qt.AlignLeft)
        self.opLayout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)

        # Options Group Box
        self.optionsGroupBox = QGroupBox('Options')
        self.optionsGroupBox.setLayout(self.opLayout)
示例#9
0
    def __init__(self, model, main_window, field, colormaps=None):
        super().__init__()

        self.model = model
        self.main_window = main_window
        self.field = field

        self.layout = QFormLayout()

        # Visibility check box
        self.visibilityBox = QCheckBox()
        visible_connector = partial(main_window.toggleTallyVisibility)
        self.visibilityBox.stateChanged.connect(visible_connector)

        # Alpha value
        self.alphaBox = QDoubleSpinBox()
        self.alphaBox.setDecimals(2)
        self.alphaBox.setRange(0, 1)
        self.alphaBox.setSingleStep(0.05)
        alpha_connector = partial(main_window.editTallyAlpha)
        self.alphaBox.valueChanged.connect(alpha_connector)

        # Color map selector
        self.colormapBox = QComboBox()
        if colormaps is None:
            colormaps = sorted(m for m in mcolormaps.datad if not m.endswith("_r"))
        for colormap in colormaps:
            self.colormapBox.addItem(colormap)
        cmap_connector = partial(main_window.editTallyDataColormap)
        self.colormapBox.currentTextChanged[str].connect(cmap_connector)

        # Data indicator line check box
        self.dataIndicatorCheckBox = QCheckBox()
        data_indicator_connector = partial(main_window.toggleTallyDataIndicator)
        self.dataIndicatorCheckBox.stateChanged.connect(data_indicator_connector)

        # User specified min/max check box
        self.userMinMaxBox = QCheckBox()
        minmax_connector = partial(main_window.toggleTallyDataUserMinMax)
        self.userMinMaxBox.stateChanged.connect(minmax_connector)

        # Data min spin box
        self.minBox = ScientificDoubleSpinBox()
        self.minBox.setMinimum(0.0)
        min_connector = partial(main_window.editTallyDataMin)
        self.minBox.valueChanged.connect(min_connector)

        # Data max spin box
        self.maxBox = ScientificDoubleSpinBox()
        self.maxBox.setMinimum(0.0)
        max_connector = partial(main_window.editTallyDataMax)
        self.maxBox.valueChanged.connect(max_connector)

        # Linear/Log scaling check box
        self.scaleBox = QCheckBox()
        scale_connector = partial(main_window.toggleTallyLogScale)
        self.scaleBox.stateChanged.connect(scale_connector)

        # Masking of zero values check box
        self.maskZeroBox = QCheckBox()
        zero_connector = partial(main_window.toggleTallyMaskZero)
        self.maskZeroBox.stateChanged.connect(zero_connector)

        # Clip data to min/max check box
        self.clipDataBox = QCheckBox()
        clip_connector = partial(main_window.toggleTallyDataClip)
        self.clipDataBox.stateChanged.connect(clip_connector)

        # Display data as contour plot check box
        self.contoursBox = QCheckBox()
        self.contoursBox.stateChanged.connect(main_window.toggleTallyContours)
        self.contourLevelsLine = QLineEdit()
        self.contourLevelsLine.textChanged.connect(
            main_window.editTallyContourLevels)

        # Organize widgets on layout
        self.layout.addRow("Visible:", self.visibilityBox)
        self.layout.addRow("Alpha: ", self.alphaBox)
        self.layout.addRow("Colormap: ", self.colormapBox)
        self.layout.addRow("Data Indicator: ", self.dataIndicatorCheckBox)
        self.layout.addRow("Custom Min/Max: ", self.userMinMaxBox)
        self.layout.addRow("Min: ", self.minBox)
        self.layout.addRow("Max: ", self.maxBox)
        self.layout.addRow("Log Scale: ", self.scaleBox)
        self.layout.addRow("Clip Data: ", self.clipDataBox)
        self.layout.addRow("Mask Zeros: ", self.maskZeroBox)
        self.layout.addRow("Contours: ", self.contoursBox)
        self.layout.addRow("Contour Levels:", self.contourLevelsLine)
        self.setLayout(self.layout)
示例#10
0
    def __init__(self, minval, maxval, stepsize=.1, parent=None):
        super(DoubleEditor, self).__init__(parent)

        # Edit field
        self.maxval = maxval
        self.minval = minval
        # print("self.maxval: ", self.maxval)

        self.edit = QDoubleSpinBox(self)
        self.edit.setKeyboardTracking(False)
        self.edit.setRange(self.minval, self.maxval)
        self.edit.setSingleStep(stepsize)
        self.edit.setMinimumWidth(70)

        if stepsize < 1.:
            decimals = int(np.ceil(-np.log10(stepsize)))
        else:
            decimals = 1
        self.edit.setDecimals(decimals)

        # Slider
        self.slider = DoubleSlider(min_val=self.minval, max_val=self.maxval, stepsize=stepsize,
                                   orientation=Qt.Vertical, parent=self)
        self.slider.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)

        # Ticks
        self.q_ticks = QSlider.TicksBelow
        self.slider.setTickPosition(self.q_ticks)

        self.tick_amount = 6

        self.slider_range = self.slider.maximum() - self.slider.minimum()
        self.tick_interval = int(round(self.slider_range / (self.tick_amount-1)))
        self.slider.setTickInterval(self.tick_interval)

        # ...labels
        font = QFont()
        font.setPointSize(8)

        self.tick_str1 = QLabel('{:.0f}'.format(self.minval), self)
        self.tick_str2 = QLabel('{:.0f}'.format(self.maxval), self)
        self.tick_str1.setFont(font)
        self.tick_str2.setFont(font)

        self.slider_tick_layout = QGridLayout()
        self.tick_str1.setAlignment(Qt.AlignBottom | Qt.AlignLeft)
        self.tick_str2.setAlignment(Qt.AlignTop | Qt.AlignLeft)
        self.slider_tick_layout.addWidget(self.slider, 0, 0, self.tick_amount, 1)
        self.slider_tick_layout.addWidget(self.tick_str2, 0, 1, 1, 1)
        self.slider_tick_layout.addWidget(self.tick_str1, self.tick_amount - 1, 1, 1, 1)

        # Layout
        self.layout = QVBoxLayout()
        self.layout.addLayout(self.slider_tick_layout)
        self.layout.addWidget(self.edit)
        self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Expanding)
        self.setLayout(self.layout)

        # Signals and slots
        self.edit.valueChanged.connect(self.slider.setValue)
        self.slider.doubleValueChanged.connect(self.edit.setValue)
示例#11
0
    def __init__(self, conn):
        '''
        Parameters:
            conn : connection
                Connection to the database.
        '''
        super().__init__()
        self.setWindowTitle('Aggiungi Prenotazione')
        self.setWindowFlag(QtCore.Qt.WindowContextHelpButtonHint, False)

        self.conn = conn
        self.cursor = conn.cursor()

        self.books = dict()
        self.books_qt = dict()

        self.gen_layout = QVBoxLayout()

        self.form_layout = QFormLayout()
        self.form_layout.setRowWrapPolicy(QFormLayout.WrapLongRows)

        # Widgets
        self.client_field = QLineEdit()
        self.form_layout.addRow('Numero Cliente: ', self.client_field)

        self.dip_field = QLineEdit()
        self.form_layout.addRow('Dipendente (CF): ', self.dip_field)

        self.date_picker = QDateEdit(QDate.currentDate())
        self.date_picker.setDisplayFormat("MM/dd/yyyy")
        self.date_picker.setCalendarPopup(True)
        self.form_layout.addRow('Data (mm/gg/aaaa): ', self.date_picker)

        self.importo_field = QDoubleSpinBox()
        self.importo_field.setMaximum(999999999.99)
        self.form_layout.addRow('Importo: ', self.importo_field)

        self.ins_layout = QHBoxLayout()
        self.libro_field = QLineEdit()
        self.quantita_field = QSpinBox()
        self.quantita_field.setMinimum(1)
        self.libro_button = QPushButton('Aggiungi')
        self.libro_button.clicked.connect(self.aggiungi_libro)
        self.ins_layout.addWidget(QLabel('Libro (ISBN): '))
        self.ins_layout.addWidget(self.libro_field)
        self.ins_layout.addWidget(QLabel('Quantità: '))
        self.ins_layout.addWidget(self.quantita_field)
        self.ins_layout.addWidget(self.libro_button)

        self.labels = ['ISBN', 'Quantità', '']
        self.table = QTableWidget(0, 3)
        self.table.setHorizontalHeaderLabels(self.labels)
        self.table.horizontalHeader().setSectionResizeMode(
            0, QHeaderView.Stretch)
        self.table.horizontalHeader().setSectionResizeMode(
            1, QHeaderView.Stretch)
        self.table.horizontalHeader().setSectionResizeMode(
            2, QHeaderView.ResizeToContents)

        self.info_label = QLabel(
            'Le prenotazioni non riducono i libri disponibili.')
        self.confirm_button = QPushButton('Conferma')
        self.confirm_button.clicked.connect(self.post_prenotazione)

        self.gen_layout.addLayout(self.form_layout)
        self.gen_layout.addLayout(self.ins_layout)
        self.gen_layout.addWidget(self.table)
        self.gen_layout.addWidget(self.info_label)
        self.gen_layout.addWidget(self.confirm_button)
        self.setLayout(self.gen_layout)
示例#12
0
    def init_ui(self, name: str):
        self.main_layout = QGridLayout(self)
        self.main_layout.setContentsMargins(0, 0, 0, 0)

        self.name_label = QLabel(name)
        self.name_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.name_label.setSizePolicy(QSizePolicy.Fixed,
                                      QSizePolicy.MinimumExpanding)
        self.main_layout.addWidget(self.name_label, 1, 0, 4, 1)
        # shape
        self.shape_label = QLabel(self.tr("Shape"))
        self.shape_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.shape_mean_input = QDoubleSpinBox()
        self.shape_mean_input.setRange(*self.SHAPE_MEAN_RANGE)
        self.shape_mean_input.setSingleStep(self.SHAPE_MEAN_STEP)
        self.shape_mean_input.setValue(self.SHAPE_MEAN_DEFAULT)
        self.shape_std_input = QDoubleSpinBox()
        self.shape_std_input.setRange(*self.SHAPE_STD_RANGE)
        self.shape_std_input.setSingleStep(self.SHAPE_STD_STEP)
        self.shape_std_input.setValue(self.SHAPE_STD_DEFAULT)
        self.main_layout.addWidget(self.shape_label, 1, 1)
        self.main_layout.addWidget(self.shape_mean_input, 1, 2)
        self.main_layout.addWidget(self.shape_std_input, 1, 3)
        # location
        self.loc_label = QLabel(self.tr("Location"))
        self.loc_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.loc_mean_input = QDoubleSpinBox()
        self.loc_mean_input.setRange(*self.LOC_MEAN_RANGE)
        self.loc_mean_input.setSingleStep(self.LOC_MEAN_STEP)
        self.loc_mean_input.setValue(self.LOC_MEAN_DEFAULT)
        self.loc_std_input = QDoubleSpinBox()
        self.loc_std_input.setRange(*self.LOC_STD_RANGE)
        self.loc_std_input.setSingleStep(self.LOC_STD_STEP)
        self.loc_std_input.setValue(self.LOC_STD_DEFAULT)
        self.main_layout.addWidget(self.loc_label, 2, 1)
        self.main_layout.addWidget(self.loc_mean_input, 2, 2)
        self.main_layout.addWidget(self.loc_std_input, 2, 3)
        # scale
        self.scale_label = QLabel(self.tr("Scale"))
        self.scale_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.scale_mean_input = QDoubleSpinBox()
        self.scale_mean_input.setRange(*self.SCALE_MEAN_RANGE)
        self.scale_mean_input.setSingleStep(self.SCALE_MEAN_STEP)
        self.scale_mean_input.setValue(self.SCALE_MEAN_DEFAULT)
        self.scale_std_input = QDoubleSpinBox()
        self.scale_std_input.setRange(*self.SCALE_STD_RANGE)
        self.scale_std_input.setSingleStep(self.SCALE_STD_STEP)
        self.scale_std_input.setValue(self.SCALE_STD_DEFAULT)
        self.main_layout.addWidget(self.scale_label, 3, 1)
        self.main_layout.addWidget(self.scale_mean_input, 3, 2)
        self.main_layout.addWidget(self.scale_std_input, 3, 3)
        # weight
        self.weight_label = QLabel(self.tr("Weight"))
        self.weight_label.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
        self.weight_mean_input = QDoubleSpinBox()
        self.weight_mean_input.setRange(*self.WEIGHT_MEAN_RANGE)
        self.weight_mean_input.setSingleStep(self.WEIGHT_MEAN_STEP)
        self.weight_mean_input.setValue(self.WEIGHT_MEAN_DEFAULT)
        self.weight_std_input = QDoubleSpinBox()
        self.weight_std_input.setRange(*self.WEIGHT_STD_RANGE)
        self.weight_std_input.setSingleStep(self.WEIGHT_STD_STEP)
        self.weight_std_input.setValue(self.WEIGHT_STD_DEFAULT)
        self.main_layout.addWidget(self.weight_label, 4, 1)
        self.main_layout.addWidget(self.weight_mean_input, 4, 2)
        self.main_layout.addWidget(self.weight_std_input, 4, 3)

        self.shape_mean_input.valueChanged.connect(self.on_value_changed)
        self.shape_std_input.valueChanged.connect(self.on_value_changed)
        self.loc_mean_input.valueChanged.connect(self.on_value_changed)
        self.loc_std_input.valueChanged.connect(self.on_value_changed)
        self.scale_mean_input.valueChanged.connect(self.on_value_changed)
        self.scale_std_input.valueChanged.connect(self.on_value_changed)
        self.weight_mean_input.valueChanged.connect(self.on_value_changed)
        self.weight_std_input.valueChanged.connect(self.on_value_changed)
示例#13
0
    def init_ui(self):
        self.setAttribute(Qt.WA_StyledBackground, True)
        self.main_layout = QGridLayout(self)
        # self.main_layout.setContentsMargins(0, 0, 0, 0)

        self.sampling_group = QGroupBox(self.tr("Sampling"))
        # self.control_group.setFixedSize(400, 160)
        self.control_layout = QGridLayout(self.sampling_group)
        self.minimum_size_label = QLabel(self.tr("Minimum Size [μm]"))
        self.minimum_size_input = QDoubleSpinBox()
        self.minimum_size_input.setDecimals(2)
        self.minimum_size_input.setRange(1e-4, 1e6)
        self.minimum_size_input.setValue(0.0200)
        self.maximum_size_label = QLabel(self.tr("Maximum Size [μm]"))
        self.maximum_size_input = QDoubleSpinBox()
        self.maximum_size_input.setDecimals(2)
        self.maximum_size_input.setRange(1e-4, 1e6)
        self.maximum_size_input.setValue(2000.0000)
        self.control_layout.addWidget(self.minimum_size_label, 0, 0)
        self.control_layout.addWidget(self.minimum_size_input, 0, 1)
        self.control_layout.addWidget(self.maximum_size_label, 0, 2)
        self.control_layout.addWidget(self.maximum_size_input, 0, 3)
        self.n_classes_label = QLabel(self.tr("N<sub>classes</sub>"))
        self.n_classes_input = QSpinBox()
        self.n_classes_input.setRange(10, 1e4)
        self.n_classes_input.setValue(101)
        self.precision_label = QLabel(self.tr("Data Precision"))
        self.precision_input = QSpinBox()
        self.precision_input.setRange(2, 8)
        self.precision_input.setValue(4)
        self.control_layout.addWidget(self.n_classes_label, 1, 0)
        self.control_layout.addWidget(self.n_classes_input, 1, 1)
        self.control_layout.addWidget(self.precision_label, 1, 2)
        self.control_layout.addWidget(self.precision_input, 1, 3)
        self.component_number_label = QLabel(self.tr("N<sub>components</sub>"))
        self.component_number_input = QSpinBox()
        self.component_number_input.setRange(1, 10)
        self.component_number_input.valueChanged.connect(
            self.on_n_components_changed)
        self.preview_button = QPushButton(qta.icon("mdi.animation-play"),
                                          self.tr("Preview"))
        self.preview_button.clicked.connect(self.on_preview_clicked)
        self.control_layout.addWidget(self.component_number_label, 2, 0)
        self.control_layout.addWidget(self.component_number_input, 2, 1)
        self.control_layout.addWidget(self.preview_button, 2, 2, 1, 2)
        self.main_layout.addWidget(self.sampling_group, 0, 0)

        self.save_group = QGroupBox(self.tr("Save"))
        # self.save_group.setFixedHeight(160)
        self.save_layout = QGridLayout(self.save_group)
        self.n_samples_label = QLabel(self.tr("N<sub>samples</sub>"))
        self.n_samples_input = QSpinBox()
        self.n_samples_input.setRange(100, 100000)
        self.save_layout.addWidget(self.n_samples_label, 0, 0)
        self.save_layout.addWidget(self.n_samples_input, 0, 1)

        self.cancel_button = QPushButton(qta.icon("mdi.cancel"),
                                         self.tr("Cancel"))
        self.cancel_button.setEnabled(False)
        self.cancel_button.clicked.connect(self.on_cancel_clicked)
        self.generate_button = QPushButton(qta.icon("mdi.cube-send"),
                                           self.tr("Generate"))
        self.generate_button.clicked.connect(self.on_generate_clicked)
        self.progress_bar = QProgressBar()
        self.progress_bar.setRange(0, 100)
        self.progress_bar.setOrientation(Qt.Horizontal)
        self.progress_bar.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
        self.save_layout.addWidget(self.cancel_button, 1, 0)
        self.save_layout.addWidget(self.generate_button, 1, 1)
        self.save_layout.addWidget(self.progress_bar, 2, 0, 1, 2)
        self.main_layout.addWidget(self.save_group, 0, 1)

        self.param_group = QGroupBox("Random Parameter")
        # self.param_group.setFixedWidth(400)
        self.param_layout = QGridLayout(self.param_group)
        self.main_layout.addWidget(self.param_group, 1, 0)

        self.preview_group = QGroupBox(self.tr("Preview"))
        self.chart_layout = QGridLayout(self.preview_group)

        self.chart = MixedDistributionChart(parent=self, toolbar=False)
        self.chart_layout.addWidget(self.chart, 0, 0)
        self.chart.setSizePolicy(QSizePolicy.MinimumExpanding,
                                 QSizePolicy.MinimumExpanding)
        self.main_layout.addWidget(self.preview_group, 1, 1)
示例#14
0
    def init_ui(self):
        # Define & Configure Components
        normal_button_size = QSize(80, 24)
        icon_button_size = QSize(24, 24)
        icon_size = QSize(18, 18)
        
        self.central_widget = QWidget()
        self.central_layout = QGridLayout()
        self.central_widget.setLayout(self.central_layout)

        self.tab_group_widget = QTabWidget()
        self.tab_group_widget.setMinimumSize(400, 0)
        self.tab_group_widget.setFixedHeight(150)
        self.tab1_name = '스폰서 변환'
        self.tab2_name = '싱크 조절(초)'
        self.tab3_name = '싱크 조절(%)'

        self.tab_page_1 = QWidget()
        self.tab_grid_1 = QGridLayout()
        self.tab1_search_label = QLabel('검색 텍스트')
        self.tab1_search = QLineEdit()
        self.tab1_sponsor = QWidget()
        self.tab1_sponsor_layout = QHBoxLayout()
        self.tab1_sponsor_layout.setContentsMargins(0, 0, 0, 0)
        self.tab1_sponsor_label = QLabel('스폰서 영상 길이')
        self.tab1_sponsor_value = QDoubleSpinBox()
        self.tab1_sponsor_value.setFixedWidth(60)
        self.tab1_sponsor_value.setMinimum(-1000000000)
        self.tab1_sponsor_value.setValue(10)
        self.tab1_offset = QWidget()
        self.tab1_offset_layout = QHBoxLayout()
        self.tab1_offset_layout.setContentsMargins(0, 0, 0, 0)
        self.tab1_offset_label = QLabel('라인 오프셋')
        self.tab1_offset_value = QSpinBox()
        self.tab1_offset_value.setMinimum(-1000000000)
        self.tab1_offset_value.setValue(2)
        self.tab1_offset_value.setFixedWidth(50)
        self.tab1_ignore = QWidget()
        self.tab1_ignore_layout = QHBoxLayout()
        self.tab1_ignore_layout.setContentsMargins(0, 0, 0, 0)
        self.tab1_ignore_label1 = QLabel('시작부터')
        self.tab1_ignore_value = QSpinBox()
        self.tab1_ignore_value.setFixedWidth(50)
        self.tab1_ignore_value.setValue(5)
        self.tab1_ignore_label2 = QLabel('줄 ')
        self.tab1_ignore_sec = QSpinBox()
        self.tab1_ignore_sec.setFixedWidth(60)
        self.tab1_ignore_sec.setMaximum(1000)
        self.tab1_ignore_sec.setValue(90)
        self.tab1_ignore_label3 = QLabel('초 무시하기')
        self.tab1_add_button = QPushButton('추가하기')

        self.tab_page_2 = QWidget()
        self.tab_grid_2 = QGridLayout()
        self.tab2_shift = QWidget()
        self.tab2_shift_layout = QHBoxLayout()
        self.tab2_shift_layout.setContentsMargins(0, 0, 0, 0)
        self.tab2_shift_label1 = QLabel('자막 싱크')
        self.tab2_shift_value = QDoubleSpinBox()
        self.tab2_shift_value.setFixedWidth(60)
        self.tab2_shift_label2 = QLabel('초 ')
        self.tab2_slow_radio = QRadioButton('느리게')
        self.tab2_slow_radio.setChecked(True)
        self.tab2_fast_radio = QRadioButton('빠르게')
        self.tab2_add_button = QPushButton('추가하기')

        self.tab_page_3 = QWidget()
        self.tab_grid_3 = QGridLayout()
        self.tab3_speed_label1 = QLabel('자막 싱크')
        self.tab3_speed_value = QSpinBox()
        self.tab3_speed_value.setFixedWidth(70)
        self.tab3_speed_value.setRange(1, 1000)
        self.tab3_speed_value.setValue(100)
        self.tab3_speed_label2 = QLabel('%')
        self.tab3_add_button = QPushButton('추가하기')

        self.que_label = QLabel('작업 목록')
        self.que_label.setFixedHeight(24)
        self.que_widget = QWidget()
        self.que_widget.setFixedHeight(114)
        self.que_layout = QGridLayout()
        self.que_layout.setContentsMargins(0, 0, 0, 0)
        self.que_list = QTreeWidget()
        self.que_list.setHeaderLabels(['작업', '옵션'])
        self.que_delete_button = QPushButton(QIcon(':/remove.png'), '')
        self.que_delete_button.setFixedSize(icon_button_size)
        self.que_delete_button.setIconSize(icon_size)
        self.que_delete_button.setToolTip('목록 삭제')
        self.que_up_button = QPushButton(QIcon(':/up.png'), '')
        self.que_up_button.setIconSize(icon_size)
        self.que_up_button.setFixedSize(icon_button_size)
        self.que_up_button.setToolTip('위로')
        self.que_down_button = QPushButton(QIcon(':/down.png'), '')
        self.que_down_button.setIconSize(icon_size)
        self.que_down_button.setFixedSize(icon_button_size)
        self.que_down_button.setToolTip('아래로')
        self.que_clear_button = QPushButton(QIcon(':/clear.png'), '')
        self.que_clear_button.setIconSize(icon_size)
        self.que_clear_button.setFixedSize(icon_button_size)
        self.que_clear_button.setToolTip('비우기')

        self.file_label = QLabel('파일 목록')
        self.file_label.setFixedHeight(24)
        self.file_widget = QWidget()
        self.file_layout = QGridLayout()
        self.file_layout.setContentsMargins(0, 0, 0, 0)
        self.file_list = QTreeWidget()
        self.file_list.setAcceptDrops(True)
        self.file_list.setHeaderLabels(['이름', '경로'])
        self.file_file_open = QPushButton(QIcon(':/file.png'), '')
        self.file_file_open.setFixedSize(icon_button_size)
        self.file_file_open.setIconSize(icon_size)
        self.file_file_open.setToolTip('파일 열기')
        self.file_dir_open = QPushButton(QIcon(':/folder.png'), '')
        self.file_dir_open.setFixedSize(icon_button_size)
        self.file_dir_open.setIconSize(icon_size)
        self.file_dir_open.setToolTip('폴더 열기')
        self.file_delete = QPushButton(QIcon(':/remove.png'), '')
        self.file_delete.setFixedSize(icon_button_size)
        self.file_delete.setIconSize(icon_size)
        self.file_delete.setToolTip('목록 삭제')
        self.file_clear = QPushButton(QIcon(':/clear.png'), '')
        self.file_clear.setFixedSize(icon_button_size)
        self.file_clear.setIconSize(icon_size)
        self.file_clear.setToolTip('비우기')
        self.file_encode = QPushButton(QIcon(':/encode.png'), '')
        self.file_encode.setFixedSize(icon_button_size)
        self.file_encode.setIconSize(icon_size)
        self.file_encode.setToolTip('인코딩 설정')

        self.save_widget = QGroupBox('저장 옵션')
        self.save_widget.setMinimumSize(400, 0)
        self.save_widget.setFixedHeight(82)
        self.save_layout = QGridLayout()
        self.save_orig_radio = QRadioButton('원본 위치에 저장')
        self.save_orig_radio.setChecked(True)
        self.save_strip = QCheckBox('싱크 꼬임 무시')
        self.save_strip.setToolTip('싱크 꼬임을 무시하고 모든 자막을 보존합니다.')
        self.save_dir_radio = QRadioButton('다른 위치에 저장')
        self.save_dir_line = QLineEdit()
        self.save_dir_find = QPushButton('...')
        self.save_dir_find.setFixedWidth(40)

        self.ok_button = QPushButton('적용')
        self.ok_button.setFixedSize(normal_button_size)
        self.cancel_button = QPushButton('취소')
        self.cancel_button.setFixedSize(normal_button_size)

        # Display GUI Components
        self.central_layout.addWidget(self.tab_group_widget, 0, 0, 1, 3)
        self.central_layout.addWidget(self.que_label, 1, 0, 1, 3)
        self.central_layout.addWidget(self.que_widget, 2, 0, 1, 3)
        self.central_layout.addWidget(self.file_label, 3, 0, 1, 3)
        self.central_layout.addWidget(self.file_widget, 4, 0, 1, 3)
        self.central_layout.addWidget(self.save_widget, 5, 0, 1, 3)
        self.central_layout.addWidget(self.ok_button, 6, 1, 1, 1)
        self.central_layout.addWidget(self.cancel_button, 6, 2, 1, 1)

        self.tab_group_widget.addTab(self.tab_page_1, QIcon(), self.tab1_name)
        self.tab_group_widget.addTab(self.tab_page_2, QIcon(), self.tab2_name)
        self.tab_group_widget.addTab(self.tab_page_3, QIcon(), self.tab3_name)

        self.tab_page_1.setLayout(self.tab_grid_1)
        self.tab_grid_1.addWidget(self.tab1_search_label, 0, 0, 1, 1)
        self.tab_grid_1.addWidget(self.tab1_search, 0, 1, 1, 2)
        self.tab_grid_1.addWidget(self.tab1_sponsor, 1, 1, 1, 1)
        self.tab_grid_1.addWidget(self.tab1_offset, 1, 2, 1, 1)
        self.tab_grid_1.addWidget(self.tab1_ignore, 2, 1, 1, 2)
        self.tab_grid_1.addWidget(self.tab1_add_button, 3, 0, 1, 3)
        self.tab1_sponsor.setLayout(self.tab1_sponsor_layout)
        self.tab1_sponsor_layout.addWidget(self.tab1_sponsor_label)
        self.tab1_sponsor_layout.addWidget(self.tab1_sponsor_value)
        self.tab1_sponsor_layout.addStretch(1)
        self.tab1_offset.setLayout(self.tab1_offset_layout)
        self.tab1_offset_layout.addWidget(self.tab1_offset_label)
        self.tab1_offset_layout.addWidget(self.tab1_offset_value)
        self.tab1_offset_layout.addStretch(1)
        self.tab1_ignore.setLayout(self.tab1_ignore_layout)
        self.tab1_ignore_layout.addWidget(self.tab1_ignore_label1)
        self.tab1_ignore_layout.addWidget(self.tab1_ignore_value)
        self.tab1_ignore_layout.addWidget(self.tab1_ignore_label2)
        self.tab1_ignore_layout.addWidget(self.tab1_ignore_sec)
        self.tab1_ignore_layout.addWidget(self.tab1_ignore_label3)
        self.tab1_ignore_layout.addStretch(1)

        self.tab_page_2.setLayout(self.tab_grid_2)
        self.tab_grid_2.setRowStretch(0, 1)
        self.tab_grid_2.addWidget(self.tab2_shift, 1, 0, 2, 1)
        self.tab_grid_2.addWidget(self.tab2_slow_radio, 1, 1, 1, 1)
        self.tab_grid_2.addWidget(self.tab2_fast_radio, 2, 1, 1, 1)
        self.tab_grid_2.setColumnStretch(2, 1)
        self.tab_grid_2.setRowStretch(3, 1)
        self.tab_grid_2.addWidget(self.tab2_add_button, 4, 0, 1, 3)
        self.tab2_shift.setLayout(self.tab2_shift_layout)
        self.tab2_shift_layout.addWidget(self.tab2_shift_label1)
        self.tab2_shift_layout.addWidget(self.tab2_shift_value)
        self.tab2_shift_layout.addWidget(self.tab2_shift_label2)

        self.tab_page_3.setLayout(self.tab_grid_3)
        self.tab_grid_3.setRowStretch(0, 1)
        self.tab_grid_3.addWidget(self.tab3_speed_label1, 1, 0, 1, 1)
        self.tab_grid_3.addWidget(self.tab3_speed_value, 1, 1, 1, 1)
        self.tab_grid_3.addWidget(self.tab3_speed_label2, 1, 2, 1, 1)
        self.tab_grid_3.setColumnStretch(3, 1)
        self.tab_grid_3.setRowStretch(2, 1)
        self.tab_grid_3.addWidget(self.tab3_add_button, 3, 0, 1, 4)

        self.que_widget.setLayout(self.que_layout)
        self.que_layout.addWidget(self.que_list, 0, 0, 4, 1)
        self.que_layout.addWidget(self.que_delete_button, 0, 1, 1, 1)
        self.que_layout.addWidget(self.que_up_button, 1, 1, 1, 1)
        self.que_layout.addWidget(self.que_down_button, 2, 1, 1, 1)
        self.que_layout.addWidget(self.que_clear_button, 3, 1, 1, 1)

        self.file_widget.setLayout(self.file_layout)
        self.file_layout.addWidget(self.file_list, 0, 0, 6, 1)
        self.file_layout.addWidget(self.file_file_open, 0, 1, 1, 1)
        self.file_layout.addWidget(self.file_dir_open, 1, 1, 1, 1)
        self.file_layout.addWidget(self.file_delete, 2, 1, 1, 1)
        self.file_layout.addWidget(self.file_clear, 3, 1, 1, 1)
        self.file_layout.addWidget(self.file_encode, 5, 1, 1, 1)

        self.save_widget.setLayout(self.save_layout)
        self.save_layout.addWidget(self.save_orig_radio, 0, 0, 1, 1)
        self.save_layout.setColumnStretch(1, 1)
        self.save_layout.addWidget(self.save_strip, 0, 2, 1, 2)
        self.save_layout.addWidget(self.save_dir_radio, 1, 0, 1, 1)
        self.save_layout.addWidget(self.save_dir_line, 1, 1, 1, 2)
        self.save_layout.addWidget(self.save_dir_find, 1, 3, 1, 1)

        self.setWindowTitle('Batch SAMI Sync v0.2')
        self.setCentralWidget(self.central_widget)
        self.adjustSize()
    def __init__(self, database, parent):
        QWidget.__init__(self)
        self.recipe_ingredients = 0
        self.add_recipe_win = QWidget()
        self.add_recipe_win.setFixedWidth(400)
        self.add_recipe_win.setWindowTitle("Add Recipe")
        add_rec_main_layout = QVBoxLayout()

        self.meal_planner_db = database
        self.setParent(parent)

        self.rec_name_input = QLineEdit()
        self.rec_desc_input = QLineEdit()
        self.rec_source_input = QLineEdit()
        rec_form_layout = QFormLayout()
        rec_form_layout.addRow(QLabel("Recipe Name"), self.rec_name_input)
        rec_form_layout.addRow(QLabel("Recipe Desc"), self.rec_desc_input)
        rec_form_layout.addRow(QLabel("Recipe Source"), self.rec_source_input)
        add_rec_main_layout.addLayout(rec_form_layout)

        rec_info_layout = QHBoxLayout()
        difficulty_layout = QVBoxLayout()
        self.difficulty_spinbox = QSpinBox()
        self.difficulty_spinbox.setRange(1, 5)
        self.difficulty_spinbox.setValue(3)
        difficulty_layout.addWidget(QLabel("Difficulty"))
        difficulty_layout.addWidget(self.difficulty_spinbox)

        prep_time_layout = QVBoxLayout()
        self.prep_time_spinbox = QSpinBox()
        self.prep_time_spinbox.setRange(0, 600)
        self.prep_time_spinbox.setValue(30)
        prep_time_layout.addWidget(QLabel("Prep. Time (min.)"))
        prep_time_layout.addWidget(self.prep_time_spinbox)

        rating_layout = QVBoxLayout()
        self.rating_spinbox = QSpinBox()
        self.rating_spinbox.setRange(1, 5)
        self.rating_spinbox.setValue(3)
        rating_layout.addWidget(QLabel("Rating"))
        rating_layout.addWidget(self.rating_spinbox)

        rec_info_layout.addLayout(difficulty_layout)
        rec_info_layout.addLayout(prep_time_layout)
        rec_info_layout.addLayout(rating_layout)

        add_rec_main_layout.addLayout(rec_info_layout)

        rec_tags_layout = QHBoxLayout()
        rec_cuisine_layout = QVBoxLayout()
        cuisines = [
            "Mexican", "Swedish", "Austrian", "Italian", "Spanish", "American",
            "British", "Thai", "Greek", "Vietnamese", "Caribbean", "Japanese",
            "Chinese", "Indian", "French", "Swiss", "Portuguese", "Korean",
            "Turkish", "Moroccan", "Russian", "Malaysian", "Philippines",
            "Ethiopian", "Lebanese", "Arab", "Peruvian", "Brazilian", "Asian",
            "Middle Eastern", "South American", "African", "-"
        ]
        cuisines.sort()
        self.tag_cuisine = QComboBox()
        self.tag_cuisine.addItems(cuisines)
        rec_cuisine_layout.addWidget(QLabel("Cuisine"))
        rec_cuisine_layout.addWidget(self.tag_cuisine)
        rec_tags_layout.addLayout(rec_cuisine_layout)

        rec_category_layout = QVBoxLayout()
        categories = [
            "Beef & Calf", "Chicken & Poultry", "Lamb", "Pork", "Preservation",
            "Salad", "Sandwich", "Soup", "Stew", "Pasta", "Rice",
            "Grain & Beans", "Fish & Seafood", "Vegetables", "Eggs & Cheese",
            "BBQ", "Fruits", "Cake & Pie (Sweet)", "Pie", "Bread", "Beverage",
            "Cookies & Sweets", "Sauce", "-"
        ]
        categories.sort()
        self.tag_category = QComboBox()
        self.tag_category.addItems(categories)
        rec_category_layout.addWidget(QLabel("Category"))
        rec_category_layout.addWidget(self.tag_category)
        rec_tags_layout.addLayout(rec_category_layout)

        rec_meal_type_layout = QVBoxLayout()
        meal_types = [
            "Breakfast", "Brunch", "Lunch", "Dinner", "Dessert", "Starter",
            "Side", "Buffet", "Snack", "-"
        ]
        meal_types.sort()
        self.tag_meal_types = QComboBox()
        self.tag_meal_types.addItems(meal_types)
        rec_meal_type_layout.addWidget(QLabel("Meal Type"))
        rec_meal_type_layout.addWidget(self.tag_meal_types)
        rec_tags_layout.addLayout(rec_meal_type_layout)

        add_rec_main_layout.addLayout(rec_tags_layout)

        self.ingredient_name_input = QLineEdit()
        self.ingredient_qty_input = QDoubleSpinBox()
        self.ingredient_qty_input.setValue(1.0)
        self.ingredient_qty_input.setMaximum(1000)
        self.ingredient_qty_input.setDecimals(2)
        self.ingredient_unit_input = QComboBox()
        self.ingredient_unit_input.addItems(
            ["g", "ml", "dl", "l", "msk", "tsk", "st", "-"])
        add_ingredient_btn = QPushButton("Create ingredient")
        add_ingredient_btn.clicked.connect(self.create_ingredient)
        add_ingredient_layout = QHBoxLayout()
        add_rec_main_layout.addWidget(QLabel("Ingredient"))
        add_ingredient_layout.addWidget(self.ingredient_name_input)
        add_ingredient_layout.addWidget(self.ingredient_qty_input)
        add_ingredient_layout.addWidget(self.ingredient_unit_input)
        add_ingredient_layout.addWidget(add_ingredient_btn)
        add_rec_main_layout.addLayout(add_ingredient_layout)

        btn_layout = QHBoxLayout()
        add_ingredient_to_recipe_btn = QPushButton("Add ingredient")
        add_ingredient_to_recipe_btn.clicked.connect(
            self.add_ingredient_to_recipe)

        del_ingredient_from_recipe_btn = QPushButton("Remove ingredient")
        del_ingredient_from_recipe_btn.clicked.connect(
            self.del_ingredient_from_recipe)
        btn_layout.addWidget(add_ingredient_to_recipe_btn)
        btn_layout.addWidget(del_ingredient_from_recipe_btn)
        add_rec_main_layout.addLayout(btn_layout)

        self.rec_ingredient_table = QTableWidget()
        self.rec_ingredient_table.setColumnCount(3)
        self.rec_ingredient_table.setHorizontalHeaderLabels(
            ["Amount", "Unit", "Ingredient"])
        header = self.rec_ingredient_table.horizontalHeader()
        header.setSectionResizeMode(0, QtWidgets.QHeaderView.ResizeToContents)
        header.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents)
        header.setSectionResizeMode(2, QtWidgets.QHeaderView.Stretch)
        add_rec_main_layout.addWidget(self.rec_ingredient_table)

        self.step_count = 0
        self.add_recipe_step_btn = QPushButton("Add recipe instruction")
        add_rec_main_layout.addWidget(self.add_recipe_step_btn)
        self.add_recipe_step_btn.clicked.connect(self.add_recipe_step_win)
        self.rec_step_table = QTableWidget()
        self.rec_step_table.setColumnCount(1)
        self.rec_step_table.setHorizontalHeaderLabels(["Instructions"])
        self.rec_step_table.setWordWrap(True)
        header = self.rec_step_table.horizontalHeader()
        header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
        add_rec_main_layout.addWidget(self.rec_step_table)

        bottom_btn_layout = QHBoxLayout()
        self.add_rec_btn = QPushButton("Add recipe")
        self.add_rec_btn.clicked.connect(self.add_recipe_to_db)

        self.back_btn = QPushButton("Cancel")
        self.back_btn.clicked.connect(self.add_recipe_win.close)

        bottom_btn_layout.addWidget(self.add_rec_btn)
        bottom_btn_layout.addWidget(self.back_btn)
        add_rec_main_layout.addLayout(bottom_btn_layout)

        self.add_recipe_win.setLayout(add_rec_main_layout)
        self.add_recipe_win.show()
示例#16
0
    def __init__(self):
        super().__init__()

        layout = QVBoxLayout()

        form = QFormLayout()

        self.track_id = QSpinBox()
        self.track_id.setDisabled(True)
        self.name = QLineEdit()
        self.album = QComboBox()
        self.media_type = QComboBox()
        self.genre = QComboBox()
        self.composer = QLineEdit()

        self.milliseconds = QSpinBox()
        self.milliseconds.setRange(0, 2147483647)
        self.milliseconds.setSingleStep(1)

        self.bytes = QSpinBox()
        self.bytes.setRange(0, 2147483647)
        self.bytes.setSingleStep(1)

        self.unit_price = QDoubleSpinBox()
        self.unit_price.setRange(0, 999)
        self.unit_price.setSingleStep(0.01)
        self.unit_price.setPrefix("$")

        form.addRow(QLabel("Track ID"), self.track_id)
        form.addRow(QLabel("Track name"), self.name)
        form.addRow(QLabel("Composer"), self.composer)
        form.addRow(QLabel("Milliseconds"), self.milliseconds)
        form.addRow(QLabel("Bytes"), self.bytes)
        form.addRow(QLabel("Unit Price"), self.unit_price)

        self.model = QSqlTableModel(db=db)

        self.mapper = QDataWidgetMapper()
        self.mapper.setModel(self.model)

        self.mapper.addMapping(self.track_id, 0)
        self.mapper.addMapping(self.name, 1)
        self.mapper.addMapping(self.composer, 5)
        self.mapper.addMapping(self.milliseconds, 6)
        self.mapper.addMapping(self.bytes, 7)
        self.mapper.addMapping(self.unit_price, 8)

        self.model.setTable("Track")
        self.model.select()

        self.mapper.toFirst()

        self.setMinimumSize(QSize(400, 400))

        controls = QHBoxLayout()

        # tag::controls[]
        prev_rec = QPushButton("Previous")
        prev_rec.clicked.connect(self.mapper.toPrevious)

        next_rec = QPushButton("Next")
        next_rec.clicked.connect(self.mapper.toNext)

        save_rec = QPushButton("Save Changes")
        save_rec.clicked.connect(self.mapper.submit)
        # end::controls[]

        controls.addWidget(prev_rec)
        controls.addWidget(next_rec)
        controls.addWidget(save_rec)

        layout.addLayout(form)
        layout.addLayout(controls)

        widget = QWidget()
        widget.setLayout(layout)
        self.setCentralWidget(widget)
示例#17
0
    def init_ui(self):
        self.setWindowTitle(_('Printer settings'))
        self.setWindowIcon(QIcon(config.ICON))
        self.setSizeGripEnabled(False)
        self.setModal(True)

        self.layout = QFormLayout(self)

        self.label_split_printer = QLabel(_('Default split printer'))
        self.split_printer_selector = QPushButton(_('select'))

        def select_split_printer():
            printer = self.select_printer()
            self.selected_split_printer.setText(printer)

        self.split_printer_selector.clicked.connect(select_split_printer)

        self.selected_printer = QLabel()
        self.selected_split_printer = QLabel()

        self.layout.addRow(self.label_split_printer,
                           self.split_printer_selector)
        self.layout.addRow(self.selected_split_printer)

        self.label_template = QLabel(_('Template'))
        self.item_template = AdvComboBox()
        self.item_template.setMaximumWidth(200)
        self.item_template.addItem(_('Internal printing'))
        self.item_template.addItem(
            _('Internal printing') + ' ' + _('scale') + '=75')
        self.item_template.addItems(get_templates(
            config.template_dir('split')))
        self.layout.addRow(self.label_template, self.item_template)

        self.item_custom_path = QPushButton(_('Choose template'))

        def select_custom_path():
            file_name = get_open_file_name(_('Open HTML template'),
                                           _("HTML file (*.html)"))
            self.item_template.setCurrentText(file_name)

        self.item_custom_path.clicked.connect(select_custom_path)
        self.layout.addRow(self.item_custom_path)

        self.print_splits_checkbox = QCheckBox(_('Print splits'))
        self.layout.addRow(self.print_splits_checkbox)

        self.margin_group_box = QGroupBox(_('Margins'))
        self.margin_layout = QFormLayout()
        self.item_margin_left = QDoubleSpinBox()
        self.margin_layout.addRow(QLabel(_('Left')), self.item_margin_left)
        self.item_margin_top = QDoubleSpinBox()
        self.margin_layout.addRow(QLabel(_('Top')), self.item_margin_top)
        self.item_margin_right = QDoubleSpinBox()
        self.margin_layout.addRow(QLabel(_('Right')), self.item_margin_right)
        self.item_margin_bottom = QDoubleSpinBox()
        self.margin_layout.addRow(QLabel(_('Bottom')), self.item_margin_bottom)
        self.margin_group_box.setLayout(self.margin_layout)
        self.layout.addRow(self.margin_group_box)

        self.set_values()

        def cancel_changes():
            self.close()

        def apply_changes():
            try:
                self.apply_changes_impl()
            except Exception as e:
                logging.error(str(e))
            self.close()

        button_box = QDialogButtonBox(QDialogButtonBox.Ok
                                      | QDialogButtonBox.Cancel)
        self.button_ok = button_box.button(QDialogButtonBox.Ok)
        self.button_ok.setText(_('OK'))
        self.button_ok.clicked.connect(apply_changes)
        self.button_cancel = button_box.button(QDialogButtonBox.Cancel)
        self.button_cancel.setText(_('Cancel'))
        self.button_cancel.clicked.connect(cancel_changes)
        self.layout.addRow(button_box)

        self.show()
示例#18
0
    def __init__(self,
                 audios_name,
                 audios_delay,
                 audios_language,
                 audios_track_name,
                 audios_set_default,
                 audios_set_forced,
                 audios_default_value_delay,
                 audios_default_value_language,
                 audios_default_value_track_name,
                 audios_default_value_set_default,
                 audios_default_value_set_forced,
                 audio_set_default_disabled=False,
                 audio_set_forced_disabled=False,
                 disable_edit=False,
                 parent=None):
        super().__init__(parent)
        self.window_title = "Audio Info"
        self.state = "no"
        self.audios_count = len(audios_delay)

        self.messageIcon = QLabel()
        self.audio_tab_comboBox = InfoCellDialogTabComboBox(
            hint="Audios Groups")
        for i in range(self.audios_count):
            self.audio_tab_comboBox.addItem("Audio #" + str(i + 1))
        self.audio_tab_comboBox.setCurrentIndex(0)
        self.audio_tab_comboBox.currentIndexChanged.connect(
            self.update_current_audio_index)
        self.current_audio_index = 0

        self.disable_edit = disable_edit
        self.current_audio_name = audios_name
        self.current_audio_language = audios_language
        self.current_audio_delay = audios_delay
        self.current_audio_track_name = audios_track_name
        self.current_audio_set_default = audios_set_default
        self.current_audio_set_forced = audios_set_forced

        self.default_audio_language = audios_default_value_language
        self.default_audio_delay = audios_default_value_delay
        self.default_audio_track_name = audios_default_value_track_name
        self.default_audio_set_default = audios_default_value_set_default
        self.default_audio_set_forced = audios_default_value_set_forced

        self.audio_set_default_disabled = audio_set_default_disabled
        self.audio_set_forced_disabled = audio_set_forced_disabled

        self.audio_name_label = QLabel("Audio Name:")
        self.audio_name_value = QLabel(
            str(self.current_audio_name[self.current_audio_index]))
        width_to_be_fixed = 0
        for i in range(len(self.current_audio_name)):
            width_to_be_fixed = max(
                width_to_be_fixed,
                self.audio_name_value.fontMetrics().boundingRect(
                    self.current_audio_name[i]).width())
        self.audio_name_value.setFixedWidth(width_to_be_fixed + 10)
        self.audio_delay_label = QLabel("Audio Delay:")
        self.audio_delay_spin = QDoubleSpinBox()
        self.setup_audio_delay_spin()

        self.audio_language_label = QLabel("Audio Language:")
        self.audio_language_comboBox = QComboBox()
        self.setup_audio_language_comboBox()

        self.audio_track_name_label = QLabel("Audio Track Name:")
        self.audio_track_name_lineEdit = QLineEdit()
        self.setup_audio_track_name_lineEdit()

        self.audio_set_forced_label = QLabel("Audio Forced State:")
        self.audio_set_forced_checkBox = QCheckBox()
        self.setup_audio_set_forced_checkBox()

        self.audio_set_default_label = QLabel("Audio Default State:")
        self.audio_set_default_checkBox = QCheckBox()
        self.setup_audio_set_default_checkBox()

        self.yes_button = QPushButton("OK")
        self.no_button = QPushButton("Cancel")
        self.reset_button = QPushButton("Reset To Default")

        self.buttons_layout = QHBoxLayout()
        self.audio_delay_layout = QHBoxLayout()
        self.audio_language_layout = QHBoxLayout()
        self.audio_track_name_layout = QHBoxLayout()
        self.audio_set_default_layout = QHBoxLayout()
        self.audio_set_forced_layout = QHBoxLayout()
        self.buttons_layout.addWidget(QLabel(""), stretch=3)
        self.buttons_layout.addWidget(self.reset_button, stretch=2)
        self.buttons_layout.addWidget(self.yes_button, stretch=2)
        self.buttons_layout.addWidget(self.no_button, stretch=2)
        self.buttons_layout.addWidget(QLabel(""), stretch=3)
        self.audio_setting_layout = QGridLayout()
        self.audio_editable_setting_layout = QFormLayout()
        self.audio_editable_setting_layout.addRow(self.audio_name_label,
                                                  self.audio_name_value)
        self.audio_editable_setting_layout.addRow(
            self.audio_track_name_label, self.audio_track_name_lineEdit)
        self.audio_editable_setting_layout.addRow(self.audio_language_label,
                                                  self.audio_language_comboBox)
        self.audio_editable_setting_layout.addRow(self.audio_delay_label,
                                                  self.audio_delay_spin)
        self.audio_editable_setting_layout.addRow(
            self.audio_set_default_label, self.audio_set_default_checkBox)
        self.audio_editable_setting_layout.addRow(
            self.audio_set_forced_label, self.audio_set_forced_checkBox)
        self.audio_setting_layout.addWidget(self.audio_tab_comboBox, 0, 0)
        self.audio_setting_layout.addLayout(self.audio_editable_setting_layout,
                                            1, 0, 5, 2)
        self.audio_setting_layout.addWidget(self.messageIcon, 1, 3, 5, -1)

        self.main_layout = QGridLayout()
        self.main_layout.addLayout(self.audio_setting_layout, 0, 0, 2, 3)
        self.main_layout.addLayout(self.buttons_layout, 2, 0, 1, -1)
        self.main_layout.setContentsMargins(20, 20, 20, 20)
        self.setLayout(self.main_layout)

        self.setup_ui()
        self.signal_connect()
    def __init__(self, parent=None):
        super().__init__(parent)
        layout = QFormLayout()
        self.setLayout(layout)

        self._model = None

        # Block properties ---------------------------------------------------------------------------------------------
        self.duration = QWidget()
        self.duration.setContentsMargins(0, 0, 0, 0)
        ly = QHBoxLayout()
        ly.setContentsMargins(0, 0, 0, 0)
        self.duration.setLayout(ly)

        self.duration_base = QDoubleSpinBox()
        self.duration_base.setRange(0, 1000)
        self.duration_base.setValue(10)

        self.duration_deviation = QDoubleSpinBox()
        self.duration_deviation.setRange(0, 10)
        self.duration_deviation.setValue(0)
        self.duration_deviation.setSingleStep(0.1)
        self.duration_deviation.setSuffix(" s")
        self.duration_base.valueChanged.connect(self.duration_deviation.setMaximum)

        ly.addWidget(self.duration_base)
        ly.addWidget(QLabel("±"))
        ly.addWidget(self.duration_deviation)

        self.feedback_source = QLineEdit("All")

        self.feedback_type = QComboBox()
        self.feedback_type.addItem("Baseline")
        self.feedback_type.addItem("Feedback")

        self.mock_signal_path = QLineEdit()
        self.mock_signal_dataset = QLineEdit()
        self.mock_previous = QSpinBox()
        self.mock_previous_reverse = QCheckBox()
        self.mock_previous_random = QCheckBox()
        self.pause = QCheckBox()
        self.beep = QCheckBox()
        self.start_data_driven_filter_designer = QCheckBox()
        self.update_statistics = QCheckBox()
        self.update_statistics.stateChanged.connect(lambda state: self.statistics_type.setEnabled(bool(state)))
        self.statistics_type = QComboBox()
        self.statistics_type.setEnabled(False)
        for name in self.statistics_name_to_type:
            self.statistics_type.addItem(name)
        self.statistics_type.setCurrentText("Standardise")

        self.random_bound = QComboBox()
        self.random_bound.addItem("SimCircle")
        self.random_bound.addItem("RandomCircle")
        self.random_bound.addItem("Bar")

        self.video_path = QLineEdit()
        
        self.message = QLineEdit()
        self.feedback_type.currentTextChanged.connect(lambda ftype: self.message.setEnabled(ftype == "Baseline"))

        self.voiceover = QCheckBox()

        # Grouped properties -------------------------------------------------------------------------------------------
        # Mock signal
        mock_signal_groupbox = QGroupBox("Mock signal")
        mock_signal_gblayout = QFormLayout()
        mock_signal_groupbox.setLayout(mock_signal_gblayout)
        mock_signal_gblayout.addRow("Mock signal file path", self.mock_signal_path)
        mock_signal_gblayout.addRow("Mock signal file dataset", self.mock_signal_dataset)
        mock_signal_gblayout.addRow("Mock previous", self.mock_previous)
        mock_signal_gblayout.addRow("Reverse mock previous", self.mock_previous_reverse)
        mock_signal_gblayout.addRow("Random mock previous", self.mock_previous_random)

        # After block actions
        after_block_groupbox = QGroupBox("After block actions")
        after_block_gblayout = QFormLayout()
        after_block_groupbox.setLayout(after_block_gblayout)
        after_block_gblayout.addRow("Start data driven filter designer", self.start_data_driven_filter_designer)
        after_block_gblayout.addRow("Pause", self.pause)
        after_block_gblayout.addRow("Beep", self.beep)
        after_block_gblayout.addRow("Update statistics", self.update_statistics)
        after_block_gblayout.addRow("Statistics type", self.statistics_type)

        # Adding properties to the widget ------------------------------------------------------------------------------
        layout.addRow("Duration", self.duration)
        layout.addRow("Source", self.feedback_source)
        layout.addRow("FB Type", self.feedback_type)
        layout.addRow("Random bound", self.random_bound)
        layout.addRow("Video path", self.video_path)
        layout.addRow("Message for test subject", self.message)
        layout.addRow("Voiceover for message", self.voiceover)
        layout.addRow(mock_signal_groupbox)
        layout.addRow(after_block_groupbox)
示例#20
0
    def createGeneralTab(self):

        # Masking options
        self.maskingCheck = QCheckBox('')
        self.maskingCheck.stateChanged.connect(self.mw.toggleMasking)

        self.maskColorButton = QPushButton()
        self.maskColorButton.setCursor(QtCore.Qt.PointingHandCursor)
        self.maskColorButton.setFixedWidth(self.FM.width("XXXXXXXXXX"))
        self.maskColorButton.setFixedHeight(self.FM.height() * 1.5)
        self.maskColorButton.clicked.connect(self.mw.editMaskingColor)

        # Highlighting options
        self.hlCheck = QCheckBox('')
        self.hlCheck.stateChanged.connect(self.mw.toggleHighlighting)

        self.hlColorButton = QPushButton()
        self.hlColorButton.setCursor(QtCore.Qt.PointingHandCursor)
        self.hlColorButton.setFixedWidth(self.FM.width("XXXXXXXXXX"))
        self.hlColorButton.setFixedHeight(self.FM.height() * 1.5)
        self.hlColorButton.clicked.connect(self.mw.editHighlightColor)

        self.alphaBox = QDoubleSpinBox()
        self.alphaBox.setRange(0, 1)
        self.alphaBox.setSingleStep(.05)
        self.alphaBox.valueChanged.connect(self.mw.editAlpha)

        self.seedBox = QSpinBox()
        self.seedBox.setRange(1, 999)
        self.seedBox.valueChanged.connect(self.mw.editSeed)

        # General options
        self.bgButton = QPushButton()
        self.bgButton.setCursor(QtCore.Qt.PointingHandCursor)
        self.bgButton.setFixedWidth(self.FM.width("XXXXXXXXXX"))
        self.bgButton.setFixedHeight(self.FM.height() * 1.5)
        self.bgButton.clicked.connect(self.mw.editBackgroundColor)

        self.colorbyBox = QComboBox(self)
        self.colorbyBox.addItem("material")
        self.colorbyBox.addItem("cell")
        self.colorbyBox.currentTextChanged[str].connect(self.mw.editColorBy)

        formLayout = QFormLayout()
        formLayout.setAlignment(QtCore.Qt.AlignHCenter)
        formLayout.setFormAlignment(QtCore.Qt.AlignHCenter)
        formLayout.setLabelAlignment(QtCore.Qt.AlignLeft)
        #formLayout.setFieldGrowthPolicy(QFormLayout.AllNonFixedFieldsGrow)

        formLayout.addRow('Masking:', self.maskingCheck)
        formLayout.addRow('Mask Color:', self.maskColorButton)
        formLayout.addRow(HorizontalLine())
        formLayout.addRow('Highlighting:', self.hlCheck)
        formLayout.addRow('Highlight Color:', self.hlColorButton)
        formLayout.addRow('Highlight Alpha:', self.alphaBox)
        formLayout.addRow('Highlight Seed:', self.seedBox)
        formLayout.addRow(HorizontalLine())
        formLayout.addRow('Background Color:          ', self.bgButton)
        formLayout.addRow('Color Plot By:', self.colorbyBox)

        generalLayout = QHBoxLayout()
        innerWidget = QWidget()
        generalLayout.setAlignment(QtCore.Qt.AlignVCenter)
        innerWidget.setLayout(formLayout)
        generalLayout.addStretch(1)
        generalLayout.addWidget(innerWidget)
        generalLayout.addStretch(1)

        self.generalTab = QWidget()
        self.generalTab.setLayout(generalLayout)
示例#21
0
    def __init__(self, parent=None):
        super(NGL_HKLViewer, self).__init__(parent)

        self.verbose = 0
        self.UseOSbrowser = False
        self.jscriptfname = ""
        self.devmode = False
        self.hklfname = ""
        self.handshakewait = 5
        for e in sys.argv:
            if "verbose" in e:
                self.verbose = e.split("verbose=")[1]
            if "UseOSbrowser" in e:
                self.UseOSbrowser = e.split("UseOSbrowser=")[1]
            if "jscriptfname" in e:
                self.jscriptfname = e.split("jscriptfname=")[1]
            if "devmode" in e:
                self.devmode = True
            if 'htmlfname' in e:
                self.hklfname = e.split("htmlfname=")[1]
            if 'handshakewait' in e:
                self.handshakewait = e.split('handshakewait=')[1]

        self.zmq_context = None
        self.bufsize = 20000

        self.originalPalette = QApplication.palette()

        self.openFileNameButton = QPushButton("Load reflection file")
        self.openFileNameButton.setDefault(True)
        self.openFileNameButton.clicked.connect(self.OpenReflectionsFile)

        self.debugbutton = QPushButton("Debug")
        self.debugbutton.clicked.connect(self.DebugInteractively)

        self.settingsbtn = QPushButton("Settings")
        self.settingsbtn.clicked.connect(self.SettingsDialog)

        self.mousemoveslider = QSlider(Qt.Horizontal)
        self.mousemoveslider.setMinimum(0)
        self.mousemoveslider.setMaximum(300)
        self.mousemoveslider.setValue(0)
        self.mousemoveslider.sliderReleased.connect(
            self.onFinalMouseSensitivity)
        self.mousemoveslider.valueChanged.connect(self.onMouseSensitivity)
        self.mousesensitxtbox = QLineEdit('')
        self.mousesensitxtbox.setReadOnly(True)
        self.fontspinBox = QDoubleSpinBox()
        self.fontspinBox.setSingleStep(1)
        self.fontspinBox.setRange(4, 50)
        self.font = QFont()
        self.font.setFamily(self.font.defaultFamily())
        self.fontspinBox.setValue(self.font.pointSize())
        #self.fontspinBox.setValue(self.font.pixelSize())
        self.fontspinBox.valueChanged.connect(self.onFontsizeChanged)
        self.Fontsize_labeltxt = QLabel()
        self.Fontsize_labeltxt.setText("Font size:")

        self.cameraPerspectCheckBox = QCheckBox()
        self.cameraPerspectCheckBox.setText("Perspective camera")
        self.cameraPerspectCheckBox.clicked.connect(self.onCameraPerspect)
        self.cameraPerspectCheckBox.setCheckState(Qt.Unchecked)

        self.settingsform = SettingsForm(self)

        self.MillerComboBox = QComboBox()
        self.MillerComboBox.activated.connect(self.onMillerComboSelchange)
        #self.MillerComboBox.setSizeAdjustPolicy(QComboBox.AdjustToContents)

        self.MillerLabel = QLabel()
        self.MillerLabel.setText("Selected HKL Scene")

        self.HKLnameedit = QLineEdit('')
        self.HKLnameedit.setReadOnly(True)
        self.textInfo = QTextEdit()
        self.textInfo.setLineWrapMode(QTextEdit.NoWrap)
        self.textInfo.setReadOnly(True)

        labels = [
            "Label", "Type", "no. of HKLs", "Span of HKLs", "Min Max data",
            "Min Max sigmas", "d_min, d_max", "Symmetry unique", "Anomalous"
        ]
        self.millertable = QTableWidget(0, len(labels))
        self.millertable.setHorizontalHeaderLabels(labels)
        self.millertable.horizontalHeader().setDefaultAlignment(Qt.AlignLeft)
        # don't allow editing this table
        self.millertable.setEditTriggers(QTableWidget.NoEditTriggers)

        self.createExpansionBox()
        self.createFileInfoBox()
        self.CreateSliceTabs()
        self.createRadiiScaleGroupBox()
        self.createBinsBox()
        self.CreateFunctionTabs()

        mainLayout = QGridLayout()
        mainLayout.addWidget(self.FileInfoBox, 0, 0)
        mainLayout.addWidget(self.MillerLabel, 1, 0)
        mainLayout.addWidget(self.MillerComboBox, 2, 0)
        mainLayout.addWidget(self.functionTabWidget, 3, 0)
        mainLayout.addWidget(self.settingsbtn, 4, 0, 1, 1)

        #import code, traceback; code.interact(local=locals(), banner="".join( traceback.format_stack(limit=10) ) )
        if self.UseOSbrowser == False:
            self.BrowserBox = QWebEngineView()
            mainLayout.addWidget(self.BrowserBox, 0, 1, 5, 3)
            self.BrowserBox.setUrl("https://cctbx.github.io/")
            #self.BrowserBox.setUrl("https://webglreport.com/")
            #self.BrowserBox.loadFinished.connect(self.onLoadFinished)
            mainLayout.setColumnStretch(2, 1)

        mainLayout.setRowStretch(0, 1)
        mainLayout.setRowStretch(1, 0)
        mainLayout.setRowStretch(2, 1)
        mainLayout.setRowStretch(3, 1)
        mainLayout.setColumnStretch(4, 0)
        self.setLayout(mainLayout)

        self.setWindowTitle("HKL-Viewer")
        self.cctbxproc = None
        self.LaunchCCTBXPython()
        self.out = None
        self.err = None
        self.comboviewwidth = 0
        self.hklscenes_arrays = []
        self.array_infotpls = []
        self.matching_arrays = []
        self.bin_infotpls = None
        self.bin_opacities = None
        self.html_url = ""
        self.spacegroups = []
        self.info = []
        self.infostr = ""
        self.fileisvalid = False
        self.NewFileLoaded = False
        self.NewHKLscenes = False
        self.updatingNbins = False
        self.binstableitemchanges = False

        self.show()
示例#22
0
    def __init__(self, parent=None, toolbar=False):
        flags = Qt.Window | Qt.WindowTitleHint | Qt.CustomizeWindowHint | Qt.WindowCloseButtonHint
        super().__init__(parent=parent, f=flags)
        self.setWindowTitle(self.tr("SSU Typical Component Chart"))
        self.figure = plt.figure(figsize=(6, 3))
        self.clustering_axes = self.figure.add_subplot(1, 2, 1)
        self.component_axes = self.figure.add_subplot(1, 2, 2)
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        self.main_layout = QGridLayout(self)
        self.main_layout.addWidget(self.toolbar, 0, 0, 1, 4)
        self.main_layout.addWidget(self.canvas, 1, 0, 1, 4)
        if not toolbar:
            self.toolbar.hide()
        self.supported_scales = [("log-linear", self.tr("Log-linear")),
                                 ("log", self.tr("Log")),
                                 ("phi", self.tr("φ")),
                                 ("linear", self.tr("Linear"))]
        self.AXIS_LIST = [
            self.tr("Mean [φ]"),
            self.tr("Standard deviation [φ]"),
            self.tr("Skewness"),
            self.tr("Kurtosis")
        ]
        self.x_axis_label = QLabel(self.tr("X Axis"))
        self.x_axis_combo_box = QComboBox()
        self.x_axis_combo_box.addItems(self.AXIS_LIST)
        self.y_axis_label = QLabel(self.tr("Y Axis"))
        self.y_axis_combo_box = QComboBox()
        self.y_axis_combo_box.addItems(self.AXIS_LIST)
        self.y_axis_combo_box.setCurrentIndex(1)
        self.main_layout.addWidget(self.x_axis_label, 2, 0)
        self.main_layout.addWidget(self.x_axis_combo_box, 2, 1)
        self.main_layout.addWidget(self.y_axis_label, 3, 0)
        self.main_layout.addWidget(self.y_axis_combo_box, 3, 1)
        self.scale_label = QLabel(self.tr("Scale"))
        self.scale_combo_box = QComboBox()
        self.scale_combo_box.addItems(
            [name for key, name in self.supported_scales])
        self.main_layout.addWidget(self.scale_label, 2, 2)
        self.main_layout.addWidget(self.scale_combo_box, 2, 3)
        self.min_samples_label = QLabel(self.tr("Minimum Samples"))
        self.min_samples_input = QDoubleSpinBox()
        self.min_samples_input.setRange(0.0001, 0.9999)
        self.min_samples_input.setDecimals(4)
        self.min_samples_input.setSingleStep(0.001)
        self.min_samples_input.setValue(0.03)
        self.min_cluster_size_label = QLabel(self.tr("Minimum Cluster Size"))
        self.min_cluster_size_input = QDoubleSpinBox()
        self.min_cluster_size_input.setRange(0.0001, 0.9999)
        self.min_cluster_size_input.setDecimals(4)
        self.min_cluster_size_input.setSingleStep(0.001)
        self.min_cluster_size_input.setValue(0.1)
        self.xi_label = QLabel(self.tr("xi"))
        self.xi_input = QDoubleSpinBox()
        self.xi_input.setRange(0.0001, 0.9999)
        self.xi_input.setDecimals(4)
        self.xi_input.setSingleStep(0.001)
        self.xi_input.setValue(0.05)
        self.main_layout.addWidget(self.min_samples_label, 3, 2)
        self.main_layout.addWidget(self.min_samples_input, 3, 3)
        self.main_layout.addWidget(self.min_cluster_size_label, 4, 0)
        self.main_layout.addWidget(self.min_cluster_size_input, 4, 1)
        self.main_layout.addWidget(self.xi_label, 4, 2)
        self.main_layout.addWidget(self.xi_input, 4, 3)
        self.update_chart_button = QPushButton(self.tr("Update Chart"))
        self.update_chart_button.clicked.connect(self.update_chart)
        self.save_typical_button = QPushButton(self.tr("Save Typical"))
        self.save_typical_button.setEnabled(False)
        self.save_typical_button.clicked.connect(self.on_save_clicked)
        self.main_layout.addWidget(self.update_chart_button, 5, 0, 1, 2)
        self.main_layout.addWidget(self.save_typical_button, 5, 2, 1, 2)

        self.last_results = None  # type: list[SSUResult]
        self.data_to_clustering = None
        self.stacked_components = None
        self.normal_msg = QMessageBox(self)
        self.file_dialog = QFileDialog(parent=self)
示例#23
0
 def init_ui(self):
     self.main_layout = QGridLayout(self)
     # distance
     self.distance_label = QLabel(self.tr("Distance (Loss) Function"))
     self.distance_label.setToolTip(
         self.
         tr("It's the function to calculate the difference (on the contrary, similarity) between two samples."
            ))
     self.distance_combo_box = QComboBox()
     self.distance_combo_box.addItems(built_in_distances)
     self.distance_combo_box.setCurrentText("log10MSE")
     self.distance_combo_box.currentTextChanged.connect(
         self.on_distance_changed)
     self.main_layout.addWidget(self.distance_label, 0, 0)
     self.main_layout.addWidget(self.distance_combo_box, 0, 1)
     # minimizer
     self.minimizer_label = QLabel(self.tr("Minimizer"))
     self.minimizer_label.setToolTip(
         self.
         tr("The algorithm to find the minimum value of the distance function."
            ))
     self.minimizer_combo_box = QComboBox()
     self.minimizer_combo_box.addItems(built_in_minimizers)
     self.minimizer_combo_box.setCurrentText("SLSQP")
     self.main_layout.addWidget(self.minimizer_label, 1, 0)
     self.main_layout.addWidget(self.minimizer_combo_box, 1, 1)
     # try_GO
     self.try_GO_checkbox = QCheckBox(
         self.tr("Try Global Optimization (GO)"))
     self.try_GO_checkbox.setChecked(False)
     self.try_GO_checkbox.setToolTip(
         self.tr("Whether to try global optimization."))
     self.main_layout.addWidget(self.try_GO_checkbox, 2, 0, 1, 2)
     # GO_max_niter
     self.GO_max_niter_label = QLabel(
         self.tr("[GO] Maximum N<sub>iteration</sub>"))
     self.GO_max_niter_label.setToolTip(
         self.
         tr("Maximum number of iterations of global optimization for termination."
            ))
     self.GO_max_niter_input = QSpinBox()
     self.GO_max_niter_input.setRange(0, 10000)
     self.GO_max_niter_input.setValue(100)
     self.main_layout.addWidget(self.GO_max_niter_label, 3, 0)
     self.main_layout.addWidget(self.GO_max_niter_input, 3, 1)
     # GO_success_niter
     self.GO_success_niter_label = QLabel(
         self.tr("[GO] Success N<sub>iteration</sub>"))
     self.GO_success_niter_label.setToolTip(
         self.
         tr("The number of iteration that reaching the same local optimal value for termination."
            ))
     self.GO_success_niter_input = QSpinBox()
     self.GO_success_niter_input.setRange(1, 100)
     self.GO_success_niter_input.setValue(5)
     self.main_layout.addWidget(self.GO_success_niter_label, 4, 0)
     self.main_layout.addWidget(self.GO_success_niter_input, 4, 1)
     # GO_step
     self.GO_step_label = QLabel(self.tr("[GO] Step Size"))
     self.GO_step_label.setToolTip(
         self.tr("The step size of searching global optimal value."))
     self.GO_step_input = QDoubleSpinBox()
     self.GO_step_input.setRange(0.01, 10)
     self.GO_step_input.setValue(0.1)
     self.main_layout.addWidget(self.GO_step_label, 5, 0)
     self.main_layout.addWidget(self.GO_step_input, 5, 1)
     # GO_minimizer_tol
     self.GO_minimizer_tol_label = QLabel(
         self.tr("[GO] Minimizer -lg(loss<sub>tolerance</sub>)"))
     self.GO_minimizer_tol_label.setToolTip(
         self.
         tr("Controls the tolerance of the loss function for termination."))
     self.GO_minimizer_tol_input = QSpinBox()
     self.GO_minimizer_tol_input.setRange(1, 100)
     self.GO_minimizer_tol_input.setValue(6)
     self.main_layout.addWidget(self.GO_minimizer_tol_label, 6, 0)
     self.main_layout.addWidget(self.GO_minimizer_tol_input, 6, 1)
     # GO_minimizer_ftol
     self.GO_minimizer_ftol_label = QLabel(
         self.tr("[GO] Minimizer -lg(δ<sub>loss</sub>)"))
     self.GO_minimizer_ftol_label.setToolTip(
         self.
         tr("Controls the precision goal for the value of loss function in the stopping criterion."
            ))
     self.GO_minimizer_ftol_input = QSpinBox()
     self.GO_minimizer_ftol_input.setRange(1, 100)
     self.GO_minimizer_ftol_input.setValue(8)
     self.main_layout.addWidget(self.GO_minimizer_ftol_label, 7, 0)
     self.main_layout.addWidget(self.GO_minimizer_ftol_input, 7, 1)
     # GO_minimizer_max_niter
     self.GO_minimizer_max_niter_label = QLabel(
         self.tr("[GO] Minimizer Maximum N<sub>iteration</sub>"))
     self.GO_minimizer_max_niter_label.setToolTip(
         self.
         tr("Maximum number of iterations of the minimizer of global optimization."
            ))
     self.GO_minimizer_max_niter_input = QSpinBox()
     self.GO_minimizer_max_niter_input.setRange(0, 100000)
     self.GO_minimizer_max_niter_input.setValue(500)
     self.main_layout.addWidget(self.GO_minimizer_max_niter_label, 8, 0)
     self.main_layout.addWidget(self.GO_minimizer_max_niter_input, 8, 1)
     # FLO_tol
     self.FLO_tol_label = QLabel(
         self.tr("[FLO] -lg(loss<sub>tolerance</sub>)"))
     self.FLO_tol_label.setToolTip(
         self.
         tr("Controls the tolerance of the loss function for termination."))
     self.FLO_tol_input = QSpinBox()
     self.FLO_tol_input.setRange(1, 100)
     self.FLO_tol_input.setValue(8)
     self.main_layout.addWidget(self.FLO_tol_label, 9, 0)
     self.main_layout.addWidget(self.FLO_tol_input, 9, 1)
     # FLO_ftol
     self.FLO_ftol_label = QLabel(self.tr("[FLO] -lg(δ<sub>loss</sub>)"))
     self.FLO_ftol_label.setToolTip(
         self.
         tr("Controls the precision goal for the value of loss function in the stopping criterion."
            ))
     self.FLO_ftol_input = QSpinBox()
     self.FLO_ftol_input.setRange(1, 100)
     self.FLO_ftol_input.setValue(10)
     self.main_layout.addWidget(self.FLO_ftol_label, 10, 0)
     self.main_layout.addWidget(self.FLO_ftol_input, 10, 1)
     # FLO_max_niter
     self.FLO_max_niter_label = QLabel(
         self.tr("[FLO] Maximum N<sub>iteration</sub>"))
     self.FLO_max_niter_label.setToolTip(
         self.
         tr("Maximum number of iterations of the minimizer of final local optimization."
            ))
     self.FLO_max_niter_input = QSpinBox()
     self.FLO_max_niter_input.setRange(100, 100000)
     self.FLO_max_niter_input.setValue(1000)
     self.main_layout.addWidget(self.FLO_max_niter_label, 11, 0)
     self.main_layout.addWidget(self.FLO_max_niter_input, 11, 1)
示例#24
0
    def __init__(self, prefs, icon=None):
        super().__init__()
        self.prefs = prefs
        self.hotkey_format_regex = r'^\<ctrl\>\+\<alt\>(\+\<shift\>)?\+[a-zA-Z0-9]$'
        if icon:
            self.setWindowIcon(icon)

        # checkbox: Include Minimized
        include_minimized = QCheckBox()
        include_minimized.setFixedWidth(35)
        include_minimized.setChecked(self.prefs["include_minimized"]["value"])
        include_minimized.stateChanged.connect(
            lambda: self.include_minimized(include_minimized.isChecked()))
        include_minimized_descr = QLabel(
            self.prefs["include_minimized"]["description"])
        include_minimized_descr.setWordWrap(True)

        include_minimized_layout = QHBoxLayout()
        include_minimized_layout.addWidget(include_minimized)
        include_minimized_layout.addWidget(include_minimized_descr)

        include_minimized_groupbox = QGroupBox("Include Minimized")
        include_minimized_groupbox.setLayout(include_minimized_layout)

        # checkbox: snap to grid
        snap_to_grid = QCheckBox()
        snap_to_grid.setFixedWidth(35)
        snap_to_grid.setChecked(self.prefs["snap_to_grid"]["value"])
        snap_to_grid.stateChanged.connect(
            lambda: self.snap_to_grid(snap_to_grid.isChecked()))
        snap_to_grid_descr = QLabel(self.prefs["snap_to_grid"]["description"])
        snap_to_grid_descr.setWordWrap(True)

        snap_to_grid_layout = QHBoxLayout()
        snap_to_grid_layout.addWidget(snap_to_grid)
        snap_to_grid_layout.addWidget(snap_to_grid_descr)

        snap_to_grid_groupbox = QGroupBox("Snap To Grid")
        snap_to_grid_groupbox.setLayout(snap_to_grid_layout)

        # checkbox: fit into screen
        fit_into_screen = QCheckBox()
        fit_into_screen.setFixedWidth(35)
        fit_into_screen.setChecked(self.prefs["fit_into_screen"]["value"])
        fit_into_screen.stateChanged.connect(
            lambda: self.fit_into_screen(fit_into_screen.isChecked()))
        fit_into_screen_descr = QLabel(
            self.prefs["fit_into_screen"]["description"])
        fit_into_screen_descr.setWordWrap(True)

        fit_into_screen_layout = QHBoxLayout()
        fit_into_screen_layout.addWidget(fit_into_screen)
        fit_into_screen_layout.addWidget(fit_into_screen_descr)

        fit_into_screen_groupbox = QGroupBox("Fit Into Screen")
        fit_into_screen_groupbox.setLayout(fit_into_screen_layout)

        # doublespinBox: match cutoff
        match_cutoff = QDoubleSpinBox()
        match_cutoff.setFixedWidth(35)
        match_cutoff.setValue(self.prefs["match_cutoff"]["value"])
        match_cutoff.setRange(0.1, 1.0)
        match_cutoff.setSingleStep(0.1)
        match_cutoff.setDecimals(1)
        match_cutoff.valueChanged.connect(
            lambda: self.match_cutoff(match_cutoff.value()))
        match_cutoff_descr = QLabel(self.prefs["match_cutoff"]["description"])
        match_cutoff_descr.setWordWrap(True)

        match_cutoff_layout = QHBoxLayout()
        match_cutoff_layout.addWidget(match_cutoff)
        match_cutoff_layout.addWidget(match_cutoff_descr)

        match_cutoff_groupbox = QGroupBox("Match Cutoff")
        match_cutoff_groupbox.setLayout(match_cutoff_layout)

        # checkbox: enable hotkeys
        enable_hotkeys = QCheckBox()
        enable_hotkeys.setFixedWidth(35)
        enable_hotkeys.setChecked(self.prefs["enable_hotkeys"]["value"])
        enable_hotkeys.stateChanged.connect(
            lambda: self.enable_hotkeys(enable_hotkeys.isChecked()))
        enable_hotkeys_descr = QLabel(
            self.prefs["enable_hotkeys"]["description"])
        enable_hotkeys_descr.setWordWrap(True)

        enable_hotkeys_layout = QHBoxLayout()
        enable_hotkeys_layout.addWidget(enable_hotkeys)
        enable_hotkeys_layout.addWidget(enable_hotkeys_descr)

        # lineedit: hotkeys shortcuts
        hotkey_freeze_new_name = QLabel("Freeze New:")
        hotkey_freeze_new_name.setFixedWidth(75)
        self.hotkey_freeze_new_status = QLabel()
        self.hotkey_freeze_new = QLineEdit(
            self.prefs["hotkeys"]["value"]["freeze_new"])
        self.hotkey_freeze_new.setFixedWidth(140)
        self.hotkey_freeze_new.editingFinished.connect(
            lambda: self.hotkey_freeze_new_update(self.hotkey_freeze_new.text(
            )))
        self.hotkey_freeze_new.cursorPositionChanged.connect(
            self.hotkey_freeze_new_status.clear)

        hotkey_freeze_new_layout = QHBoxLayout()
        hotkey_freeze_new_layout.addWidget(hotkey_freeze_new_name)
        hotkey_freeze_new_layout.addWidget(self.hotkey_freeze_new)
        hotkey_freeze_new_layout.addWidget(self.hotkey_freeze_new_status)

        hotkey_freeze_all_name = QLabel("Freeze All:")
        hotkey_freeze_all_name.setFixedWidth(75)
        self.hotkey_freeze_all_status = QLabel()
        self.hotkey_freeze_all = QLineEdit(
            self.prefs["hotkeys"]["value"]["freeze_all"])
        self.hotkey_freeze_all.setFixedWidth(140)
        self.hotkey_freeze_all.editingFinished.connect(
            lambda: self.hotkey_freeze_all_update(self.hotkey_freeze_all.text(
            )))
        self.hotkey_freeze_all.cursorPositionChanged.connect(
            self.hotkey_freeze_all_status.clear)

        hotkey_freeze_all_layout = QHBoxLayout()
        hotkey_freeze_all_layout.addWidget(hotkey_freeze_all_name)
        hotkey_freeze_all_layout.addWidget(self.hotkey_freeze_all)
        hotkey_freeze_all_layout.addWidget(self.hotkey_freeze_all_status)

        hotkey_restore_name = QLabel("Restore:")
        hotkey_restore_name.setFixedWidth(75)
        self.hotkey_restore_status = QLabel()
        self.hotkey_restore = QLineEdit(
            self.prefs["hotkeys"]["value"]["restore"])
        self.hotkey_restore.setFixedWidth(140)
        self.hotkey_restore.editingFinished.connect(
            lambda: self.hotkey_restore_update(self.hotkey_restore.text()))
        self.hotkey_restore.cursorPositionChanged.connect(
            self.hotkey_restore_status.clear)

        hotkey_restore_layout = QHBoxLayout()
        hotkey_restore_layout.addWidget(hotkey_restore_name)
        hotkey_restore_layout.addWidget(self.hotkey_restore)
        hotkey_restore_layout.addWidget(self.hotkey_restore_status)

        self.hotkeys_statusbar = QLabel()
        self.hotkeys_statusbar.setWordWrap(True)
        self.hotkeys_statusbar.setText(hotkeys_statusbar_map[
            self.prefs['enable_hotkeys']['value']]['text'])
        self.hotkeys_statusbar.setStyleSheet(hotkeys_statusbar_map[
            self.prefs['enable_hotkeys']['value']]['style'])

        close_button = QPushButton("Close")
        close_button.setMaximumWidth(75)
        close_button.clicked.connect(self.close)

        hotkeys_statusbar_layout = QHBoxLayout()
        hotkeys_statusbar_layout.addWidget(self.hotkeys_statusbar)
        hotkeys_statusbar_layout.addWidget(close_button)

        hotkeys_layout = QVBoxLayout()
        hotkeys_layout.addLayout(hotkey_freeze_new_layout)
        hotkeys_layout.addLayout(hotkey_freeze_all_layout)
        hotkeys_layout.addLayout(hotkey_restore_layout)

        self.hotkeys_groupbox = QGroupBox()
        self.hotkeys_groupbox.setFlat(True)
        self.hotkeys_groupbox.setDisabled(
            not self.prefs["enable_hotkeys"]["value"])
        self.hotkeys_groupbox.setLayout(hotkeys_layout)

        enable_hotkeys_outer_layout = QVBoxLayout()
        enable_hotkeys_outer_layout.addLayout(enable_hotkeys_layout)
        enable_hotkeys_outer_layout.addWidget(self.hotkeys_groupbox)

        enable_hotkeys_groupbox = QGroupBox("Enable Hotkeys")
        enable_hotkeys_groupbox.setLayout(enable_hotkeys_outer_layout)

        # Create main layout and add widgets
        main_layout = QVBoxLayout()
        main_layout.addWidget(include_minimized_groupbox)
        main_layout.addWidget(snap_to_grid_groupbox)
        main_layout.addWidget(fit_into_screen_groupbox)
        main_layout.addWidget(match_cutoff_groupbox)
        main_layout.addWidget(enable_hotkeys_groupbox)
        main_layout.addWidget(self.hotkeys_groupbox)
        #main_layout.addWidget(hotkeys_statusbar_groupbox)
        main_layout.addLayout(hotkeys_statusbar_layout)
        self.setLayout(main_layout)
示例#25
0
    def __init_slicer_options_widget__(self):
        self.__slicer_options_widget = QGroupBox("Slicer Options", self)

        thickness_label = QLabel("Layer Thickness",
                                 self.__slicer_options_widget)
        thickness_edit = QDoubleSpinBox(self.__slicer_options_widget)
        thickness_edit.setSuffix(str('\u03BCm'))
        thickness_edit.setMaximum(1000000)
        thickness_edit.setMinimum(0)
        thickness_edit.setDecimals(3)
        thickness_edit.setSingleStep(0.001)
        thickness_edit.setValue(self.dlp_controller.support_thickness * 1000)
        # self.__opengl_widget.set_slice_thickness(self.dlp_controller.support_thickness)
        thickness_edit.valueChanged.connect(
            self.__slicer_widget.set_slice_thickness)

        pixel_size_label = QLabel("Projector Pixel Size",
                                  self.__slicer_options_widget)
        pixel_size_edit = QDoubleSpinBox(self.__slicer_options_widget)
        pixel_size_edit.setSuffix(str('\u03BCm'))
        pixel_size_edit.setMaximum(1000000)
        pixel_size_edit.setMinimum(0)
        pixel_size_edit.setDecimals(2)
        pixel_size_edit.setSingleStep(0.01)
        pixel_size_edit.setValue(self.dlp_controller.projector_pixel_size *
                                 1000)
        pixel_size_edit.valueChanged.connect(
            self.__slicer_widget.set_pixel_size)

        projector_resolution_label = QLabel("Projector Resolution",
                                            self.__slicer_options_widget)
        projector_resolution_edit_x = QSpinBox(self.__slicer_options_widget)
        projector_resolution_edit_x.setSuffix(str('W'))
        projector_resolution_edit_x.setMaximum(1000000)
        projector_resolution_edit_x.setMinimum(0)
        projector_resolution_edit_x.setValue(
            self.dlp_controller.projector_width)
        projector_resolution_edit_x.valueChanged.connect(
            self.__slicer_widget.set_projector_width)
        projector_resolution_edit_y = QSpinBox(self.__slicer_options_widget)
        projector_resolution_edit_y.setSuffix(str('H'))
        projector_resolution_edit_y.setMaximum(1000000)
        projector_resolution_edit_y.setMinimum(0)
        projector_resolution_edit_y.setValue(
            self.dlp_controller.projector_height)
        projector_resolution_edit_y.valueChanged.connect(
            self.__slicer_widget.set_projector_height)

        samples_per_pixel_label = QLabel("Samples per Pixel",
                                         self.__slicer_options_widget)
        samples_per_pixel_edit = QSpinBox(self.__slicer_options_widget)
        samples_per_pixel_edit.setMaximum(1000000)
        samples_per_pixel_edit.setMinimum(1)
        samples_per_pixel_edit.setValue(self.dlp_controller.samples_per_pixel)
        samples_per_pixel_edit.valueChanged.connect(
            self.__slicer_widget.set_samples_per_pixel)

        slice_geometry_button = QPushButton("Slice Geometry")
        slice_geometry_button.clicked.connect(self.start_slicing_process)

        slice_interrupt_button = QPushButton("Stop Slicing")
        slice_interrupt_button.clicked.connect(
            self.__slicer_widget.interrupt_slicing)

        self.slices_label = QLabel(f'Slicing progress: {0:.0f}/{0:.0f}',
                                   self.__info_widget)

        thickness_label_row = 0
        pixel_size_row = 1
        projector_resolution_row = 2
        samples_per_pixel_row = 3
        slice_button_row = 4
        slices_label_row = 5
        # slice_interrupt_row = slice_button_row

        slice_layout = QGridLayout(self.__slicer_options_widget)
        slice_layout.addWidget(thickness_label, thickness_label_row, 0)
        slice_layout.addWidget(thickness_edit, thickness_label_row, 1)
        slice_layout.addWidget(pixel_size_label, pixel_size_row, 0)
        slice_layout.addWidget(pixel_size_edit, pixel_size_row, 1)
        slice_layout.addWidget(projector_resolution_label,
                               projector_resolution_row, 0)
        slice_layout.addWidget(projector_resolution_edit_x,
                               projector_resolution_row, 1)
        slice_layout.addWidget(projector_resolution_edit_y,
                               projector_resolution_row, 2)
        slice_layout.addWidget(self.slices_label, slice_button_row, 0)
        slice_layout.addWidget(slice_geometry_button, slice_button_row, 1)
        slice_layout.addWidget(slice_interrupt_button, slice_button_row, 2)
        slice_layout.addWidget(samples_per_pixel_label, samples_per_pixel_row,
                               0)
        slice_layout.addWidget(samples_per_pixel_edit, samples_per_pixel_row,
                               1)
        self.__slicer_options_widget.setLayout(slice_layout)
示例#26
0
    def __init__(self, parent=None):
        super().__init__(parent)

        # setup settings for the class
        self.settings = QSettings()
        self.settings.beginGroup("plot_control")

        self.base_vector_data = vpype.VectorData()
        self.vector_data: vpype.VectorData = None

        # settings
        self.page_format: str = self.settings.value("page_format", "A4")
        self.landscape: bool = self.settings.value("landscape", False)
        self.rotated: bool = self.settings.value("rotate", False)
        self.rotated: bool = self.settings.value("rotated", False)
        self.center: bool = self.settings.value("center", True)
        self.fit_page: bool = self.settings.value("fit_page", False)
        self.margin_value: float = self.settings.value("margin_value", 2.0)
        self.margin_unit: str = self.settings.value("margin_unit", "cm")

        # setup plot area
        self.plot = VectorDataPlotWidget()
        self.plot.setSizePolicy(
            QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))

        # page layout controls
        page_box = QGroupBox("Page layout")
        page_layout = QFormLayout()
        page_format_combo = QComboBox()
        for k in PAGE_FORMATS:
            page_format_combo.addItem(k)
        page_format_combo.setCurrentText(self.page_format)
        page_format_combo.currentTextChanged.connect(
            lambda text: self.set_page_format(text))
        landscape_check = QCheckBox("Landscape")
        landscape_check.setChecked(self.landscape)
        landscape_check.stateChanged.connect(
            lambda: self.set_landscape(landscape_check.isChecked()))
        rotated_check = QCheckBox("Rotated")
        rotated_check.setChecked(self.landscape)
        rotated_check.stateChanged.connect(
            lambda: self.set_rotated(rotated_check.isChecked()))
        center_check = QCheckBox("Center on page")
        center_check.setChecked(self.center)
        center_check.stateChanged.connect(
            lambda: self.set_center(center_check.isChecked()))
        fit_page_check = QCheckBox("Fit to page")
        fit_page_check.setChecked(self.fit_page)
        fit_page_check.stateChanged.connect(
            lambda: self.set_fit_page(fit_page_check.isChecked()))
        margin_layout = QHBoxLayout()
        margin_spin = QDoubleSpinBox()
        margin_spin.setValue(self.margin_value)
        margin_spin.valueChanged.connect(lambda: self.set_margin(
            margin_spin.value(), margin_unit.currentText()))
        margin_unit = UnitComboBox()
        margin_unit.setCurrentText(self.margin_unit)
        margin_unit.currentTextChanged.connect(lambda: self.set_margin(
            margin_spin.value(), margin_unit.currentText()))
        margin_layout.addWidget(margin_spin)
        margin_layout.addWidget(margin_unit)
        page_layout.addRow("Page format:", page_format_combo)
        page_layout.addRow("", landscape_check)
        page_layout.addRow("", rotated_check)
        page_layout.addRow("", center_check)
        page_layout.addRow("", fit_page_check)
        page_layout.addRow("Margin:", margin_layout)
        page_box.setLayout(page_layout)

        # Action buttons
        pen_up_btn = QPushButton("UP")
        pen_down_btn = QPushButton("DOWN")
        pen_up_btn.clicked.connect(lambda: axy.pen_up())
        pen_down_btn.clicked.connect(lambda: axy.pen_down())
        pen_up_spin = AxySettingsSpinBox(self.settings, "pen_pos_up", 60.0)
        pen_down_spin = AxySettingsSpinBox(self.settings, "pen_pos_down", 40.0)
        pen_up_layout = QHBoxLayout()
        pen_up_layout.addWidget(pen_up_spin)
        pen_up_layout.addWidget(pen_up_btn)
        pen_down_layout = QHBoxLayout()
        pen_down_layout.addWidget(pen_down_spin)
        pen_down_layout.addWidget(pen_down_btn)
        shutdown_btn = QPushButton("OFF")
        shutdown_btn.clicked.connect(lambda: axy.shutdown())
        plot_btn = QPushButton("PLOT")
        plot_btn.clicked.connect(lambda: self.plot_svg())
        action_box = QGroupBox("Actions")
        action_layout = QFormLayout()
        action_layout.addRow("Pen up: ", pen_up_layout)
        action_layout.addRow("Pen down: ", pen_down_layout)
        action_layout.addRow("Motor off:", shutdown_btn)
        action_layout.addRow("Plot:", plot_btn)
        action_box.setLayout(action_layout)

        self.list = QListView()
        self.list.setFixedHeight(120)
        self.list.setSizePolicy(
            QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))

        # controls layout
        controls_layout = QVBoxLayout()
        controls_layout.addWidget(self.list)
        controls_layout.addWidget(page_box)
        controls_layout.addWidget(action_box)
        controls_layout.addItem(
            QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding))

        # setup layout
        root_layout = QHBoxLayout()
        root_layout.addWidget(self.plot)
        root_layout.addLayout(controls_layout)
        self.setLayout(root_layout)

        self.update_view()

        # FIXME: stub vector data
        # vd = vpype.VectorData()
        # vd.add(vpype.LineCollection([(0, 100), (200, 1001 + 201j)]), 1)
        # vd.add(vpype.LineCollection([(0, 100 + 100j), (300j, 400j + 100)]), 2)
        self.load_svg(
            "/Users/hhip/Drive/axidraw/wheel_cards/wheel_card_triple_5_40.svg")
示例#27
0
 def testQRealSignal(self):
     foo1 = QDoubleSpinBox()
     effect = QGraphicsBlurEffect()
     effect.blurRadiusChanged['qreal'].connect(foo1.setValue) # check if qreal is a valid type
     effect.setBlurRadius(0.42)
     self.assertAlmostEqual(foo1.value(), effect.blurRadius())
示例#28
0
    def __init__(self, parent=None):
        super(MainWidget, self).__init__(parent)
        self.chart = QtCharts.QChart()
        self.series = QtCharts.QBarSeries()

        self.main_layout = QGridLayout()
        self.button_layout = QGridLayout()
        self.font_layout = QFormLayout()

        self.font_size = QDoubleSpinBox()

        self.legend_posx = QDoubleSpinBox()
        self.legend_posy = QDoubleSpinBox()
        self.legend_width = QDoubleSpinBox()
        self.legend_height = QDoubleSpinBox()

        self.detach_legend_button = QPushButton("Toggle attached")
        self.detach_legend_button.clicked.connect(self.toggle_attached)
        self.button_layout.addWidget(self.detach_legend_button, 0, 0)

        self.add_set_button = QPushButton("add barset")
        self.add_set_button.clicked.connect(self.add_barset)
        self.button_layout.addWidget(self.add_set_button, 2, 0)

        self.remove_barset_button = QPushButton("remove barset")
        self.remove_barset_button.clicked.connect(self.remove_barset)
        self.button_layout.addWidget(self.remove_barset_button, 3, 0)

        self.align_button = QPushButton("Align (Bottom)")
        self.align_button.clicked.connect(self.set_legend_alignment)
        self.button_layout.addWidget(self.align_button, 4, 0)

        self.bold_button = QPushButton("Toggle bold")
        self.bold_button.clicked.connect(self.toggle_bold)
        self.button_layout.addWidget(self.bold_button, 8, 0)

        self.italic_button = QPushButton("Toggle italic")
        self.italic_button.clicked.connect(self.toggle_italic)
        self.button_layout.addWidget(self.italic_button, 9, 0)

        self.legend_posx.valueChanged.connect(self.update_legend_layout)
        self.legend_posy.valueChanged.connect(self.update_legend_layout)
        self.legend_width.valueChanged.connect(self.update_legend_layout)
        self.legend_height.valueChanged.connect(self.update_legend_layout)

        legend_layout = QFormLayout()
        legend_layout.addRow("HPos", self.legend_posx)
        legend_layout.addRow("VPos", self.legend_posy)
        legend_layout.addRow("Width", self.legend_width)
        legend_layout.addRow("Height", self.legend_height)

        self.legend_settings = QGroupBox("Detached legend")
        self.legend_settings.setLayout(legend_layout)
        self.button_layout.addWidget(self.legend_settings)
        self.legend_settings.setVisible(False)

        # Create chart view with the chart
        self.chart_view = QtCharts.QChartView(self.chart, self)

        # Create spinbox to modify font size
        self.font_size.setValue(self.chart.legend().font().pointSizeF())
        self.font_size.valueChanged.connect(self.font_size_changed)

        self.font_layout.addRow("Legend font size", self.font_size)

        # Create layout for grid and detached legend
        self.main_layout.addLayout(self.button_layout, 0, 0)
        self.main_layout.addLayout(self.font_layout, 1, 0)
        self.main_layout.addWidget(self.chart_view, 0, 1, 3, 1)
        self.setLayout(self.main_layout)

        self.create_series()
示例#29
0
 def __init_projector_widget__(self, parent=None):
     self.__projector_widget = QGroupBox("Projector Options", parent)
     # self.__projector_widget.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum)
     mirror_x = QCheckBox("Mirror X")
     mirror_x.setChecked(self.dlp_controller.is_horizontal_mirrored())
     mirror_x.toggled.connect(self.dlp_controller.set_horizontal_mirroring)
     mirror_y = QCheckBox("Mirror Y")
     mirror_y.setChecked(self.dlp_controller.is_vertical_mirrored())
     mirror_y.toggled.connect(self.dlp_controller.set_vertical_mirroring)
     start_projector_button = QPushButton("Start Projector",
                                          self.__projector_widget)
     start_projector_button.clicked.connect(
         self.dlp_controller.start_projector)
     project_pattern_button = QPushButton("Project Pattern",
                                          self.__projector_widget)
     project_pattern_button.clicked.connect(
         self.dlp_controller.project_calibration_pattern)
     print_position_button = QPushButton("Print Position",
                                         self.__projector_widget)
     print_position_button.clicked.connect(
         self.dlp_controller.print_motor_position)
     home_projector_button = QPushButton("Home Projector",
                                         self.__projector_widget)
     home_projector_button.clicked.connect(
         self.dlp_controller.home_projector)
     move_projector_button = QPushButton("Move Projector",
                                         self.__projector_widget)
     move_projector_button.clicked.connect(
         self.dlp_controller.move_projector)
     move_projector_edit = QDoubleSpinBox(self.__projector_widget)
     move_projector_edit.setSuffix("mm")
     move_projector_edit.setMaximum(10000)
     move_projector_edit.setMinimum(-10000)
     move_projector_edit.setDecimals(3)
     move_projector_edit.setSingleStep(0.001)
     move_projector_edit.valueChanged.connect(
         self.dlp_controller.update_projector_distance)
     set_amplitude_button = QPushButton("Set Projector Amplitude",
                                        self.__projector_widget)
     set_amplitude_button.clicked.connect(
         self.dlp_controller.set_projector_amplitude)
     set_amplitude_edit = QSpinBox(self.__projector_widget)
     set_amplitude_edit.setMaximum(1000)
     set_amplitude_edit.setMinimum(0)
     set_amplitude_edit.setValue(self.dlp_controller.projector_amplitude)
     set_amplitude_edit.valueChanged.connect(
         self.dlp_controller.update_projector_amplitude)
     lock_unlock_projector_button = QPushButton("Lock/Unlock Projector",
                                                self.__projector_widget)
     lock_unlock_projector_button.clicked.connect(
         self.dlp_controller.lock_unlock_projector)
     projector_layout = QGridLayout(self.__projector_widget)
     # projector_layout.addWidget(projector_label, 0, 0)
     projector_layout.addWidget(mirror_x, 0, 1)
     projector_layout.addWidget(mirror_y, 0, 2)
     projector_layout.addWidget(start_projector_button, 1, 0, 1, 1)
     projector_layout.addWidget(project_pattern_button, 1, 1, 1, 1)
     projector_layout.addWidget(print_position_button, 1, 2, 1, 1)
     projector_layout.addWidget(home_projector_button, 2, 0, 1, 1)
     projector_layout.addWidget(move_projector_button, 2, 1, 1, 1)
     projector_layout.addWidget(move_projector_edit, 2, 2)
     projector_layout.addWidget(set_amplitude_button, 3, 0, 1, 1)
     projector_layout.addWidget(set_amplitude_edit, 3, 1)
     projector_layout.addWidget(lock_unlock_projector_button, 3, 2, 1, 1)
     self.__projector_widget.setLayout(projector_layout)
示例#30
0
    def __init__(self):
        super().__init__()

        hlayout = QHBoxLayout()

        layout = QVBoxLayout()

        self.filtert = QLineEdit()
        self.filtert.setPlaceholderText("Search...")
        self.table = QTableView()

        vlayout = QVBoxLayout()
        vlayout.addWidget(self.filtert)
        vlayout.addWidget(self.table)

        # Left/right pane.
        hlayout.addLayout(vlayout)
        hlayout.addLayout(layout)

        form = QFormLayout()

        self.track_id = QSpinBox()
        self.track_id.setDisabled(True)
        self.track_id.setRange(0, 2147483647)
        self.name = QLineEdit()
        self.album = QComboBox()
        self.media_type = QComboBox()
        self.genre = QComboBox()
        self.composer = QLineEdit()

        self.milliseconds = QSpinBox()
        self.milliseconds.setRange(0, 2147483647)
        self.milliseconds.setSingleStep(1)

        self.bytes = QSpinBox()
        self.bytes.setRange(0, 2147483647)
        self.bytes.setSingleStep(1)

        self.unit_price = QDoubleSpinBox()
        self.unit_price.setRange(0, 999)
        self.unit_price.setSingleStep(0.01)
        self.unit_price.setPrefix("$")

        form.addRow(QLabel("Track ID"), self.track_id)
        form.addRow(QLabel("Track name"), self.name)
        form.addRow(QLabel("Composer"), self.composer)
        form.addRow(QLabel("Milliseconds"), self.milliseconds)
        form.addRow(QLabel("Bytes"), self.bytes)
        form.addRow(QLabel("Unit Price"), self.unit_price)

        self.model = QSqlTableModel(db=db)

        self.proxy_model = QSortFilterProxyModel()
        self.proxy_model.setSourceModel(self.model)
        self.proxy_model.sort(1, Qt.AscendingOrder)
        self.proxy_model.setFilterKeyColumn(-1)  # all columns
        self.table.setModel(self.proxy_model)

        # Update search when filter changes.
        self.filtert.textChanged.connect(self.proxy_model.setFilterFixedString)

        self.mapper = QDataWidgetMapper()
        self.mapper.setModel(self.proxy_model)

        self.mapper.addMapping(self.track_id, 0)
        self.mapper.addMapping(self.name, 1)
        self.mapper.addMapping(self.composer, 5)
        self.mapper.addMapping(self.milliseconds, 6)
        self.mapper.addMapping(self.bytes, 7)
        self.mapper.addMapping(self.unit_price, 8)

        self.model.setTable("Track")
        self.model.select()

        # Change the mapper selection using the table.
        self.table.selectionModel().currentRowChanged.connect(
            self.mapper.setCurrentModelIndex)

        self.mapper.toFirst()

        # tag::controls[]
        self.setMinimumSize(QSize(800, 400))

        controls = QHBoxLayout()

        prev_rec = QPushButton("Previous")
        prev_rec.clicked.connect(self.mapper.toPrevious)

        next_rec = QPushButton("Next")
        next_rec.clicked.connect(self.mapper.toNext)

        save_rec = QPushButton("Save Changes")
        save_rec.clicked.connect(self.mapper.submit)

        controls.addWidget(prev_rec)
        controls.addWidget(next_rec)
        controls.addWidget(save_rec)

        layout.addLayout(form)
        layout.addLayout(controls)

        widget = QWidget()
        widget.setLayout(hlayout)
        self.setCentralWidget(widget)