Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):
        super(StartValuesGroupBox, self).__init__('Start values', *args,
                                                  **kwargs)

        self._layout = QtWidgets.QVBoxLayout(self)

        self._grid_layout1 = QtWidgets.QGridLayout()

        self._grid_layout1.addWidget(LabelAlignRight('Distance:'), 0, 0)
        self.distance_txt = NumberTextField('200')
        self.distance_cb = QtWidgets.QCheckBox()
        self.distance_cb.setChecked(True)
        self._grid_layout1.addWidget(self.distance_txt, 0, 1)
        self._grid_layout1.addWidget(QtWidgets.QLabel('mm'), 0, 2)
        self._grid_layout1.addWidget(self.distance_cb, 0, 3)

        self._grid_layout1.addWidget(LabelAlignRight('Wavelength:'), 1, 0)
        self.wavelength_txt = NumberTextField('0.3344')
        self.wavelength_cb = QtWidgets.QCheckBox()
        self._grid_layout1.addWidget(self.wavelength_txt, 1, 1)
        self._grid_layout1.addWidget(QtWidgets.QLabel('A'), 1, 2)
        self._grid_layout1.addWidget(self.wavelength_cb, 1, 3)

        self._grid_layout1.addWidget(LabelAlignRight('Polarization:'), 2, 0)
        self.polarization_txt = NumberTextField('0.99')
        self._grid_layout1.addWidget(self.polarization_txt, 2, 1)

        self._grid_layout1.addWidget(LabelAlignRight('Pixel width:'), 3, 0)
        self.pixel_width_txt = NumberTextField('72')
        self._grid_layout1.addWidget(self.pixel_width_txt, 3, 1)
        self._grid_layout1.addWidget(QtWidgets.QLabel('um'))

        self._grid_layout1.addWidget(LabelAlignRight('Pixel height:'), 4, 0)
        self.pixel_height_txt = NumberTextField('72')
        self._grid_layout1.addWidget(self.pixel_height_txt, 4, 1)
        self._grid_layout1.addWidget(QtWidgets.QLabel('um'))

        self._grid_layout1.addWidget(LabelAlignRight('Calibrant:'), 5, 0)
        self.calibrant_cb = CleanLooksComboBox()
        self._grid_layout1.addWidget(self.calibrant_cb, 5, 1, 1, 2)

        self._grid_layout2 = QtWidgets.QGridLayout()
        self._grid_layout2.setSpacing(6)

        self.rotate_p90_btn = FlatButton('Rotate +90')
        self.rotate_m90_btn = FlatButton('Rotate -90', self)
        self._grid_layout2.addWidget(self.rotate_p90_btn, 1, 0)
        self._grid_layout2.addWidget(self.rotate_m90_btn, 1, 1)

        self.flip_horizontal_btn = FlatButton('Flip horizontal', self)
        self.flip_vertical_btn = FlatButton('Flip vertical', self)
        self._grid_layout2.addWidget(self.flip_horizontal_btn, 2, 0)
        self._grid_layout2.addWidget(self.flip_vertical_btn, 2, 1)

        self.reset_transformations_btn = FlatButton('Reset transformations',
                                                    self)
        self._grid_layout2.addWidget(self.reset_transformations_btn, 3, 0, 1,
                                     2)

        self._layout.addLayout(self._grid_layout1)
        self._layout.addLayout(self._grid_layout2)

        self.setLayout(self._layout)
Exemplo n.º 2
0
    def setupUi(self, SearcherSettings):
        SearcherSettings.setObjectName("SearcherSettings")
        SearcherSettings.setWindowModality(QtCore.Qt.NonModal)
        SearcherSettings.resize(450, 211)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(SearcherSettings.sizePolicy().hasHeightForWidth())
        SearcherSettings.setSizePolicy(sizePolicy)
        SearcherSettings.setMinimumSize(QtCore.QSize(450, 0))
        SearcherSettings.setBaseSize(QtCore.QSize(0, 0))
        SearcherSettings.setStyleSheet("")
        self.gridLayout = QtWidgets.QGridLayout(SearcherSettings)
        self.gridLayout.setContentsMargins(-1, -1, -1, 6)
        self.gridLayout.setSpacing(6)
        self.gridLayout.setObjectName("gridLayout")
        self.verticalLayout_4 = QtWidgets.QVBoxLayout()
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.headerrow = QtWidgets.QHBoxLayout()
        self.headerrow.setObjectName("headerrow")
        self.projectTitle = QtWidgets.QLabel(SearcherSettings)
        font = QtGui.QFont()
        font.setPointSize(15)
        self.projectTitle.setFont(font)
        self.projectTitle.setAlignment(QtCore.Qt.AlignCenter)
        self.projectTitle.setObjectName("projectTitle")
        self.headerrow.addWidget(self.projectTitle)
        self.line_2 = QtWidgets.QFrame(SearcherSettings)
        self.line_2.setFrameShape(QtWidgets.QFrame.VLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line_2")
        self.headerrow.addWidget(self.line_2)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.headerrow.addItem(spacerItem)
        self.checkBox = QtWidgets.QCheckBox(SearcherSettings)
        self.checkBox.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.checkBox.setObjectName("checkBox")
        self.headerrow.addWidget(self.checkBox)
        self.windowsize_chk = QtWidgets.QCheckBox(SearcherSettings)
        self.windowsize_chk.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.windowsize_chk.setObjectName("windowsize_chk")
        self.headerrow.addWidget(self.windowsize_chk)
        self.verticalLayout_4.addLayout(self.headerrow)
        self.line = QtWidgets.QFrame(SearcherSettings)
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout_4.addWidget(self.line)
        self.secondrow = QtWidgets.QHBoxLayout()
        self.secondrow.setObjectName("secondrow")
        self.lang_cbox = QtWidgets.QComboBox(SearcherSettings)
        self.lang_cbox.setObjectName("lang_cbox")
        self.lang_cbox.addItem("")
        self.secondrow.addWidget(self.lang_cbox)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.secondrow.addItem(spacerItem1)
        self.label_3 = QtWidgets.QLabel(SearcherSettings)
        self.label_3.setObjectName("label_3")
        self.secondrow.addWidget(self.label_3)
        self.maxresults_txt = QtWidgets.QSpinBox(SearcherSettings)
        self.maxresults_txt.setMinimum(1)
        self.maxresults_txt.setMaximum(9999)
        self.maxresults_txt.setObjectName("maxresults_txt")
        self.secondrow.addWidget(self.maxresults_txt)
        self.inmemory_chk = QtWidgets.QCheckBox(SearcherSettings)
        self.inmemory_chk.setLayoutDirection(QtCore.Qt.RightToLeft)
        self.inmemory_chk.setTristate(False)
        self.inmemory_chk.setObjectName("inmemory_chk")
        self.secondrow.addWidget(self.inmemory_chk)
        self.verticalLayout_4.addLayout(self.secondrow)
        self.thirdrow = QtWidgets.QHBoxLayout()
        self.thirdrow.setObjectName("thirdrow")
        self.label_2 = QtWidgets.QLabel(SearcherSettings)
        self.label_2.setObjectName("label_2")
        self.thirdrow.addWidget(self.label_2)
        self.defaulthotkey_txt = QtWidgets.QLineEdit(SearcherSettings)
        self.defaulthotkey_txt.setToolTip("")
        self.defaulthotkey_txt.setReadOnly(True)
        self.defaulthotkey_txt.setObjectName("defaulthotkey_txt")
        self.thirdrow.addWidget(self.defaulthotkey_txt)
        self.hotkey_icon = QtWidgets.QToolButton(SearcherSettings)
        self.hotkey_icon.setPopupMode(QtWidgets.QToolButton.InstantPopup)
        self.hotkey_icon.setObjectName("hotkey_icon")
        self.thirdrow.addWidget(self.hotkey_icon)
        self.verticalLayout_4.addLayout(self.thirdrow)
        self.fourthrow = QtWidgets.QHBoxLayout()
        self.fourthrow.setObjectName("fourthrow")
        self.label = QtWidgets.QLabel(SearcherSettings)
        self.label.setObjectName("label")
        self.fourthrow.addWidget(self.label)
        self.databasepath_txt = QtWidgets.QLineEdit(SearcherSettings)
        self.databasepath_txt.setObjectName("databasepath_txt")
        self.fourthrow.addWidget(self.databasepath_txt)
        self.dbpath_icon = QtWidgets.QToolButton(SearcherSettings)
        self.dbpath_icon.setObjectName("dbpath_icon")
        self.fourthrow.addWidget(self.dbpath_icon)
        self.verticalLayout_4.addLayout(self.fourthrow)
        self.fifthrow = QtWidgets.QHBoxLayout()
        self.fifthrow.setObjectName("fifthrow")
        self.label_4 = QtWidgets.QLabel(SearcherSettings)
        self.label_4.setObjectName("label_4")
        self.fifthrow.addWidget(self.label_4)
        self.test1_btn = QtWidgets.QPushButton(SearcherSettings)
        self.test1_btn.setObjectName("test1_btn")
        self.fifthrow.addWidget(self.test1_btn)
        self.cleardata_btn = QtWidgets.QPushButton(SearcherSettings)
        self.cleardata_btn.setObjectName("cleardata_btn")
        self.fifthrow.addWidget(self.cleardata_btn)
        self.verticalLayout_4.addLayout(self.fifthrow)
        self.line_3 = QtWidgets.QFrame(SearcherSettings)
        self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_3.setObjectName("line_3")
        self.verticalLayout_4.addWidget(self.line_3)
        self.sixthrow = QtWidgets.QHBoxLayout()
        self.sixthrow.setObjectName("sixthrow")
        self.about_btn = QtWidgets.QToolButton(SearcherSettings)
        self.about_btn.setObjectName("about_btn")
        self.sixthrow.addWidget(self.about_btn)
        spacerItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.sixthrow.addItem(spacerItem2)
        self.debuglevel_cbx = QtWidgets.QComboBox(SearcherSettings)
        self.debuglevel_cbx.setObjectName("debuglevel_cbx")
        self.debuglevel_cbx.addItem("")
        self.debuglevel_cbx.addItem("")
        self.debuglevel_cbx.addItem("")
        self.sixthrow.addWidget(self.debuglevel_cbx)
        self.debugflag_chk = QtWidgets.QCheckBox(SearcherSettings)
        self.debugflag_chk.setLayoutDirection(QtCore.Qt.LeftToRight)
        self.debugflag_chk.setObjectName("debugflag_chk")
        self.sixthrow.addWidget(self.debugflag_chk)
        self.discard_btn = QtWidgets.QPushButton(SearcherSettings)
        self.discard_btn.setObjectName("discard_btn")
        self.sixthrow.addWidget(self.discard_btn)
        self.save_btn = QtWidgets.QPushButton(SearcherSettings)
        self.save_btn.setObjectName("save_btn")
        self.sixthrow.addWidget(self.save_btn)
        self.verticalLayout_4.addLayout(self.sixthrow)
        self.gridLayout.addLayout(self.verticalLayout_4, 0, 0, 1, 1)

        self.retranslateUi(SearcherSettings)
        QtCore.QMetaObject.connectSlotsByName(SearcherSettings)
Exemplo n.º 3
0
    def __init__(self, parent, flat_media, do_export_and_then_quit=False):

        ClientGUIScrolledPanels.ReviewPanel.__init__(self, parent)

        new_options = HG.client_controller.new_options

        self._media_to_paths = {}
        self._existing_filenames = set()
        self._last_phrase_used = ''
        self._last_dir_used = ''

        self._tags_box = ClientGUIListBoxes.StaticBoxSorterForListBoxTags(
            self, 'files\' tags')

        services_manager = HG.client_controller.services_manager

        self._neighbouring_txt_tag_service_keys = services_manager.FilterValidServiceKeys(
            new_options.GetKeyList(
                'default_neighbouring_txt_tag_service_keys'))

        t = ClientGUIListBoxes.ListBoxTagsMedia(
            self._tags_box,
            ClientTags.TAG_DISPLAY_SIBLINGS_AND_PARENTS,
            include_counts=True)

        self._tags_box.SetTagsBox(t)

        self._tags_box.setMinimumSize(QC.QSize(220, 300))

        columns = [('number', 8), ('filetype', 20), ('expected path', -1)]

        self._paths = ClientGUIListCtrl.BetterListCtrl(
            self,
            'export_files',
            24,
            64,
            columns,
            self._ConvertDataToListCtrlTuples,
            use_simple_delete=True)

        self._paths.Sort(0)

        self._export_path_box = ClientGUICommon.StaticBox(self, 'export path')

        self._directory_picker = QP.DirPickerCtrl(self._export_path_box)
        self._directory_picker.dirPickerChanged.connect(self._RefreshPaths)

        self._open_location = QW.QPushButton('open this location',
                                             self._export_path_box)
        self._open_location.clicked.connect(self.EventOpenLocation)

        self._filenames_box = ClientGUICommon.StaticBox(self, 'filenames')

        self._pattern = QW.QLineEdit(self._filenames_box)

        self._update = QW.QPushButton('update', self._filenames_box)
        self._update.clicked.connect(self._RefreshPaths)

        self._examples = ClientGUICommon.ExportPatternButton(
            self._filenames_box)

        self._delete_files_after_export = QW.QCheckBox(
            'delete files from client after export?', self)
        self._delete_files_after_export.setObjectName('HydrusWarning')

        self._export_symlinks = QW.QCheckBox('EXPERIMENTAL: export symlinks',
                                             self)
        self._export_symlinks.setObjectName('HydrusWarning')

        text = 'This will export all the files\' tags, newline separated, into .txts beside the files themselves.'

        self._export_tag_txts_services_button = ClientGUICommon.BetterButton(
            self, 'set .txt services', self._SetTxtServices)

        self._export_tag_txts = QW.QCheckBox('export tags to .txt files?',
                                             self)
        self._export_tag_txts.setToolTip(text)
        self._export_tag_txts.clicked.connect(self.EventExportTagTxtsChanged)

        self._export = QW.QPushButton('export', self)
        self._export.clicked.connect(self._DoExport)

        #

        export_path = ClientExporting.GetExportPath()

        self._directory_picker.SetPath(export_path)

        phrase = new_options.GetString('export_phrase')

        self._pattern.setText(phrase)

        if len(self._neighbouring_txt_tag_service_keys) > 0:

            self._export_tag_txts.setChecked(True)

        self._paths.SetData(list(enumerate(flat_media)))

        self._delete_files_after_export.setChecked(
            HG.client_controller.new_options.GetBoolean(
                'delete_files_after_export'))
        self._delete_files_after_export.clicked.connect(
            self.EventDeleteFilesChanged)

        if not HG.client_controller.new_options.GetBoolean('advanced_mode'):

            self._export_symlinks.setVisible(False)

        #

        top_hbox = QP.HBoxLayout()

        QP.AddToLayout(top_hbox, self._tags_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(top_hbox, self._paths, CC.FLAGS_EXPAND_BOTH_WAYS)

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._directory_picker, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(hbox, self._open_location, CC.FLAGS_VCENTER)

        self._export_path_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(hbox, self._update, CC.FLAGS_VCENTER)
        QP.AddToLayout(hbox, self._examples, CC.FLAGS_VCENTER)

        self._filenames_box.Add(hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        txt_hbox = QP.HBoxLayout()

        QP.AddToLayout(txt_hbox, self._export_tag_txts_services_button,
                       CC.FLAGS_VCENTER)
        QP.AddToLayout(txt_hbox, self._export_tag_txts, CC.FLAGS_VCENTER)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, top_hbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        QP.AddToLayout(vbox, self._export_path_box,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._filenames_box,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._delete_files_after_export,
                       CC.FLAGS_LONE_BUTTON)
        QP.AddToLayout(vbox, self._export_symlinks, CC.FLAGS_LONE_BUTTON)
        QP.AddToLayout(vbox, txt_hbox, CC.FLAGS_LONE_BUTTON)
        QP.AddToLayout(vbox, self._export, CC.FLAGS_LONE_BUTTON)

        self.widget().setLayout(vbox)

        self._RefreshTags()

        self._UpdateTxtButton()

        HG.client_controller.CallAfterQtSafe(self._export,
                                             self._export.setFocus,
                                             QC.Qt.OtherFocusReason)

        self._paths.itemSelectionChanged.connect(self._RefreshTags)

        if do_export_and_then_quit:

            QP.CallAfter(self._DoExport, True)
Exemplo n.º 4
0
    def __init__(self, constraints, parent=None):
        """
        Parameters
        ----------
        constraints : dict
            The `contstraints` property of a :class:`~glue.core.fitters.BaseFitter1D`
            object
        parent : QtWidgets.QWidget (optional)
            The parent of this widget
        """
        super(ConstraintsWidget, self).__init__(parent)
        self.constraints = constraints

        self.layout = QtWidgets.QGridLayout()
        self.layout.setContentsMargins(2, 2, 2, 2)
        self.layout.setSpacing(4)

        self.setLayout(self.layout)

        self.layout.addWidget(QtWidgets.QLabel("Estimate"), 0, 1)
        self.layout.addWidget(QtWidgets.QLabel("Fixed"), 0, 2)
        self.layout.addWidget(QtWidgets.QLabel("Bounded"), 0, 3)
        self.layout.addWidget(QtWidgets.QLabel("Lower Bound"), 0, 4)
        self.layout.addWidget(QtWidgets.QLabel("Upper Bound"), 0, 5)

        self._widgets = {}
        names = sorted(list(self.constraints.keys()))

        for k in names:
            row = []
            w = QtWidgets.QLabel(k)
            row.append(w)

            v = QtGui.QDoubleValidator()
            e = QtWidgets.QLineEdit()
            e.setValidator(v)
            e.setText(str(constraints[k]['value'] or ''))
            row.append(e)

            w = QtWidgets.QCheckBox()
            w.setChecked(constraints[k]['fixed'])
            fix = w
            row.append(w)

            w = QtWidgets.QCheckBox()
            limits = constraints[k]['limits']
            w.setChecked(limits is not None)
            bound = w
            row.append(w)

            e = QtWidgets.QLineEdit()
            e.setValidator(v)
            if limits is not None:
                e.setText(str(limits[0]))
            row.append(e)

            e = QtWidgets.QLineEdit()
            e.setValidator(v)
            if limits is not None:
                e.setText(str(limits[1]))
            row.append(e)

            def unset(w):
                def result(active):
                    if active:
                        w.setChecked(False)

                return result

            fix.toggled.connect(unset(bound))
            bound.toggled.connect(unset(fix))

            self._widgets[k] = row

        for i, row in enumerate(names, 1):
            for j, widget in enumerate(self._widgets[row]):
                self.layout.addWidget(widget, i, j)
Exemplo n.º 5
0
    def __init__(self, parameter, layout, type_int):
        # call the super method's initializer
        super().__init__(parameter, layout)

        if type_int:
            self.decimals = 0
        elif self.parameter.decimals is None:
            self.decimals = 2
        else:
            self.decimals = self.parameter.decimals
        self.decimal_factor = 10**self.decimals

        # if the parameter has a minimum and maximum, we can add a slider to display it
        if self.parameter.min is not None and self.parameter.max is not None:
            # create a slider object
            self.slider = QtWidgets.QSlider()
            # add it to the widget
            self.layout.addWidget(self.slider)
            # set the orientation of the slider to horizontal
            self.slider.setOrientation(QtCore.Qt.Horizontal)
            # set the range
            self.slider.setRange(parameter.min * self.decimal_factor,
                                 parameter.max * self.decimal_factor)
            # and connect the valueChanged signal
            self.slider.valueChanged.connect(
                lambda x: self.setValue(x / self.decimal_factor))

        # if it is an integer, use a QSpinBox
        if type_int:
            self.spinBox = QtWidgets.QSpinBox()
        # if it is a float, use a QDoubleSpinBox
        else:
            self.spinBox = QtWidgets.QDoubleSpinBox()
            self.spinBox.setDecimals(self.decimals)
        # add the spinbox to the layout
        self.layout.addWidget(self.spinBox)

        # set the minimum of the spinbox
        if parameter.min is not None:
            self.spinBox.setMinimum(parameter.min)
        else:
            self.spinBox.setMinimum(-2**16)

        # set the maximum of the spinbox
        if parameter.max is not None:
            self.spinBox.setMaximum(parameter.max)
        else:
            self.spinBox.setMaximum(2**16)

        # connect the valueChanged signal of the spinbox
        self.spinBox.valueChanged.connect(self.setValue)

        # set the value of the parameter
        self.setValue(parameter.value)
        """ range selection """
        self.range_edits = []
        for name in ["min", "max"]:
            # the name of the range end, e.g. min or max
            self.layoutRange.addWidget(QtWidgets.QLabel(name))

            # the selector
            edit = QtWidgets.QLineEdit()
            # a validator for the input
            if type_int:
                edit.setValidator(QtGui.QIntValidator())
            else:
                edit.setValidator(QtGui.QDoubleValidator())
            # connect the signal
            edit.textEdited.connect(self.rangeChanged)
            # style
            edit.setMaximumWidth(50)
            edit.setPlaceholderText(name + "imum")

            # set the value if already a value is given
            if self.parameter.min is not None:
                edit.setText(str(self.parameter.min))

            # add it to the layout and the list
            self.layoutRange.addWidget(edit)
            self.range_edits.append(edit)

        # if the type is a float add a checkbox to sample from a log normal distribution for optimisation
        if not type_int:
            self.check_log = QtWidgets.QCheckBox("log-uniform")
            self.layoutRange.addWidget(self.check_log)
Exemplo n.º 6
0
 def _get_widget(self, parent=None):
     sb = QtWidgets.QCheckBox(parent=parent)
     sb.setCheckState(self._get_checked_state(self._value))
     sb.stateChanged.connect(self._handle_value_changed)
     return sb
Exemplo n.º 7
0
    def __init__(self, window, data_file):
        QtWidgets.QWidget.__init__(self)
        self.window = window
        self.data_file = data_file

        # Widget
        self.setMinimumWidth(500)
        self.setMinimumHeight(200)
        self.setWindowTitle("Folder Selector - ClickPoints")
        self.layout = QtWidgets.QVBoxLayout(self)

        self.setWindowIcon(qta.icon("fa.folder-open"))
        """ """
        self.list = QtWidgets.QListWidget(self)
        self.layout.addWidget(self.list)
        self.list.itemSelectionChanged.connect(self.list_selected)

        group_box = QtWidgets.QGroupBox("Add Folder")
        self.group_box = group_box
        self.layout.addWidget(group_box)
        layout = QtWidgets.QVBoxLayout()
        group_box.setLayout(layout)
        """ """

        horizontal_layout = QtWidgets.QHBoxLayout()
        layout.addLayout(horizontal_layout)

        horizontal_layout.addWidget(QtWidgets.QLabel("Folder:"))

        self.text_input = QtWidgets.QLineEdit(self)
        self.text_input.setDisabled(True)
        horizontal_layout.addWidget(self.text_input)

        self.pushbutton_folder = QtWidgets.QPushButton('Select F&older', self)
        self.pushbutton_folder.pressed.connect(self.select_folder)
        horizontal_layout.addWidget(self.pushbutton_folder)

        self.pushbutton_file = QtWidgets.QPushButton('Select F&ile', self)
        self.pushbutton_file.pressed.connect(self.select_file)
        horizontal_layout.addWidget(self.pushbutton_file)
        """ """

        horizontal_layout = QtWidgets.QHBoxLayout()
        layout.addLayout(horizontal_layout)

        horizontal_layout.addWidget(QtWidgets.QLabel("Filter:"))

        self.text_input_filter = QtWidgets.QLineEdit(self)
        self.text_input_filter.setToolTip(
            "Use any expression with an wildcard * to filter the files in the selected folder."
        )
        horizontal_layout.addWidget(self.text_input_filter)
        """ """

        horizontal_layout = QtWidgets.QHBoxLayout()
        layout.addLayout(horizontal_layout)

        self.checkbox_subfolders = QtWidgets.QCheckBox("subfolders")
        self.checkbox_subfolders.setToolTip(
            "Add all the subfolders of the selected folder, too.")
        horizontal_layout.addWidget(self.checkbox_subfolders)
        self.checkbox_natsort = QtWidgets.QCheckBox("natsort")
        self.checkbox_natsort.setToolTip(
            "Use natural sorting of filenames. This will sort numbers correctly (e.g. not 1 10 2 3). Takes more time to load."
        )
        horizontal_layout.addWidget(self.checkbox_natsort)

        self.pushbutton_load = QtWidgets.QPushButton('Load', self)
        self.pushbutton_load.pressed.connect(self.add_folder)
        horizontal_layout.addWidget(self.pushbutton_load)

        self.pushbutton_delete = QtWidgets.QPushButton('Remove', self)
        self.pushbutton_delete.pressed.connect(self.remove_folder)
        horizontal_layout.addWidget(self.pushbutton_delete)
        """ """

        horizontal_layout = QtWidgets.QHBoxLayout()
        self.layout.addLayout(horizontal_layout)

        horizontal_layout.addStretch()

        self.pushbutton_Confirm = QtWidgets.QPushButton('O&k', self)
        self.pushbutton_Confirm.pressed.connect(self.close)
        horizontal_layout.addWidget(self.pushbutton_Confirm)

        self.update_folder_list()
        self.list.setCurrentRow(self.list.count() - 1)
Exemplo n.º 8
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(651, 532)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/icons/collections.png"),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Dialog.setWindowIcon(icon)
        Dialog.setSizeGripEnabled(True)
        Dialog.setModal(True)
        self.verticalLayout_4 = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout_4.setObjectName("verticalLayout_4")
        self.main_splitter = QtWidgets.QSplitter(Dialog)
        self.main_splitter.setOrientation(QtCore.Qt.Horizontal)
        self.main_splitter.setObjectName("main_splitter")
        self.preview_box = QtWidgets.QGroupBox(self.main_splitter)
        self.preview_box.setObjectName("preview_box")
        self.preview_layout = QtWidgets.QVBoxLayout(self.preview_box)
        self.preview_layout.setObjectName("preview_layout")
        self.show_solutions = QtWidgets.QCheckBox(self.preview_box)
        self.show_solutions.setChecked(True)
        self.show_solutions.setObjectName("show_solutions")
        self.preview_layout.addWidget(self.show_solutions)
        self.sub_splitter = QtWidgets.QSplitter(self.main_splitter)
        self.sub_splitter.setOrientation(QtCore.Qt.Vertical)
        self.sub_splitter.setObjectName("sub_splitter")
        self.layoutWidget = QtWidgets.QWidget(self.sub_splitter)
        self.layoutWidget.setObjectName("layoutWidget")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.layoutWidget)
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.common_label = QtWidgets.QLabel(self.layoutWidget)
        self.common_label.setObjectName("common_label")
        self.verticalLayout_2.addWidget(self.common_label)
        self.common_list = QtWidgets.QListWidget(self.layoutWidget)
        self.common_list.setObjectName("common_list")
        self.verticalLayout_2.addWidget(self.common_list)
        self.common_load = QtWidgets.QPushButton(self.layoutWidget)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/icons/data.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.common_load.setIcon(icon1)
        self.common_load.setObjectName("common_load")
        self.verticalLayout_2.addWidget(self.common_load)
        self.verticalLayoutWidget = QtWidgets.QWidget(self.sub_splitter)
        self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(
            self.verticalLayoutWidget)
        self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.line = QtWidgets.QFrame(self.verticalLayoutWidget)
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout_3.addWidget(self.line)
        self.Collections_label = QtWidgets.QLabel(self.verticalLayoutWidget)
        self.Collections_label.setObjectName("Collections_label")
        self.verticalLayout_3.addWidget(self.Collections_label)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.collections_list = QtWidgets.QListWidget(
            self.verticalLayoutWidget)
        self.collections_list.setObjectName("collections_list")
        self.horizontalLayout_2.addWidget(self.collections_list)
        self.verticalLayout = QtWidgets.QVBoxLayout()
        self.verticalLayout.setObjectName("verticalLayout")
        self.project_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(":/icons/mechanism.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.project_button.setIcon(icon2)
        self.project_button.setObjectName("project_button")
        self.verticalLayout.addWidget(self.project_button)
        self.line_2 = QtWidgets.QFrame(self.verticalLayoutWidget)
        self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line_2.setObjectName("line_2")
        self.verticalLayout.addWidget(self.line_2)
        self.rename_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(":/icons/rename.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.rename_button.setIcon(icon3)
        self.rename_button.setAutoDefault(False)
        self.rename_button.setObjectName("rename_button")
        self.verticalLayout.addWidget(self.rename_button)
        self.copy_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(":/icons/copy.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.copy_button.setIcon(icon4)
        self.copy_button.setObjectName("copy_button")
        self.verticalLayout.addWidget(self.copy_button)
        spacerItem = QtWidgets.QSpacerItem(20, 40,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.verticalLayout.addItem(spacerItem)
        self.delete_button = QtWidgets.QPushButton(self.verticalLayoutWidget)
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(":/icons/delete.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.delete_button.setIcon(icon5)
        self.delete_button.setAutoDefault(False)
        self.delete_button.setObjectName("delete_button")
        self.verticalLayout.addWidget(self.delete_button)
        self.horizontalLayout_2.addLayout(self.verticalLayout)
        self.verticalLayout_3.addLayout(self.horizontalLayout_2)
        self.verticalLayout_4.addWidget(self.main_splitter)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        spacerItem1 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Expanding,
                                            QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem1)
        self.button_box = QtWidgets.QDialogButtonBox(Dialog)
        self.button_box.setStandardButtons(QtWidgets.QDialogButtonBox.Close
                                           | QtWidgets.QDialogButtonBox.Open)
        self.button_box.setObjectName("button_box")
        self.horizontalLayout_3.addWidget(self.button_box)
        self.verticalLayout_4.addLayout(self.horizontalLayout_3)

        self.retranslateUi(Dialog)
        self.button_box.rejected.connect(Dialog.reject)
        self.button_box.accepted.connect(Dialog.accept)
        self.common_load.clicked.connect(Dialog.accept)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
Exemplo n.º 9
0
    def __init__(self, ol=None, parent=None):
        # pylint: disable=unused-argument,super-on-old-class
        super(DGSPlannerGUI, self).__init__(parent)
        # OrientedLattice
        if ValidateOL(ol):
            self.ol = ol
        else:
            self.ol = mantid.geometry.OrientedLattice()
        self.masterDict = dict()  # holds info about instrument and ranges
        self.updatedInstrument = False
        self.updatedOL = False
        self.wg = None  # workspace group
        self.instrumentWidget = InstrumentSetupWidget.InstrumentSetupWidget(
            self)
        self.setLayout(QtWidgets.QHBoxLayout())
        controlLayout = QtWidgets.QVBoxLayout()
        controlLayout.addWidget(self.instrumentWidget)
        self.ublayout = QtWidgets.QHBoxLayout()
        self.classic = ClassicUBInputWidget.ClassicUBInputWidget(self.ol)
        self.ublayout.addWidget(self.classic,
                                alignment=QtCore.Qt.AlignTop,
                                stretch=1)
        self.matrix = MatrixUBInputWidget.MatrixUBInputWidget(self.ol)
        self.ublayout.addWidget(self.matrix,
                                alignment=QtCore.Qt.AlignTop,
                                stretch=1)
        controlLayout.addLayout(self.ublayout)
        self.dimensionWidget = DimensionSelectorWidget.DimensionSelectorWidget(
            self)
        controlLayout.addWidget(self.dimensionWidget)
        plotControlLayout = QtWidgets.QGridLayout()
        self.plotButton = QtWidgets.QPushButton("Plot", self)
        self.oplotButton = QtWidgets.QPushButton("Overplot", self)
        self.helpButton = QtWidgets.QPushButton("?", self)
        self.colorLabel = QtWidgets.QLabel('Color by angle', self)
        self.colorButton = QtWidgets.QCheckBox(self)
        self.colorButton.toggle()
        self.aspectLabel = QtWidgets.QLabel('Aspect ratio 1:1', self)
        self.aspectButton = QtWidgets.QCheckBox(self)
        self.saveButton = QtWidgets.QPushButton("Save Figure", self)
        plotControlLayout.addWidget(self.plotButton, 0, 0)
        plotControlLayout.addWidget(self.oplotButton, 0, 1)
        plotControlLayout.addWidget(self.colorLabel, 0, 2,
                                    QtCore.Qt.AlignRight)
        plotControlLayout.addWidget(self.colorButton, 0, 3)
        plotControlLayout.addWidget(self.aspectLabel, 0, 4,
                                    QtCore.Qt.AlignRight)
        plotControlLayout.addWidget(self.aspectButton, 0, 5)
        plotControlLayout.addWidget(self.helpButton, 0, 6)
        plotControlLayout.addWidget(self.saveButton, 0, 7)
        controlLayout.addLayout(plotControlLayout)
        self.layout().addLayout(controlLayout)

        # figure
        self.figure = Figure()
        self.figure.patch.set_facecolor('white')
        self.canvas = FigureCanvas(self.figure)
        self.grid_helper = GridHelperCurveLinear((self.tr, self.inv_tr))
        self.trajfig = Subplot(self.figure,
                               1,
                               1,
                               1,
                               grid_helper=self.grid_helper)
        if matplotlib.compare_versions('2.1.0', matplotlib.__version__):
            self.trajfig.hold(
                True)  # hold is deprecated since 2.1.0, true by default
        self.figure.add_subplot(self.trajfig)
        self.toolbar = CustomNavigationToolbar(self.canvas, self)
        figureLayout = QtWidgets.QVBoxLayout()
        figureLayout.addWidget(self.toolbar, 0)
        figureLayout.addWidget(self.canvas, 1)
        self.layout().addLayout(figureLayout)
        self.needToClear = False
        self.saveDir = ''

        # connections
        self.matrix.UBmodel.changed.connect(self.updateUB)
        self.matrix.UBmodel.changed.connect(self.classic.updateOL)
        self.classic.changed.connect(self.matrix.UBmodel.updateOL)
        self.classic.changed.connect(self.updateUB)
        self.instrumentWidget.changed.connect(self.updateParams)
        self.dimensionWidget.changed.connect(self.updateParams)
        self.plotButton.clicked.connect(self.updateFigure)
        self.oplotButton.clicked.connect(self.updateFigure)
        self.helpButton.clicked.connect(self.help)
        self.saveButton.clicked.connect(self.save)
        # force an update of values
        self.instrumentWidget.updateAll()
        self.dimensionWidget.updateChanges()
        # help
        self.assistantProcess = QtCore.QProcess(self)
        # pylint: disable=protected-access
        self.collectionFile = os.path.join(mantid._bindir,
                                           '../docs/qthelp/MantidProject.qhc')
        version = ".".join(mantid.__version__.split(".")[:2])
        self.qtUrl = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/DGS Planner.html'
        self.externalUrl = 'http://docs.mantidproject.org/nightly/interfaces/DGS Planner.html'
        # control for cancel button
        self.iterations = 0
        self.progress_canceled = False

        # register startup
        mantid.UsageService.registerFeatureUsage("Interface", "DGSPlanner",
                                                 False)
Exemplo n.º 10
0
    def __init__(
            self,
            parent,
            audio,
            index,
            codec,
            available_audio_encoders,
            title="",
            language="",
            profile="",
            outdex=None,
            enabled=True,
            original=False,
            first=False,
            last=False,
            codecs=(),
            channels=2,
            all_info=None,
    ):
        self.loading = True
        super(Audio, self).__init__(parent)
        self.parent = parent
        self.audio = audio
        self.setFixedHeight(60)
        self.original = original
        self.outdex = index if self.original else outdex
        self.first = first
        self.track_name = title
        self.profile = profile
        self.last = last
        self.index = index
        self.codec = codec
        self.codecs = codecs
        self.channels = channels
        self.available_audio_encoders = available_audio_encoders

        self.widgets = Box(
            track_number=QtWidgets.QLabel(
                f"{index}:{self.outdex}" if enabled else "❌"),
            title=QtWidgets.QLineEdit(title),
            audio_info=QtWidgets.QLabel(audio),
            up_button=QtWidgets.QPushButton(QtGui.QIcon(up_arrow_icon), ""),
            down_button=QtWidgets.QPushButton(QtGui.QIcon(down_arrow_icon),
                                              ""),
            enable_check=QtWidgets.QCheckBox(t("Enabled")),
            dup_button=QtWidgets.QPushButton(QtGui.QIcon(copy_icon), ""),
            delete_button=QtWidgets.QPushButton(QtGui.QIcon(black_x_icon), ""),
            language=QtWidgets.QComboBox(),
            downmix=QtWidgets.QComboBox(),
            convert_to=None,
            convert_bitrate=None,
        )

        self.widgets.up_button.setStyleSheet(no_border)
        self.widgets.down_button.setStyleSheet(no_border)
        self.widgets.dup_button.setStyleSheet(no_border)
        self.widgets.delete_button.setStyleSheet(no_border)

        if all_info:
            self.widgets.audio_info.setToolTip(all_info.to_yaml())

        downmix_options = [
            "mono",
            "stereo",
            "2.1 / 3.0",
            "3.1 / 4.0",
            "4.1 / 5.0",
            "5.1 / 6.0",
            "6.1 / 7.0",
            "7.1 / 8.0",
        ]

        self.widgets.language.addItems(["No Language Set"] + language_list)
        self.widgets.language.setMaximumWidth(110)
        if language:
            try:
                lang = Lang(language).name
            except InvalidLanguageValue:
                pass
            else:
                if lang in language_list:
                    self.widgets.language.setCurrentText(lang)

        self.widgets.language.currentIndexChanged.connect(self.page_update)
        self.widgets.title.setFixedWidth(150)
        self.widgets.title.textChanged.connect(self.page_update)
        self.widgets.audio_info.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                              QtWidgets.QSizePolicy.Expanding)

        self.widgets.downmix.addItems([t("No Downmix")] +
                                      downmix_options[:channels - 2])
        self.widgets.downmix.currentIndexChanged.connect(self.update_downmix)
        self.widgets.downmix.setCurrentIndex(0)
        self.widgets.downmix.setDisabled(True)

        self.widgets.enable_check.setChecked(enabled)
        self.widgets.enable_check.toggled.connect(self.update_enable)

        self.widgets.dup_button.clicked.connect(lambda: self.dup_me())
        self.widgets.dup_button.setFixedWidth(20)
        self.widgets.delete_button.clicked.connect(lambda: self.del_me())
        self.widgets.delete_button.setFixedWidth(20)

        self.widgets.track_number.setFixedWidth(20)

        label = QtWidgets.QLabel(f"{t('Title')}: ")
        self.widgets.title.setFixedWidth(150)
        title_layout = QtWidgets.QHBoxLayout()
        title_layout.addWidget(label)
        title_layout.addWidget(self.widgets.title)

        grid = QtWidgets.QGridLayout()
        grid.addLayout(self.init_move_buttons(), 0, 0)
        grid.addWidget(self.widgets.track_number, 0, 1)
        grid.addWidget(self.widgets.audio_info, 0, 2)
        grid.addLayout(title_layout, 0, 3)
        # grid.addWidget(self.widgets.title, 0, 4)
        grid.addLayout(self.init_conversion(), 0, 5)
        grid.addWidget(self.widgets.downmix, 0, 6)
        grid.addWidget(self.widgets.language, 0, 7)

        right_button_start_index = 8

        if not original:
            spacer = QtWidgets.QLabel()
            spacer.setFixedWidth(63)
            grid.addWidget(spacer, 0, right_button_start_index)
            grid.addWidget(self.widgets.delete_button, 0,
                           right_button_start_index + 1)
        else:
            grid.addWidget(self.widgets.enable_check, 0,
                           right_button_start_index)
            grid.addWidget(self.widgets.dup_button, 0,
                           right_button_start_index + 1)
        self.setLayout(grid)
        self.loading = False
Exemplo n.º 11
0
    def __init__(self,
                 datafunction=None,
                 sweepInstrument=None,
                 sweepparams=None,
                 sweepranges=None,
                 alpha=.3,
                 verbose=1,
                 show_controls=True,
                 window_title='live view',
                 plot_title=None,
                 is1dscan=None,
                 **kwargs):
        """Return a new livePlot object."""
        super().__init__(**kwargs)

        self.window_title = window_title
        win = QtWidgets.QWidget()
        win.resize(800, 600)
        win.setWindowTitle(self.window_title)
        vertLayout = QtWidgets.QVBoxLayout()

        self._averaging_enabled = True
        if show_controls:
            topLayout = QtWidgets.QHBoxLayout()
            win.start_button = QtWidgets.QPushButton('Start')
            win.stop_button = QtWidgets.QPushButton('Stop')
            win.averaging_box = QtWidgets.QCheckBox('Averaging')
            win.averaging_box.setChecked(self._averaging_enabled)
            for b in [win.start_button, win.stop_button]:
                b.setMaximumHeight(24)
            topLayout.addWidget(win.start_button)
            topLayout.addWidget(win.stop_button)
            topLayout.addWidget(win.averaging_box)
            vertLayout.addLayout(topLayout)
        plotwin = pg.GraphicsWindow(title="Live view")
        vertLayout.addWidget(plotwin)
        win.setLayout(vertLayout)
        self.setGeometry = win.setGeometry
        self.win = win
        self.plotwin = plotwin
        self.verbose = verbose
        self.idx = 0
        self.maxidx = 1e9
        self.data = None
        self.data_avg = None
        self.sweepInstrument = sweepInstrument
        self.sweepparams = sweepparams
        self.sweepranges = sweepranges
        self.fps = pgeometry.fps_t(nn=6)
        self.datafunction = datafunction
        self.datafunction_result = None
        self.alpha = alpha
        if is1dscan is None:
            is1dscan = (isinstance(self.sweepparams, str)
                        or (isinstance(self.sweepparams, (list, dict))
                            and len(self.sweepparams) == 1))
            if isinstance(self.sweepparams, dict):
                if 'gates_horz' not in self.sweepparams:
                    is1dscan = True
        if verbose:
            print('live_plotting: is1dscan %s' % is1dscan)
        if self.sweepparams is None:
            p1 = plotwin.addPlot(title="Videomode")
            p1.setLabel('left', 'param2')
            p1.setLabel('bottom', 'param1')
            if self.datafunction is None:
                raise Exception(
                    'Either specify a datafunction or sweepparams.')
            else:
                data = np.array(self.datafunction())
                if data.ndim == 1:
                    dd = np.zeros((0, ))
                    plot = p1.plot(dd, pen='b')
                    self.plot = plot
                else:
                    self.plot = pg.ImageItem()
                    p1.addItem(self.plot)
        elif is1dscan:
            p1 = plotwin.addPlot(title=plot_title)
            p1.setLabel('left', 'Value')
            p1.setLabel('bottom', self.sweepparams, units='mV')
            dd = np.zeros((0, ))
            plot = p1.plot(dd, pen='b')
            self.plot = plot
            vpen = pg.QtGui.QPen(pg.QtGui.QColor(130, 130, 175, 60), 0,
                                 pg.QtCore.Qt.SolidLine)
            gv = pg.InfiniteLine([0, 0], angle=90, pen=vpen)
            gv.setZValue(0)
            p1.addItem(gv)
            self._crosshair = [gv]
            self.crosshair(show=False)
        elif isinstance(self.sweepparams, (list, dict)):
            # 2D scan
            p1 = plotwin.addPlot(title=plot_title)
            if type(self.sweepparams) is dict:
                [xlabel, ylabel] = ['sweepparam_v', 'stepparam_v']
            else:
                [xlabel, ylabel] = self.sweepparams
            p1.setLabel('bottom', xlabel, units='mV')
            p1.setLabel('left', ylabel, units='mV')
            self.plot = pg.ImageItem()
            p1.addItem(self.plot)
            vpen = pg.QtGui.QPen(pg.QtGui.QColor(0, 130, 235, 60), 0,
                                 pg.QtCore.Qt.SolidLine)
            gh = pg.InfiniteLine([0, 0], angle=90, pen=vpen)
            gv = pg.InfiniteLine([0, 0], angle=0, pen=vpen)
            gh.setZValue(0)
            gv.setZValue(0)
            p1.addItem(gh)
            p1.addItem(gv)
            self._crosshair = [gh, gv]
            self.crosshair(show=False)
        else:
            raise Exception(
                'The number of sweep parameters should be either None, 1 or 2.'
            )
        self.plothandle = p1
        self.timer = QtCore.QTimer()
        self.timer.timeout.connect(self.updatebg)
        self.win.show()

        def connect_slot(target):
            """ Create a slot by dropping signal arguments """

            # @Slot()
            def signal_drop_arguments(*args, **kwargs):
                # print('call %s' % target)
                target()

            return signal_drop_arguments

        if show_controls:
            win.start_button.clicked.connect(connect_slot(self.startreadout))
            win.stop_button.clicked.connect(connect_slot(self.stopreadout))
            win.averaging_box.clicked.connect(
                connect_slot(self.enable_averaging_slot))

        self.datafunction_result = None

        self.plotwin.scene().sigMouseClicked.connect(self._onClick)
Exemplo n.º 12
0
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(444, 654)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/icons/number.png"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        Form.setWindowIcon(icon)
        self.verticalLayout = QtWidgets.QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.edges_label = QtWidgets.QLabel(Form)
        self.edges_label.setObjectName("edges_label")
        self.horizontalLayout_4.addWidget(self.edges_label)
        self.edges_text = QtWidgets.QLineEdit(Form)
        self.edges_text.setReadOnly(True)
        self.edges_text.setObjectName("edges_text")
        self.horizontalLayout_4.addWidget(self.edges_text)
        self.expr_copy = QtWidgets.QPushButton(Form)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/icons/copy.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.expr_copy.setIcon(icon1)
        self.expr_copy.setObjectName("expr_copy")
        self.horizontalLayout_4.addWidget(self.expr_copy)
        self.expr_add_collection = QtWidgets.QPushButton(Form)
        self.expr_add_collection.setText("")
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(":/icons/collections.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.expr_add_collection.setIcon(icon2)
        self.expr_add_collection.setObjectName("expr_add_collection")
        self.horizontalLayout_4.addWidget(self.expr_add_collection)
        self.from_mechanism_button = QtWidgets.QPushButton(Form)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap(":/icons/merge_from.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.from_mechanism_button.setIcon(icon3)
        self.from_mechanism_button.setAutoDefault(True)
        self.from_mechanism_button.setDefault(True)
        self.from_mechanism_button.setObjectName("from_mechanism_button")
        self.horizontalLayout_4.addWidget(self.from_mechanism_button)
        self.verticalLayout.addLayout(self.horizontalLayout_4)
        self.line = QtWidgets.QFrame(Form)
        self.line.setFrameShape(QtWidgets.QFrame.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
        self.line.setObjectName("line")
        self.verticalLayout.addWidget(self.line)
        self.main_splitter = QtWidgets.QSplitter(Form)
        self.main_splitter.setOrientation(QtCore.Qt.Vertical)
        self.main_splitter.setObjectName("main_splitter")
        self.verticalLayoutWidget = QtWidgets.QWidget(self.main_splitter)
        self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(
            self.verticalLayoutWidget)
        self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.nj_label = QtWidgets.QLabel(self.verticalLayoutWidget)
        self.nj_label.setObjectName("nj_label")
        self.gridLayout.addWidget(self.nj_label, 0, 1, 1, 1)
        self.nl_label = QtWidgets.QLabel(self.verticalLayoutWidget)
        self.nl_label.setObjectName("nl_label")
        self.gridLayout.addWidget(self.nl_label, 0, 0, 1, 1)
        self.nl_input = QtWidgets.QSpinBox(self.verticalLayoutWidget)
        self.nl_input.setMinimum(4)
        self.nl_input.setObjectName("nl_input")
        self.gridLayout.addWidget(self.nl_input, 2, 0, 1, 1)
        self.nj_input = QtWidgets.QSpinBox(self.verticalLayoutWidget)
        self.nj_input.setMinimum(4)
        self.nj_input.setObjectName("nj_input")
        self.gridLayout.addWidget(self.nj_input, 2, 1, 1, 1)
        self.dof_label = QtWidgets.QLabel(self.verticalLayoutWidget)
        self.dof_label.setObjectName("dof_label")
        self.gridLayout.addWidget(self.dof_label, 0, 2, 1, 1)
        self.dof = QtWidgets.QSpinBox(self.verticalLayoutWidget)
        self.dof.setEnabled(False)
        self.dof.setMinimum(-99)
        self.dof.setProperty("value", 1)
        self.dof.setObjectName("dof")
        self.gridLayout.addWidget(self.dof, 2, 2, 1, 1)
        self.verticalLayout_2.addLayout(self.gridLayout)
        self.horizontalLayout_7 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.graph_degenerate = QtWidgets.QComboBox(self.verticalLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.graph_degenerate.sizePolicy().hasHeightForWidth())
        self.graph_degenerate.setSizePolicy(sizePolicy)
        self.graph_degenerate.setObjectName("graph_degenerate")
        self.graph_degenerate.addItem("")
        self.graph_degenerate.addItem("")
        self.graph_degenerate.addItem("")
        self.horizontalLayout_7.addWidget(self.graph_degenerate)
        spacerItem = QtWidgets.QSpacerItem(40, 20,
                                           QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_7.addItem(spacerItem)
        self.keep_dof = QtWidgets.QCheckBox(self.verticalLayoutWidget)
        self.keep_dof.setChecked(True)
        self.keep_dof.setObjectName("keep_dof")
        self.horizontalLayout_7.addWidget(self.keep_dof)
        self.verticalLayout_2.addLayout(self.horizontalLayout_7)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.number_synthesis_button = QtWidgets.QPushButton(
            self.verticalLayoutWidget)
        self.number_synthesis_button.setAutoDefault(True)
        self.number_synthesis_button.setObjectName("number_synthesis_button")
        self.horizontalLayout_2.addWidget(self.number_synthesis_button)
        self.assortment_clear_button = QtWidgets.QPushButton(
            self.verticalLayoutWidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.assortment_clear_button.sizePolicy().hasHeightForWidth())
        self.assortment_clear_button.setSizePolicy(sizePolicy)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap(":/icons/clean.png"), QtGui.QIcon.Normal,
                        QtGui.QIcon.Off)
        self.assortment_clear_button.setIcon(icon4)
        self.assortment_clear_button.setObjectName("assortment_clear_button")
        self.horizontalLayout_2.addWidget(self.assortment_clear_button)
        self.verticalLayout_2.addLayout(self.horizontalLayout_2)
        self.link_assortment_list = QtWidgets.QTreeWidget(
            self.verticalLayoutWidget)
        self.link_assortment_list.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.link_assortment_list.setIndentation(10)
        self.link_assortment_list.setObjectName("link_assortment_list")
        self.verticalLayout_2.addWidget(self.link_assortment_list)
        self.verticalLayoutWidget_2 = QtWidgets.QWidget(self.main_splitter)
        self.verticalLayoutWidget_2.setObjectName("verticalLayoutWidget_2")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(
            self.verticalLayoutWidget_2)
        self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.graph_engine = QtWidgets.QComboBox(self.verticalLayoutWidget_2)
        self.graph_engine.setObjectName("graph_engine")
        self.horizontalLayout.addWidget(self.graph_engine)
        self.reload_atlas = QtWidgets.QPushButton(self.verticalLayoutWidget_2)
        self.reload_atlas.setText("")
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap(":/icons/data_update.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.reload_atlas.setIcon(icon5)
        self.reload_atlas.setObjectName("reload_atlas")
        self.horizontalLayout.addWidget(self.reload_atlas)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Expanding,
                                            QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem1)
        self.graph_link_as_node = QtWidgets.QCheckBox(
            self.verticalLayoutWidget_2)
        self.graph_link_as_node.setObjectName("graph_link_as_node")
        self.horizontalLayout.addWidget(self.graph_link_as_node)
        self.graph_show_label = QtWidgets.QCheckBox(
            self.verticalLayoutWidget_2)
        self.graph_show_label.setChecked(True)
        self.graph_show_label.setObjectName("graph_show_label")
        self.horizontalLayout.addWidget(self.graph_show_label)
        self.verticalLayout_3.addLayout(self.horizontalLayout)
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.structure_synthesis_all_button = QtWidgets.QPushButton(
            self.verticalLayoutWidget_2)
        self.structure_synthesis_all_button.setMaximumSize(
            QtCore.QSize(100, 16777215))
        self.structure_synthesis_all_button.setAutoDefault(True)
        self.structure_synthesis_all_button.setObjectName(
            "structure_synthesis_all_button")
        self.horizontalLayout_5.addWidget(self.structure_synthesis_all_button)
        self.structure_synthesis_button = QtWidgets.QPushButton(
            self.verticalLayoutWidget_2)
        self.structure_synthesis_button.setObjectName(
            "structure_synthesis_button")
        self.horizontalLayout_5.addWidget(self.structure_synthesis_button)
        self.structure_list_clear_button = QtWidgets.QPushButton(
            self.verticalLayoutWidget_2)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.structure_list_clear_button.sizePolicy().hasHeightForWidth())
        self.structure_list_clear_button.setSizePolicy(sizePolicy)
        self.structure_list_clear_button.setIcon(icon4)
        self.structure_list_clear_button.setObjectName(
            "structure_list_clear_button")
        self.horizontalLayout_5.addWidget(self.structure_list_clear_button)
        self.verticalLayout_3.addLayout(self.horizontalLayout_5)
        self.structure_list = QtWidgets.QListWidget(
            self.verticalLayoutWidget_2)
        self.structure_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.structure_list.setIconSize(QtCore.QSize(200, 200))
        self.structure_list.setResizeMode(QtWidgets.QListView.Adjust)
        self.structure_list.setViewMode(QtWidgets.QListView.IconMode)
        self.structure_list.setUniformItemSizes(True)
        self.structure_list.setObjectName("structure_list")
        self.verticalLayout_3.addWidget(self.structure_list)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.save_edges = QtWidgets.QPushButton(self.verticalLayoutWidget_2)
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap(":/icons/save_file.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.save_edges.setIcon(icon6)
        self.save_edges.setObjectName("save_edges")
        self.horizontalLayout_3.addWidget(self.save_edges)
        self.save_atlas = QtWidgets.QPushButton(self.verticalLayoutWidget_2)
        icon7 = QtGui.QIcon()
        icon7.addPixmap(QtGui.QPixmap(":/icons/picture.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.save_atlas.setIcon(icon7)
        self.save_atlas.setObjectName("save_atlas")
        self.horizontalLayout_3.addWidget(self.save_atlas)
        self.edges2atlas_button = QtWidgets.QPushButton(
            self.verticalLayoutWidget_2)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.edges2atlas_button.sizePolicy().hasHeightForWidth())
        self.edges2atlas_button.setSizePolicy(sizePolicy)
        icon8 = QtGui.QIcon()
        icon8.addPixmap(QtGui.QPixmap(":/icons/edges_to_atlas.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.edges2atlas_button.setIcon(icon8)
        self.edges2atlas_button.setIconSize(QtCore.QSize(40, 16))
        self.edges2atlas_button.setObjectName("edges2atlas_button")
        self.horizontalLayout_3.addWidget(self.edges2atlas_button)
        self.verticalLayout_3.addLayout(self.horizontalLayout_3)
        self.horizontalLayout_6 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.time_title_label = QtWidgets.QLabel(self.verticalLayoutWidget_2)
        self.time_title_label.setObjectName("time_title_label")
        self.horizontalLayout_6.addWidget(self.time_title_label)
        self.time_label = QtWidgets.QLabel(self.verticalLayoutWidget_2)
        self.time_label.setObjectName("time_label")
        self.horizontalLayout_6.addWidget(self.time_label)
        self.paint_time_title_label = QtWidgets.QLabel(
            self.verticalLayoutWidget_2)
        self.paint_time_title_label.setObjectName("paint_time_title_label")
        self.horizontalLayout_6.addWidget(self.paint_time_title_label)
        self.paint_time_label = QtWidgets.QLabel(self.verticalLayoutWidget_2)
        self.paint_time_label.setObjectName("paint_time_label")
        self.horizontalLayout_6.addWidget(self.paint_time_label)
        spacerItem2 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Expanding,
                                            QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_6.addItem(spacerItem2)
        self.verticalLayout_3.addLayout(self.horizontalLayout_6)
        self.verticalLayout.addWidget(self.main_splitter)

        self.retranslateUi(Form)
        self.graph_degenerate.setCurrentIndex(1)
        self.graph_engine.setCurrentIndex(-1)
        QtCore.QMetaObject.connectSlotsByName(Form)
Exemplo n.º 13
0
    def __init__(self, parent, existing_folders_to_names, foldername, name,
                 file_search_context, synchronised, media_sort, media_collect):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._existing_folders_to_names = existing_folders_to_names
        self._original_folder_and_name = (foldername, name)

        self._foldername = QW.QLineEdit(self)
        self._name = QW.QLineEdit(self)

        self._media_sort = ClientGUIResultsSortCollect.MediaSortControl(self)
        self._media_collect = ClientGUIResultsSortCollect.MediaCollectControl(
            self, silent=True)

        page_key = HydrusData.GenerateKey()

        from hydrus.client.gui.search import ClientGUIACDropdown

        self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self,
            page_key,
            file_search_context,
            media_sort_widget=self._media_sort,
            media_collect_widget=self._media_collect,
            synchronised=synchronised,
            hide_favourites_edit_actions=True)

        self._include_media_sort = QW.QCheckBox(self)
        self._include_media_collect = QW.QCheckBox(self)

        width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._include_media_collect, 48)

        self._include_media_collect.setMinimumWidth(width)

        self._include_media_sort.stateChanged.connect(self._UpdateWidgets)
        self._include_media_collect.stateChanged.connect(self._UpdateWidgets)

        #

        if foldername is not None:

            self._foldername.setText(foldername)

        self._name.setText(name)

        if media_sort is not None:

            self._include_media_sort.setChecked(True)

            self._media_sort.SetSort(media_sort)

        if media_collect is not None:

            self._include_media_collect.setChecked(True)

            self._media_collect.SetCollect(media_collect)

        #

        rows = []

        rows.append(('folder (blank for none): ', self._foldername))
        rows.append(('name: ', self._name))

        top_gridbox = ClientGUICommon.WrapInGrid(self, rows)

        rows = []

        rows.append(('save sort: ', self._include_media_sort))
        rows.append(('sort: ', self._media_sort))
        rows.append(('save collect: ', self._include_media_collect))
        rows.append(('collect: ', self._media_collect))

        bottom_gridbox = ClientGUICommon.WrapInGrid(self, rows)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, top_gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._tag_autocomplete,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, bottom_gridbox,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        self.widget().setLayout(vbox)
Exemplo n.º 14
0
 def __init__(self, *args, **kwargs):
     super(ExRememberPrompt, self).__init__(*args, **kwargs)
     self.cb = QtWidgets.QCheckBox(tr("Remember this choice"), self)
     self.setCheckBox(self.cb)
Exemplo n.º 15
0
    def setup_interface(self, show_checks=False):
        self.setObjectName("GroupingWidget")
        self.resize(500, 100)

        self.grouppair_label = QtWidgets.QLabel(self)
        self.grouppair_label.setObjectName("groupPairLabel")
        self.grouppair_label.setText("Group / ")

        self.pair_label = QtWidgets.QLabel(self)
        self.pair_label.setObjectName("pairLabel")
        font = QtGui.QFont()
        font.setBold(True)
        self.pair_label.setFont(font)
        self.pair_label.setText("Pair : ")

        self.grouppair_selector = QtWidgets.QComboBox(self)
        self.grouppair_selector.setObjectName("groupPairSelector")
        self.grouppair_selector.addItems(["fwd", "bwd"])

        self.alpha_label_2 = QtWidgets.QLabel(self)
        self.alpha_label_2.setObjectName("AlphaLabel")
        self.alpha_label_2.setText("Alpha : ")

        self.alpha_edit = QtWidgets.QLineEdit(self)
        self.alpha_edit.setObjectName("alphaEdit")
        self.alpha_edit.setText("1.0")
        self.alpha_edit.setEnabled(False)

        reg_ex = QtCore.QRegExp(valid_alpha_regex)
        alpha_validator = QtGui.QRegExpValidator(reg_ex, self.alpha_edit)
        self.alpha_edit.setValidator(alpha_validator)

        self.horizontal_layout = QtWidgets.QHBoxLayout()
        self.horizontal_layout.setObjectName("horizontalLayout3")
        self.horizontal_layout.addWidget(self.grouppair_label)
        self.horizontal_layout.addWidget(self.pair_label)
        self.horizontal_layout.addWidget(self.grouppair_selector)
        self.horizontal_layout.addStretch(0)
        self.horizontal_layout.addWidget(self.alpha_label_2)
        self.horizontal_layout.addWidget(self.alpha_edit)

        self.period_label = QtWidgets.QLabel(self)
        self.period_label.setObjectName("periodLabel")
        self.period_label.setText(
            "Data collected in n periods. Plot/analysis period(s) : ")

        self.summed_period_edit = QtWidgets.QLineEdit(self)
        self.summed_period_edit.setText("1")
        reg_ex = QtCore.QRegExp("^[0-9]*([0-9]+[,-]{0,1})*[0-9]+$")
        period_validator = QtGui.QRegExpValidator(reg_ex,
                                                  self.summed_period_edit)
        self.summed_period_edit.setValidator(period_validator)

        self.minus_label = QtWidgets.QLabel(self)
        self.minus_label.setObjectName("minusLabel")
        self.minus_label.setText("-")

        self.subtracted_period_edit = QtWidgets.QLineEdit(self)
        self.subtracted_period_edit.setText("")
        period_validator = QtGui.QRegExpValidator(reg_ex,
                                                  self.subtracted_period_edit)
        self.subtracted_period_edit.setValidator(period_validator)

        self.horizontal_layout_2 = QtWidgets.QHBoxLayout()
        self.horizontal_layout_2.setObjectName("horizontalLayout2")
        self.horizontal_layout_2.addWidget(self.period_label)
        self.horizontal_layout_2.addStretch(0)
        self.horizontal_layout_2.addWidget(self.summed_period_edit)
        self.horizontal_layout_2.addSpacing(10)
        self.horizontal_layout_2.addWidget(self.minus_label)
        self.horizontal_layout_2.addSpacing(10)
        self.horizontal_layout_2.addWidget(self.subtracted_period_edit)

        self.group = QtWidgets.QGroupBox("Groups and Pairs")
        self.group.setFlat(False)
        self.setStyleSheet(
            "QGroupBox {border: 1px solid grey;border-radius: 10px;margin-top: 1ex; margin-right: 0ex}"
            "QGroupBox:title {"
            'subcontrol-origin: margin;'
            "padding: 0 3px;"
            'subcontrol-position: top center;'
            'padding-top: 0px;'
            'padding-bottom: 0px;'
            "padding-right: 10px;"
            ' color: grey; }')

        self.vertical_layout = QtWidgets.QVBoxLayout(self)
        self.vertical_layout.setObjectName("verticalLayout")
        self.vertical_layout.addItem(self.horizontal_layout)
        self.vertical_layout.addItem(self.horizontal_layout_2)
        if show_checks:
            self.all_groups_label = QtWidgets.QLabel(self)
            self.all_groups_label.setText("Apply to all groups : ")
            self.all_groups_checkbox = QtWidgets.QCheckBox(self)
            self.all_pairs_label = QtWidgets.QLabel(self)
            self.all_pairs_label.setText(
                "Apply to all pairs (alpha will not be applied)  : ")
            self.all_pairs_checkbox = QtWidgets.QCheckBox(self)

            self.horizontal_layout_3 = QtWidgets.QHBoxLayout()
            self.horizontal_layout_3.setObjectName("horizontalLayout2")
            self.horizontal_layout_3.addWidget(self.all_groups_label)
            self.horizontal_layout_3.addWidget(self.all_groups_checkbox)

            self.horizontal_layout_4 = QtWidgets.QHBoxLayout()
            self.horizontal_layout_4.addWidget(self.all_pairs_label)
            self.horizontal_layout_4.addWidget(self.all_pairs_checkbox)
            self.vertical_layout.addItem(self.horizontal_layout_3)
            self.vertical_layout.addItem(self.horizontal_layout_4)

        self.group.setLayout(self.vertical_layout)

        self.widget_layout = QtWidgets.QVBoxLayout(self)
        self.widget_layout.addWidget(self.group)
        self.setLayout(self.widget_layout)
Exemplo n.º 16
0
 def _build_ui(self):
     w = QtWidgets.QCheckBox()
     w.setChecked(self.params)
     w.toggled.connect(nonpartial(self.changed))
     return w
Exemplo n.º 17
0
    def __init__(self):
        super(PhaseWidget, self).__init__()

        self._layout = QtWidgets.QHBoxLayout()
        self._layout.setContentsMargins(5, 5, 5, 5)

        self.add_btn = FlatButton()
        self.edit_btn = FlatButton()
        self.delete_btn = FlatButton()
        self.clear_btn = FlatButton()
        self.save_list_btn = FlatButton('Save List')
        self.load_list_btn = FlatButton('Load List')

        self.button_widget = QtWidgets.QWidget(self)
        self.button_widget.setObjectName('phase_control_button_widget')
        self._button_layout = QtWidgets.QVBoxLayout()
        self._button_layout.setContentsMargins(0, 0, 0, 0)
        self._button_layout.setSpacing(6)

        self._button_layout.addWidget(self.add_btn)
        self._button_layout.addWidget(self.edit_btn)
        self._button_layout.addWidget(HorizontalLine())
        self._button_layout.addWidget(HorizontalLine())
        self._button_layout.addWidget(self.delete_btn)
        self._button_layout.addWidget(HorizontalLine())
        self._button_layout.addWidget(HorizontalLine())
        self._button_layout.addWidget(self.clear_btn)
        self._button_layout.addSpacerItem(VerticalSpacerItem())
        self.button_widget.setLayout(self._button_layout)
        self._layout.addWidget(self.button_widget)

        self.parameter_widget = QtWidgets.QWidget()

        self._parameter_layout = QtWidgets.QVBoxLayout()
        self._parameter_layout.setContentsMargins(0, 0, 0, 0)
        self._parameter_layout.setSpacing(4)

        self.pressure_step_msb = DoubleMultiplySpinBoxAlignRight()
        self.temperature_step_msb = DoubleMultiplySpinBoxAlignRight()
        self.apply_to_all_cb = QtWidgets.QCheckBox('apply to all')

        self._parameter_layout.addWidget(QtWidgets.QLabel('P step'))
        self._parameter_layout.addWidget(self.pressure_step_msb)
        self._parameter_layout.addWidget(QtWidgets.QLabel('T Step'))
        self._parameter_layout.addWidget(self.temperature_step_msb)
        self._parameter_layout.addWidget(self.apply_to_all_cb)
        self._parameter_layout.addWidget(HorizontalLine())
        self._parameter_layout.addItem(VerticalSpacerItem())
        self._parameter_layout.addWidget(self.save_list_btn)
        self._parameter_layout.addWidget(self.load_list_btn)

        self.parameter_widget.setLayout(self._parameter_layout)

        self._body_layout = QtWidgets.QHBoxLayout()

        self.phase_tw = ListTableWidget(columns=5)
        self.phase_tw.setObjectName('phase_table_widget')
        self.phase_tw.setHorizontalHeaderLabels(
            ['', '', 'Name', 'P (GPa)', 'T (K)'])
        self.phase_tw.horizontalHeader().setVisible(True)
        self.phase_tw.horizontalHeader().setStretchLastSection(False)
        self.phase_tw.setColumnWidth(0, 20)
        self.phase_tw.setColumnWidth(1, 25)
        self.phase_tw.horizontalHeader().setResizeMode(
            2, QtWidgets.QHeaderView.Stretch)
        self.phase_tw.horizontalHeader().setResizeMode(
            3, QtWidgets.QHeaderView.ResizeToContents)
        self.phase_tw.horizontalHeader().setResizeMode(
            4, QtWidgets.QHeaderView.ResizeToContents)
        self.phase_tw.setItemDelegate(NoRectDelegate())
        self._body_layout.addWidget(self.phase_tw, 10)
        self._body_layout.addWidget(self.parameter_widget, 0)

        self._layout.addLayout(self._body_layout)

        # label for alternative view:
        self.phase_header_btn = FlatButton('Phase')
        self.phase_header_btn.setEnabled(False)
        self.phase_header_btn.setVisible(False)
        self._main_layout = QtWidgets.QVBoxLayout()
        self._main_layout.setContentsMargins(0, 0, 0, 0)
        self._main_layout.addWidget(self.phase_header_btn)
        self._main_layout.addLayout(self._layout)
        self.setLayout(self._main_layout)
        self.style_widgets()
        self.add_tooltips()

        self.phase_show_cbs = []
        self.phase_color_btns = []
        self.pressure_sbs = []
        self.temperature_sbs = []

        self.show_parameter_in_pattern = True
Exemplo n.º 18
0
    def __init__(self, parent, checker_options):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        help_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().help, self._ShowHelp)
        help_button.setToolTip('Show help regarding these checker options.')

        help_hbox = ClientGUICommon.WrapInText(help_button, self,
                                               'help for this panel -->',
                                               QG.QColor(0, 0, 255))

        from hydrus.client import ClientDefaults

        defaults_panel = ClientGUICommon.StaticBox(self, 'reasonable defaults')

        defaults_1 = ClientGUICommon.BetterButton(
            defaults_panel, 'thread', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('thread'))
        defaults_2 = ClientGUICommon.BetterButton(
            defaults_panel, 'slow thread', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('slow thread'))
        defaults_3 = ClientGUICommon.BetterButton(
            defaults_panel, 'faster tag subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('fast tag subscription'))
        defaults_4 = ClientGUICommon.BetterButton(
            defaults_panel, 'medium tag/artist subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('artist subscription'))
        defaults_5 = ClientGUICommon.BetterButton(
            defaults_panel, 'slower tag subscription', self.SetValue,
            ClientDefaults.GetDefaultCheckerOptions('slow tag subscription'))

        #

        # add statictext or whatever that will update on any updates above to say 'given velocity of blah and last check at blah, next check in 5 mins'
        # or indeed this could just take the file_seed cache and last check of the caller, if there is one
        # this would be more useful to the user, to know 'right, on ok, it'll refresh in 30 mins'
        # this is actually more complicated--it also needs last check time to calc a fresh file velocity based on new death_file_velocity

        #

        min_unit_value = 0
        max_unit_value = 1000
        min_time_delta = 60

        self._death_file_velocity = VelocityCtrl(self,
                                                 min_unit_value,
                                                 max_unit_value,
                                                 min_time_delta,
                                                 days=True,
                                                 hours=True,
                                                 minutes=True,
                                                 per_phrase='in',
                                                 unit='files')

        self._flat_check_period_checkbox = QW.QCheckBox(self)

        #

        if HG.client_controller.new_options.GetBoolean('advanced_mode'):

            never_faster_than_min = 1
            never_slower_than_min = 1

            flat_check_period_min = 1

        else:

            never_faster_than_min = 30
            never_slower_than_min = 600

            flat_check_period_min = 180

        self._reactive_check_panel = ClientGUICommon.StaticBox(
            self, 'reactive checking')

        self._intended_files_per_check = QP.MakeQSpinBox(
            self._reactive_check_panel, min=1, max=1000)

        self._never_faster_than = TimeDeltaCtrl(self._reactive_check_panel,
                                                min=never_faster_than_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)

        self._never_slower_than = TimeDeltaCtrl(self._reactive_check_panel,
                                                min=never_slower_than_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)

        #

        self._static_check_panel = ClientGUICommon.StaticBox(
            self, 'static checking')

        self._flat_check_period = TimeDeltaCtrl(self._static_check_panel,
                                                min=flat_check_period_min,
                                                days=True,
                                                hours=True,
                                                minutes=True,
                                                seconds=True)

        #

        self.SetValue(checker_options)

        #

        defaults_panel.Add(defaults_1, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_2, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_3, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_4, CC.FLAGS_EXPAND_PERPENDICULAR)
        defaults_panel.Add(defaults_5, CC.FLAGS_EXPAND_PERPENDICULAR)

        #

        #

        rows = []

        rows.append(
            ('intended new files per check: ', self._intended_files_per_check))
        rows.append(
            ('never check faster than once per: ', self._never_faster_than))
        rows.append(
            ('never check slower than once per: ', self._never_slower_than))

        gridbox = ClientGUICommon.WrapInGrid(self._reactive_check_panel, rows)

        self._reactive_check_panel.Add(gridbox,
                                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        rows = []

        rows.append(('check period: ', self._flat_check_period))

        gridbox = ClientGUICommon.WrapInGrid(self._static_check_panel, rows)

        self._static_check_panel.Add(gridbox,
                                     CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        rows = []

        rows.append(('stop checking if new files found falls below: ',
                     self._death_file_velocity))
        rows.append(('just check at a static, regular interval: ',
                     self._flat_check_period_checkbox))

        gridbox = ClientGUICommon.WrapInGrid(self, rows)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, help_hbox, CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, defaults_panel, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        if HG.client_controller.new_options.GetBoolean('advanced_mode'):

            label = 'As you are in advanced mode, these options have extremely low limits. This is intended only for testing and small scale private network tasks. Do not use very fast check times for real world use on public websites, as it is wasteful and rude, hydrus will be overloaded with high-CPU parsing work, and you may get your IP banned.'

            st = ClientGUICommon.BetterStaticText(self, label=label)
            st.setObjectName('HydrusWarning')

            st.setWordWrap(True)

            QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox, self._reactive_check_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._static_check_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)

        self.widget().setLayout(vbox)

        #

        self._flat_check_period_checkbox.clicked.connect(
            self.EventFlatPeriodCheck)
Exemplo n.º 19
0
    def __init__(self, *args, **kwargs):

        clickpoints.Addon.__init__(self, *args, **kwargs)

        self.frame_number = except_error(self.db.getImageCount, TypeError, print_error=False, return_v=None)
        # information about the path, image dimensions
        self.db_info, self.all_frames = get_db_info_for_analysis(self.db)
        print_db_info(self.db_info)

        self.res_dict = defaultdict(list)  # dictionary that catches all results
        self.masks = None
        self.parameter_dict = copy.deepcopy(default_parameters)  # loading default parameters
        self.read_or_set_options()  # reading the database folder and the previous FEM_mode, or fill in default values
        self.outfile_path = os.path.join(self.folder, "out.txt")  # path for output text file
        self.config_path = os.path.join(self.folder, "config.yaml")

        # loading some default settings
        if os.path.exists(self.config_path):
            print("found config at", self.config_path)
            self.parameter_dict = load_config(self.config_path, self.parameter_dict)
        # QT settings overwrite "default_parameters"
        # reading Qt settings file
        # on linux this file is saved at /home/user/.config/pyTFM
        self.settings = QSettings("pyTFM", "pyTFM")
        for key in self.parameter_dict.keys():
            if not self.settings.value(key) is None:
                self.parameter_dict[key] = self.settings.value(key)

        # TODO: consider to save settings in each database separately

        """ GUI Widgets"""
        # set the title and layout
        self.setWindowTitle("pyTFM" + "-" + pyTFM.__version__)
        self.setWindowIcon(qta.icon("fa.compress"))
        self.setMinimumWidth(400)
        self.setMinimumHeight(200)
        self.layout = QtWidgets.QGridLayout(self)
        self.layout.setColumnMinimumWidth(0, 150)

        # button to start calculation
        self.button_start = QtWidgets.QPushButton("start")
        self.button_start.clicked.connect(partial(self.start_thread, run_function=self.start))
        self.button_start.setToolTip(tooltips["button_start"])
        self.layout.addWidget(self.button_start, 0, 0)

        # button to select images:
        self.button_select_images = QtWidgets.QPushButton("image selection")
        self.button_select_images.clicked.connect(self.select_images)
        self.button_select_images.setToolTip(tooltips["image selection"])
        self.sub_layout1 = QtWidgets.QHBoxLayout()
        self.sub_layout1.addWidget(self.button_select_images)
        self.sub_layout1.addStretch()
        self.layout.addLayout(self.sub_layout1, 1, 0)

        # button to apply drift correction:
        self.correct_drift = QtWidgets.QPushButton("correct drift")
        self.correct_drift.clicked.connect(partial(self.start_thread, run_function=self.drift_correction))
        self.correct_drift.setToolTip(tooltips["correct drift"])
        self.sub_layout2 = QtWidgets.QHBoxLayout()
        self.sub_layout2.addWidget(self.correct_drift)
        self.sub_layout2.addStretch()
        self.layout.addLayout(self.sub_layout2, 2, 0)

        # check_boxes
        self.check_box_def = QtWidgets.QCheckBox("deformation")
        self.check_box_tra = QtWidgets.QCheckBox("traction forces")
        self.check_box_FEM = QtWidgets.QCheckBox("stress analysis")
        self.check_box_contract = QtWidgets.QCheckBox("force generation")

        self.check_box_def.setToolTip(tooltips["check_box_def"])
        self.check_box_tra.setToolTip(tooltips["check_box_tra"])
        self.check_box_FEM.setToolTip(tooltips["check_box_FEM"])
        self.check_box_contract.setToolTip(tooltips["check_box_contract"])

        self.layout.addWidget(self.check_box_def, 0, 1)
        self.layout.addWidget(self.check_box_tra, 1, 1)
        self.layout.addWidget(self.check_box_FEM, 2, 1)
        self.layout.addWidget(self.check_box_contract, 3, 1)

        # a gap
        self.layout.setRowMinimumHeight(4, 20)

        # # choosing single or all frames
        self.analysis_mode = QtWidgets.QComboBox()
        self.analysis_mode.addItems(["current frame", "all frames"])
        self.analysis_mode.setToolTip(tooltips["apply to"])
        self.layout.addWidget(self.analysis_mode, 5, 1)
        self.analysis_mode_descript = QtWidgets.QLabel()
        self.analysis_mode_descript.setText("apply to")
        self.layout.addWidget(self.analysis_mode_descript, 5, 0)

        # parameters
        self.parameter_labels = ["Youngs modulus [Pa]", "Poisson's ratio", "pixel size [µm]", "PIV overlap [µm]",
                                 "PIV window size [µm]", "gel height [µm]"]
        self.param_dict_keys = ["young", "sigma", "pixelsize", "overlap", "window_size", "h"]
        self.parameter_widgets, self.parameter_lables, last_line = add_parameter_from_list(self.parameter_labels,
                                                                                           self.param_dict_keys,
                                                                                           self.parameter_dict,
                                                                                           self.layout,
                                                                                           6, self.parameters_changed)

        # adding to layout
        self.setLayout(self.layout)
        self.parameters_changed()  # initialize parameters dict

        # choosing type of cell system
        self.colony_type = QtWidgets.QComboBox()
        self.colony_type.addItems(["colony", "cell layer"])
        self.colony_type.setToolTip(tooltips["switch mode"])
        self.colony_type.setCurrentIndex(self.parameter_dict["FEM_mode_id"])
        # update parameters
        self.colony_type.currentTextChanged.connect(self.parameters_changed)
        # switch between cell layer and colony mode
        self.colony_type.currentTextChanged.connect(self.switch_colony_type_mode)
        self.parameter_widgets["FEM_mode"] = self.colony_type  # adding to parameters dict
        self.parameter_lables["FEM_mode"] = ""  # label
        self.sub_layout3 = QtWidgets.QHBoxLayout()
        self.sub_layout3.addWidget(self.colony_type)

        # button for simple segmentation of membranes and cell area
        self.button_seg = QtWidgets.QPushButton("segmentation")
        self.button_seg.setToolTip(tooltips["segmentation"])
        self.button_seg.clicked.connect(self.segmentation)  # update parameters
        self.sub_layout3.addWidget(self.button_seg)
        self.sub_layout3.addStretch()
        self.layout.addLayout(self.sub_layout3, 3, 0)
Exemplo n.º 20
0
    def __init__(self,
                 parent,
                 min=1,
                 days=False,
                 hours=False,
                 minutes=False,
                 seconds=False,
                 monthly_allowed=False,
                 monthly_label='monthly'):

        QW.QWidget.__init__(self, parent)

        self._min = min
        self._show_days = days
        self._show_hours = hours
        self._show_minutes = minutes
        self._show_seconds = seconds
        self._monthly_allowed = monthly_allowed

        hbox = QP.HBoxLayout(margin=0)

        if self._show_days:

            self._days = QP.MakeQSpinBox(self, min=0, max=3653, width=50)
            self._days.valueChanged.connect(self.EventChange)

            QP.AddToLayout(hbox, self._days, CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, 'days'),
                           CC.FLAGS_CENTER_PERPENDICULAR)

        if self._show_hours:

            self._hours = QP.MakeQSpinBox(self, min=0, max=23, width=45)
            self._hours.valueChanged.connect(self.EventChange)

            QP.AddToLayout(hbox, self._hours, CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, 'hours'),
                           CC.FLAGS_CENTER_PERPENDICULAR)

        if self._show_minutes:

            self._minutes = QP.MakeQSpinBox(self, min=0, max=59, width=45)
            self._minutes.valueChanged.connect(self.EventChange)

            QP.AddToLayout(hbox, self._minutes, CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, 'minutes'),
                           CC.FLAGS_CENTER_PERPENDICULAR)

        if self._show_seconds:

            self._seconds = QP.MakeQSpinBox(self, min=0, max=59, width=45)
            self._seconds.valueChanged.connect(self.EventChange)

            QP.AddToLayout(hbox, self._seconds, CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, 'seconds'),
                           CC.FLAGS_CENTER_PERPENDICULAR)

        if self._monthly_allowed:

            self._monthly = QW.QCheckBox(self)
            self._monthly.clicked.connect(self.EventChange)

            QP.AddToLayout(hbox, self._monthly, CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(
                hbox, ClientGUICommon.BetterStaticText(self, monthly_label),
                CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)
Exemplo n.º 21
0
    def _build(self):
        _layout = QtWidgets.QVBoxLayout(self)
        _layout.setSpacing(2)
        _layout.setContentsMargins(2, 2, 2, 2)

        # # current project widget
        # self.project_frame = QtWidgets.QFrame()
        # _layout.addWidget(self.project_frame)
        # self.project_layout = QtWidgets.QHBoxLayout(self.project_frame)
        # self.project_label = QtWidgets.QLabel()
        # self.project_label.setText(u'当前项目名:')
        # self.project_layout.addWidget(self.project_label)

        # contant widget
        self.contant_widget = QtWidgets.QFrame()
        _layout.addWidget(self.contant_widget)
        self.contant_layout = QtWidgets.QHBoxLayout(self.contant_widget)
        self.contant_layout.setSpacing(2)
        self.contant_layout.setContentsMargins(2,2,2,2)

        self.filter_widget = filter_widget.FilterWidget()
        self.contant_layout.addWidget(self.filter_widget)

        # scroll widget
        self.scroll_widget = QtWidgets.QScrollArea()
        self.contant_layout.addWidget(self.scroll_widget)
        self.scroll_widget.setWidgetResizable(True)
        self.scroll_widget.setBackgroundRole(QtGui.QPalette.NoRole)
        self.scroll_widget.setFrameShape(QtWidgets.QFrame.NoFrame)

        self.check_widget = QtWidgets.QFrame()
        self.scroll_widget.setWidget(self.check_widget)
        self.check_layout = QtWidgets.QVBoxLayout(self.check_widget)
        self.check_layout.setSpacing(0)
        self.check_layout.setContentsMargins(0,0,0,0)
         
        # self.check_infolayout = QtWidgets.QHBoxLayout()
        # self.check_infolayout.setContentsMargins(2,2,2,2)
        # self.check_layout.addLayout(self.check_infolayout)
        # self.check_label = QtWidgets.QLabel()
        # self.check_infolayout.addWidget(self.check_label) 
         
        self.check_listlayout = QtWidgets.QVBoxLayout()
        self.check_listlayout.setContentsMargins(2,2,2,2)
        self.check_layout.addLayout(self.check_listlayout)
        self.check_layout.addStretch(True)

        # operation widget
        self.operation_widget = QtWidgets.QWidget()
        _layout.addWidget(self.operation_widget)
        self.operation_layout = QtWidgets.QHBoxLayout(self.operation_widget)
        self.operation_layout.setSpacing(4)
        self.operation_layout.setContentsMargins(0,0,0,0)
        # show all item widget
        self.show_all_checkbox = QtWidgets.QCheckBox()
        self.show_all_checkbox.setText(u"显示所有检查面板")
        self.show_all_checkbox.setChecked(True)
        self.operation_layout.addWidget(self.show_all_checkbox)
        self.operation_layout.addStretch(True)
        # recheck button
        self.recheck_button = QtWidgets.QPushButton()
        self.recheck_button.setMinimumSize(100,30)
        self.operation_layout.addWidget(self.recheck_button)
        self.recheck_button.setText(u"检查")
Exemplo n.º 22
0
    def __init__(self, *args, **kwargs):
        super(Fit2dParametersWidget, self).__init__(*args, **kwargs)

        self._layout = QtWidgets.QGridLayout()

        self._layout.addWidget(LabelAlignRight('Distance:'), 0, 0)
        self.distance_txt = NumberTextField()
        self.distance_cb = QtWidgets.QCheckBox()
        self.distance_cb.setChecked(True)
        self._layout.addWidget(self.distance_txt, 0, 1)
        self._layout.addWidget(QtWidgets.QLabel('mm'), 0, 2)
        self._layout.addWidget(self.distance_cb, 0, 3)

        self._layout.addWidget(LabelAlignRight('Wavelength:'), 1, 0)
        self.wavelength_txt = NumberTextField()
        self.wavelength_cb = QtWidgets.QCheckBox()
        self._layout.addWidget(self.wavelength_txt, 1, 1)
        self._layout.addWidget(QtWidgets.QLabel('A'), 1, 2)
        self._layout.addWidget(self.wavelength_cb, 1, 3)

        self._layout.addWidget(LabelAlignRight('Polarization:'), 2, 0)
        self.polarization_txt = NumberTextField()
        self._layout.addWidget(self.polarization_txt, 2, 1)

        self._layout.addWidget(LabelAlignRight('Center X:'), 3, 0)
        self.center_x_txt = NumberTextField()
        self._layout.addWidget(self.center_x_txt, 3, 1)
        self._layout.addWidget(QtWidgets.QLabel('px'), 3, 2)

        self._layout.addWidget(LabelAlignRight('Center Y:'), 4, 0)
        self.center_y_txt = NumberTextField()
        self._layout.addWidget(self.center_y_txt, 4, 1)
        self._layout.addWidget(QtWidgets.QLabel('px'), 4, 2)

        self._layout.addWidget(LabelAlignRight('Rotation:'), 5, 0)
        self.rotation_txt = NumberTextField()
        self._layout.addWidget(self.rotation_txt, 5, 1)
        self._layout.addWidget(QtWidgets.QLabel('deg'), 5, 2)

        self._layout.addWidget(LabelAlignRight('Tilt:'), 6, 0)
        self.tilt_txt = NumberTextField()
        self._layout.addWidget(self.tilt_txt, 6, 1)
        self._layout.addWidget(QtWidgets.QLabel('deg'), 6, 2)

        self._layout.addWidget(LabelAlignRight('Pixel width:'), 8, 0)
        self.pixel_width_txt = NumberTextField()
        self._layout.addWidget(self.pixel_width_txt, 8, 1)
        self._layout.addWidget(QtWidgets.QLabel('um'))

        self._layout.addWidget(LabelAlignRight('Pixel height:'), 9, 0)
        self.pixel_height_txt = NumberTextField()
        self._layout.addWidget(self.pixel_height_txt, 9, 1)
        self._layout.addWidget(QtWidgets.QLabel('um'))

        self.update_btn = FlatButton('update')
        self._layout.addWidget(self.update_btn, 10, 0, 1, 4)

        self._layout.addItem(QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding),
                             11, 0, 1, 4)

        self.setLayout(self._layout)
Exemplo n.º 23
0
    def __init__(self, parameter, layout):
        """
        Initialize the widget

        :param parameter: The parameter object for which the widget should be created.
        :param layout: The layout into which the widget should be inserted.
        """
        # call the super class initialization
        super().__init__()

        # if a layout is given add the widget to the layout
        if layout is not None:
            layout.addWidget(self)

        # store the parameter object
        self.parameter = parameter

        # store the type of the parameter
        self.type = parameter.type

        # add a layout for this widget (with 0 margins)
        self.main_layout = QtWidgets.QHBoxLayout(self)
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        """ value selector """
        # add subwidget for value selection of this widget (with 0 margins)
        self.widget_parameter = QtWidgets.QWidget()
        self.main_layout.addWidget(self.widget_parameter)

        # add a layout
        self.layout = QtWidgets.QHBoxLayout(self.widget_parameter)
        self.layout.setContentsMargins(0, 0, 0, 0)

        # add a label containing the parameters name
        self.label = QtWidgets.QLabel(parameter.name)
        self.layout.addWidget(self.label)

        # add a stretch
        self.layout.addStretch()

        # if the parameter has a description, add a tooltip
        if self.parameter.desc is not None:
            self.setToolTip(self.parameter.desc)
        """ range selector """
        # add a subwidget for the range selector
        self.widget_range = QtWidgets.QWidget()
        self.main_layout.addWidget(self.widget_range)

        # add a layout
        self.layoutRange = QtWidgets.QHBoxLayout(self.widget_range)
        self.layoutRange.setContentsMargins(0, 0, 0, 0)

        # add a label containing the parameters name
        self.label = QtWidgets.QLabel(parameter.name)
        self.layoutRange.addWidget(self.label)
        self.layoutRange.addStretch()

        # add a checkbox to specify if the value should be fixed and not optimized
        self.checkbox_fixed = QtWidgets.QCheckBox("fixed")
        self.checkbox_fixed.stateChanged.connect(self.rangeChanged)
        self.layoutRange.addWidget(self.checkbox_fixed)

        self.displayRanges(False)
Exemplo n.º 24
0
def window():
    # Variables

    app = wid.QApplication(sys.argv)
    tabs = wid.QTabWidget()

    # Create tabs
    tab1 = wid.QWidget()
    tab2 = wid.QWidget()
    tab4 = wid.QWidget()

    tabs.resize(1200, 800)

    #Primera Tab
    tab_1 = wid.QVBoxLayout()
    licence = (
        "Trabajo de Inteligencia Artificial" +
        " \n Sistema experto para la deteccion de transtornos psicologicos mas comunes"
        + "\n \n Alumnos: \n" + "Gabriel Ramirez Reategui \n" +
        "Ricardo Andre Bueno Carrasco \n" + "Franco Pastor  \n")
    text0 = wid.QLabel(licence)
    text0.setWordWrap(True)
    tab_1.addWidget(text0)
    tab1.setLayout(tab_1)

    #Segunda Tab
    tab_2 = wid.QGridLayout()
    #textbox
    lx = wid.QLabel()
    lx.setText("Nombre del Paciente:")

    tb = wid.QLineEdit()
    tab_2.addWidget(tb, 0, 4)
    pushButton1 = wid.QPushButton("Usar S.E.")

    tab_2.addWidget(lx, 0, 3)
    checkboxs = []
    checkboxs.append(wid.QCheckBox("preocupacion_por_imagen"))
    checkboxs.append(wid.QCheckBox("perdida_de_interes"))
    checkboxs.append(wid.QCheckBox("dificultad_respiracion"))
    checkboxs.append(wid.QCheckBox("robos_sin_ganancia"))
    checkboxs.append(wid.QCheckBox("necesidad_orinar_o_defecar"))
    checkboxs.append(wid.QCheckBox("humor_depresivo_anormal"))
    checkboxs.append(wid.QCheckBox("alucinaciones_persistenes"))
    checkboxs.append(wid.QCheckBox("incapacidad_recordar_acontecimiento"))
    checkboxs.append(wid.QCheckBox("transtorno_endocrino"))
    checkboxs.append(wid.QCheckBox("autoinduccion_perdida_peso"))
    checkboxs.append(wid.QCheckBox("escalofrios"))
    checkboxs.append(wid.QCheckBox("intencion_de_resistencia"))
    checkboxs.append(wid.QCheckBox("bajo_peso"))
    checkboxs.append(wid.QCheckBox("obsesiones"))
    checkboxs.append(wid.QCheckBox("pensamientos_suicidas"))
    checkboxs.append(wid.QCheckBox("ideas_de_control"))
    checkboxs.append(wid.QCheckBox("sequedad_boca"))
    checkboxs.append(wid.QCheckBox("jugar_sin_provecho_economico"))
    checkboxs.append(wid.QCheckBox("discurso_incoherente"))
    checkboxs.append(wid.QCheckBox("dolor_pecho"))
    checkboxs.append(wid.QCheckBox("compulsiones"))
    checkboxs.append(wid.QCheckBox("sensacion_ahogo"))
    checkboxs.append(wid.QCheckBox("preocupacion_por_juego"))
    checkboxs.append(wid.QCheckBox("miedo_muerte"))
    checkboxs.append(wid.QCheckBox("disminucion_de_energia"))
    checkboxs.append(wid.QCheckBox("agitacion_o_enlentecimiento"))
    checkboxs.append(wid.QCheckBox("alivio_de_tension_al_robar"))
    checkboxs.append(wid.QCheckBox("disgusto"))
    checkboxs.append(wid.QCheckBox("hormigueo"))
    checkboxs.append(wid.QCheckBox("distorcion_imagen_corporal"))
    checkboxs.append(wid.QCheckBox("ideas_de_poder"))
    checkboxs.append(wid.QCheckBox("temblores"))
    checkboxs.append(wid.QCheckBox("recuerdos_recurrentes_acontecimiento"))
    checkboxs.append(wid.QCheckBox("repitencia_perjudicial"))
    checkboxs.append(wid.QCheckBox("alteracion_de_sueno"))
    checkboxs.append(wid.QCheckBox("indecision"))
    checkboxs.append(wid.QCheckBox("enfermedad"))
    checkboxs.append(wid.QCheckBox("miedo_social"))
    checkboxs.append(wid.QCheckBox("miedo_multitudes"))
    checkboxs.append(wid.QCheckBox("cambio_apetito"))
    checkboxs.append(wid.QCheckBox("evitacion_similar_recuerdo"))
    checkboxs.append(wid.QCheckBox("hipersensibilidad_psicologica"))
    checkboxs.append(wid.QCheckBox("miedo_humillacion"))
    checkboxs.append(wid.QCheckBox("conductas_catatonicas"))
    checkboxs.append(wid.QCheckBox("miedo_humillacion"))
    checkboxs.append(wid.QCheckBox("miedo_vomitar"))
    checkboxs.append(wid.QCheckBox("miedo_humillacion"))
    checkboxs.append(wid.QCheckBox("o_c_reiteradas_y_desagradables"))
    checkboxs.append(wid.QCheckBox("sudoracion"))
    checkboxs.append(wid.QCheckBox("palpitaciones"))
    checkboxs.append(wid.QCheckBox("situacion_extrema_estres"))
    checkboxs.append(wid.QCheckBox("miedo_viajar_lejos"))
    checkboxs.append(wid.QCheckBox("impulso_robar"))
    checkboxs.append(wid.QCheckBox("miedo_viajar_solo"))
    checkboxs.append(wid.QCheckBox("sintomas_negativos"))
    checkboxs.append(wid.QCheckBox("miedo_lugares_publicos"))
    checkboxs.append(wid.QCheckBox("perdida_de_confianza"))
    checkboxs.append(wid.QCheckBox("ruborizacion"))
    checkboxs.append(wid.QCheckBox("ideas_delirantes"))
    checkboxs.append(wid.QCheckBox("impulso_de_jugar"))
    checkboxs.append(wid.QCheckBox("mareos"))
    checkboxs.append(wid.QCheckBox("preocupacion_por_peso"))
    checkboxs.append(wid.QCheckBox("alteracion_del_pensamiento"))
    checkboxs.append(wid.QCheckBox("incapacidad_dejar_jugar"))
    checkboxs.append(wid.QCheckBox("culpa_excesiva"))
    checkboxs.append(wid.QCheckBox("preocupacion_por_peso"))
    checkboxs.append(wid.QCheckBox("miedo_atencion"))

    #we add all the checkboks
    for i in range(0, 3):
        for n in range(0, 22):
            tab_2.addWidget(checkboxs[n + i * 22], n, i)
    tab_2.addWidget(checkboxs[66], 21, 3)

    tab2.setLayout(tab_2)

    def selector():
        #for i in range(0,np.size(checkboxs,0)):
        value = tb.text()
        print(value)
        for i in range(0, np.size(checkboxs, 0)):
            if (checkboxs[i].isChecked()):
                print("Se ha agregado: ", checkboxs[i].text())
                lg.A.add_rule(checkboxs[i].text(), value)

        a = lg.tiene_depresion(value)
        b = lg.tiene_esquizofrenia(value)
        c = lg.tiene_toc(value)
        d = lg.tiene_fobia_social(value)
        e = lg.tiene_agorafobia(value)
        f = lg.tiene_anorexia(value)
        g = lg.tiene_cleptomania(value)
        h = lg.tiene_ludopatia(value)
        i = lg.tiene_pos_traumatico(value)
        print(c)
        text = "Los resultados son: " + (
            a * "Depresion" + " " + b * "esquizofrenia " + c * "toc " +
            d * "Fobia Social " + e * "agorafobia " + f * "anorexia" +
            g * "cleptomania " + h * "ludopatia " + i * "Estres postraumatico")
        msg = wid.QMessageBox()
        msg.setIcon(wid.QMessageBox.Information)
        msg.setText("Usted puede tener las siguientes enfermedades: ")
        msg.setWindowTitle("Resultado")
        msg.setDetailedText(text)
        msg.exec_()
        pass

    pushButton1.clicked.connect(selector)
    #Cuarta Tab

    tab_4 = wid.QVBoxLayout()
    licence = (
        "El sistema experto asi como el codigo del mismo se libera bajo la licencia de codigo Abierto para cualquier persona pueda leer, modificar y reutilizar el codigo"
        +
        " \n Este software fue desarrollado en conjunto por los alumnos de la universidad de ciencias aplicadas"
        +
        " para el curso de Inteligencia Artificial de la carrera de Ciencias de la Computacion"
        + "\n \n Alumnos: \n" + "Gabriel Ramirez Reategui \n" +
        "Ricardo Andre Bueno Carrasco \n" + "Franco Pastor  \n")
    text1 = wid.QLabel(licence)
    text1.setWordWrap(True)
    tab_4.addWidget(text1)
    tab4.setLayout(tab_4)

    ## information
    l1 = wid.QLabel()
    l1.setText(
        "Entrar a la tabla Sistema Experto, seleccionar sintomas y hacer clic en S.E para probar, no olvidar poner nombre"
    )
    l1.setGeometry(200, 200, 600, 600)
    tab_1.addWidget(l1)
    tab1.setLayout(tab_1)
    # Add tabs
    tabs.addTab(tab1, "Introduccion")
    tabs.addTab(tab2, "Sistema Experto")
    tabs.addTab(tab4, "licencia")

    # Titulos e informacion
    tabs.setWindowTitle(
        'Trabajo de Inteligencia Artificial: Sistema experto para Enfermedades mentales mas comunes'
    )
    tabs.show()
    sys.exit(app.exec_())
Exemplo n.º 25
0
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(637, 663)
        Dialog.setSizeGripEnabled(True)
        Dialog.setModal(True)
        self.main_layout = QtWidgets.QVBoxLayout(Dialog)
        self.main_layout.setObjectName("main_layout")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.path_label = QtWidgets.QLabel(Dialog)
        self.path_label.setObjectName("path_label")
        self.horizontalLayout_2.addWidget(self.path_label)
        self.path_edit = QtWidgets.QLineEdit(Dialog)
        self.path_edit.setObjectName("path_edit")
        self.horizontalLayout_2.addWidget(self.path_edit)
        self.choose_dir_button = QtWidgets.QToolButton(Dialog)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("icons:loadfile.png"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        self.choose_dir_button.setIcon(icon)
        self.choose_dir_button.setObjectName("choose_dir_button")
        self.horizontalLayout_2.addWidget(self.choose_dir_button)
        self.main_layout.addLayout(self.horizontalLayout_2)
        self.newfolder_option = QtWidgets.QCheckBox(Dialog)
        self.newfolder_option.setChecked(True)
        self.newfolder_option.setObjectName("newfolder_option")
        self.main_layout.addWidget(self.newfolder_option)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.filename_label = QtWidgets.QLabel(Dialog)
        self.filename_label.setObjectName("filename_label")
        self.horizontalLayout_3.addWidget(self.filename_label)
        self.filename_edit = QtWidgets.QLineEdit(Dialog)
        self.filename_edit.setClearButtonEnabled(True)
        self.filename_edit.setObjectName("filename_edit")
        self.horizontalLayout_3.addWidget(self.filename_edit)
        self.filename_suffix_label = QtWidgets.QLabel(Dialog)
        self.filename_suffix_label.setObjectName("filename_suffix_label")
        self.horizontalLayout_3.addWidget(self.filename_suffix_label)
        self.main_layout.addLayout(self.horizontalLayout_3)
        self.output_group = QtWidgets.QGroupBox(Dialog)
        self.output_group.setObjectName("output_group")
        self.output_layout = QtWidgets.QVBoxLayout(self.output_group)
        self.output_layout.setObjectName("output_layout")
        self.assembly_radio = QtWidgets.QRadioButton(self.output_group)
        self.assembly_radio.setChecked(True)
        self.assembly_radio.setObjectName("assembly_radio")
        self.output_layout.addWidget(self.assembly_radio)
        self.assembly_group = QtWidgets.QWidget(self.output_group)
        self.assembly_group.setObjectName("assembly_group")
        self.assembly_layout = QtWidgets.QVBoxLayout(self.assembly_group)
        self.assembly_layout.setObjectName("assembly_layout")
        self.assembly_label = QtWidgets.QLabel(self.assembly_group)
        self.assembly_label.setWordWrap(True)
        self.assembly_label.setObjectName("assembly_label")
        self.assembly_layout.addWidget(self.assembly_label)
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.link_radius_label = QtWidgets.QLabel(self.assembly_group)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                           QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.link_radius_label.sizePolicy().hasHeightForWidth())
        self.link_radius_label.setSizePolicy(sizePolicy)
        self.link_radius_label.setObjectName("link_radius_label")
        self.horizontalLayout_5.addWidget(self.link_radius_label)
        self.link_radius = QtWidgets.QDoubleSpinBox(self.assembly_group)
        self.link_radius.setMinimum(0.01)
        self.link_radius.setProperty("value", 10.0)
        self.link_radius.setObjectName("link_radius")
        self.horizontalLayout_5.addWidget(self.link_radius)
        spacerItem = QtWidgets.QSpacerItem(40, 20,
                                           QtWidgets.QSizePolicy.Expanding,
                                           QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_5.addItem(spacerItem)
        self.assembly_layout.addLayout(self.horizontalLayout_5)
        self.output_layout.addWidget(self.assembly_group)
        self.frame_radio = QtWidgets.QRadioButton(self.output_group)
        self.frame_radio.setObjectName("frame_radio")
        self.output_layout.addWidget(self.frame_radio)
        self.frame_group = QtWidgets.QWidget(self.output_group)
        self.frame_group.setEnabled(False)
        self.frame_group.setObjectName("frame_group")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.frame_group)
        self.verticalLayout.setObjectName("verticalLayout")
        self.frame_label = QtWidgets.QLabel(self.frame_group)
        self.frame_label.setWordWrap(True)
        self.frame_label.setObjectName("frame_label")
        self.verticalLayout.addWidget(self.frame_label)
        self.output_layout.addWidget(self.frame_group)
        self.main_layout.addWidget(self.output_group)
        self.groupBox = QtWidgets.QGroupBox(Dialog)
        self.groupBox.setObjectName("groupBox")
        self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.groupBox)
        self.verticalLayout_2.setObjectName("verticalLayout_2")
        self.overwrite_radio = QtWidgets.QRadioButton(self.groupBox)
        self.overwrite_radio.setChecked(True)
        self.overwrite_radio.setObjectName("overwrite_radio")
        self.verticalLayout_2.addWidget(self.overwrite_radio)
        self.warn_radio = QtWidgets.QRadioButton(self.groupBox)
        self.warn_radio.setObjectName("warn_radio")
        self.verticalLayout_2.addWidget(self.warn_radio)
        self.main_layout.addWidget(self.groupBox)
        spacerItem1 = QtWidgets.QSpacerItem(20, 158,
                                            QtWidgets.QSizePolicy.Minimum,
                                            QtWidgets.QSizePolicy.Expanding)
        self.main_layout.addItem(spacerItem1)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem2 = QtWidgets.QSpacerItem(40, 20,
                                            QtWidgets.QSizePolicy.Expanding,
                                            QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem2)
        self.button_box = QtWidgets.QDialogButtonBox(Dialog)
        self.button_box.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel
                                           | QtWidgets.QDialogButtonBox.Save)
        self.button_box.setObjectName("button_box")
        self.horizontalLayout.addWidget(self.button_box)
        self.main_layout.addLayout(self.horizontalLayout)

        self.retranslateUi(Dialog)
        self.button_box.rejected.connect(Dialog.reject)
        self.assembly_radio.toggled['bool'].connect(
            self.assembly_group.setEnabled)
        self.frame_radio.toggled['bool'].connect(self.frame_group.setEnabled)
        QtCore.QMetaObject.connectSlotsByName(Dialog)
Exemplo n.º 26
0
    def __init__(self, app: FastFlixApp, main, *args, **kwargs):
        super().__init__(None, *args, **kwargs)
        self.app = app
        self.main = main
        self.config_file = self.app.fastflix.config.config_path
        self.setWindowTitle(t("Settings"))
        self.setMinimumSize(600, 200)
        layout = QtWidgets.QGridLayout()

        ffmpeg_label = QtWidgets.QLabel("FFmpeg")
        self.ffmpeg_path = QtWidgets.QLineEdit()
        self.ffmpeg_path.setText(str(self.app.fastflix.config.ffmpeg))
        ffmpeg_path_button = QtWidgets.QPushButton(
            icon=self.style().standardIcon(QtWidgets.QStyle.SP_DirIcon))
        ffmpeg_path_button.clicked.connect(lambda: self.select_ffmpeg())
        layout.addWidget(ffmpeg_label, 0, 0)
        layout.addWidget(self.ffmpeg_path, 0, 1)
        layout.addWidget(ffmpeg_path_button, 0, 2)

        ffprobe_label = QtWidgets.QLabel("FFprobe")
        self.ffprobe_path = QtWidgets.QLineEdit()
        self.ffprobe_path.setText(str(self.app.fastflix.config.ffprobe))
        ffprobe_path_button = QtWidgets.QPushButton(
            icon=self.style().standardIcon(QtWidgets.QStyle.SP_DirIcon))
        ffprobe_path_button.clicked.connect(lambda: self.select_ffprobe())
        layout.addWidget(ffprobe_label, 1, 0)
        layout.addWidget(self.ffprobe_path, 1, 1)
        layout.addWidget(ffprobe_path_button, 1, 2)

        work_dir_label = QtWidgets.QLabel(t("Work Directory"))
        self.work_dir = QtWidgets.QLineEdit()
        self.work_dir.setText(str(self.app.fastflix.config.work_path))
        work_path_button = QtWidgets.QPushButton(
            icon=self.style().standardIcon(QtWidgets.QStyle.SP_DirIcon))
        work_path_button.clicked.connect(lambda: self.select_work_path())
        layout.addWidget(work_dir_label, 2, 0)
        layout.addWidget(self.work_dir, 2, 1)
        layout.addWidget(work_path_button, 2, 2)

        layout.addWidget(QtWidgets.QLabel("Config File"), 4, 0)
        layout.addWidget(QtWidgets.QLabel(str(self.config_file)), 4, 1)

        self.language_combo = QtWidgets.QComboBox(self)
        self.language_combo.addItems(known_language_list)
        try:
            index = known_language_list.index(
                Lang(self.app.fastflix.config.language).name)
        except (IndexError, InvalidLanguageValue):
            logger.exception(
                f"Could not find language for {self.app.fastflix.config.language}"
            )
            index = known_language_list.index("English")
        self.language_combo.setCurrentIndex(index)

        layout.addWidget(QtWidgets.QLabel(t("Language")), 5, 0)
        layout.addWidget(self.language_combo, 5, 1)

        config_button = QtWidgets.QPushButton(
            icon=self.style().standardIcon(QtWidgets.QStyle.SP_FileIcon))
        config_button.clicked.connect(lambda: QtGui.QDesktopServices.openUrl(
            QtCore.QUrl.fromLocalFile(str(self.config_file))))
        layout.addWidget(config_button, 4, 2)

        save = QtWidgets.QPushButton(icon=self.style().standardIcon(
            QtWidgets.QStyle.SP_DialogApplyButton),
                                     text="Save")
        save.clicked.connect(lambda: self.save())

        cancel = QtWidgets.QPushButton(icon=self.style().standardIcon(
            QtWidgets.QStyle.SP_DialogCancelButton),
                                       text="Cancel")
        cancel.clicked.connect(lambda: self.close())

        self.use_sane_audio = QtWidgets.QCheckBox(
            "Use Sane Audio Selection (updatable in config file)")
        if self.app.fastflix.config.use_sane_audio:
            self.use_sane_audio.setChecked(True)
        self.disable_version_check = QtWidgets.QCheckBox(
            "Disable update check on startup")
        if not self.app.fastflix.config.disable_version_check:
            self.disable_version_check.setChecked(False)
        elif self.app.fastflix.config.disable_version_check:
            self.disable_version_check.setChecked(True)

        layout.addWidget(self.use_sane_audio, 7, 0, 1, 2)
        layout.addWidget(self.disable_version_check, 8, 0, 1, 2)

        button_layout = QtWidgets.QHBoxLayout()
        button_layout.addStretch()
        button_layout.addWidget(cancel)
        button_layout.addWidget(save)

        layout.addLayout(button_layout, 11, 0, 1, 3)

        self.setLayout(layout)
Exemplo n.º 27
0
    def __init__(self, parent, export_folder):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._export_folder = export_folder

        (name, path, export_type, delete_from_client_after_export,
         file_search_context, run_regularly, period, phrase,
         self._last_checked, paused, run_now) = self._export_folder.ToTuple()

        self._path_box = ClientGUICommon.StaticBox(self, 'name and location')

        self._name = QW.QLineEdit(self._path_box)

        self._path = QP.DirPickerCtrl(self._path_box)

        #

        self._type_box = ClientGUICommon.StaticBox(self, 'type of export')

        self._type = ClientGUICommon.BetterChoice(self._type_box)
        self._type.addItem('regular', HC.EXPORT_FOLDER_TYPE_REGULAR)
        self._type.addItem('synchronise', HC.EXPORT_FOLDER_TYPE_SYNCHRONISE)

        self._delete_from_client_after_export = QW.QCheckBox(self._type_box)

        #

        self._query_box = ClientGUICommon.StaticBox(self, 'query to export')

        self._page_key = 'export folders placeholder'

        self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self._query_box,
            self._page_key,
            file_search_context,
            allow_all_known_files=False,
            force_system_everything=True)

        #

        self._period_box = ClientGUICommon.StaticBox(self, 'export period')

        self._period = ClientGUITime.TimeDeltaButton(self._period_box,
                                                     min=3 * 60,
                                                     days=True,
                                                     hours=True,
                                                     minutes=True)

        self._run_regularly = QW.QCheckBox(self._period_box)

        self._paused = QW.QCheckBox(self._period_box)

        self._run_now = QW.QCheckBox(self._period_box)

        #

        self._phrase_box = ClientGUICommon.StaticBox(self, 'filenames')

        self._pattern = QW.QLineEdit(self._phrase_box)

        self._examples = ClientGUICommon.ExportPatternButton(self._phrase_box)

        #

        self._name.setText(name)

        self._path.SetPath(path)

        self._type.SetValue(export_type)

        self._delete_from_client_after_export.setChecked(
            delete_from_client_after_export)

        self._period.SetValue(period)

        self._run_regularly.setChecked(run_regularly)

        self._paused.setChecked(paused)

        self._run_now.setChecked(run_now)

        self._pattern.setText(phrase)

        #

        rows = []

        rows.append(('name: ', self._name))
        rows.append(('folder path: ', self._path))

        gridbox = ClientGUICommon.WrapInGrid(self._path_box, rows)

        self._path_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        text = '''regular - try to export the files to the directory, overwriting if the filesize if different

synchronise - try to export the files to the directory, overwriting if the filesize if different, and delete anything else in the directory

If you select synchronise, be careful!'''

        st = ClientGUICommon.BetterStaticText(self._type_box, label=text)
        st.setWordWrap(True)

        self._type_box.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._type_box.Add(self._type, CC.FLAGS_EXPAND_PERPENDICULAR)

        rows = []

        rows.append(('delete files from client after export: ',
                     self._delete_from_client_after_export))

        gridbox = ClientGUICommon.WrapInGrid(self._type_box, rows)

        self._type_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        self._query_box.Add(self._tag_autocomplete)

        self._period_box.Add(self._period, CC.FLAGS_EXPAND_PERPENDICULAR)

        rows = []

        rows.append(('run regularly?: ', self._run_regularly))
        rows.append(('paused: ', self._paused))
        rows.append(('run on dialog ok: ', self._run_now))

        gridbox = ClientGUICommon.WrapInGrid(self._period_box, rows)

        self._period_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        phrase_hbox = QP.HBoxLayout()

        QP.AddToLayout(phrase_hbox, self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(phrase_hbox, self._examples, CC.FLAGS_VCENTER)

        self._phrase_box.Add(phrase_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._path_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._type_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._query_box, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._period_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._phrase_box, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.widget().setLayout(vbox)

        self._UpdateTypeDeleteUI()

        self._type.currentIndexChanged.connect(self._UpdateTypeDeleteUI)
        self._delete_from_client_after_export.clicked.connect(
            self.EventDeleteFilesAfterExport)
Exemplo n.º 28
0
 def __init__(self, parent=None):
     # pylint: disable=unused-argument,super-on-old-class
     super(InstrumentSetupWidget, self).__init__()
     metrics = QtGui.QFontMetrics(self.font())
     self.signaldict = dict()
     #instrument selector
     self.instrumentList = [
         'ARCS', 'CNCS', 'DNS', 'EXED', 'FOCUS', 'HET', 'HYSPEC', 'LET',
         'MAPS', 'MARI', 'MERLIN', 'SEQUOIA'
     ]
     self.combo = QtWidgets.QComboBox(self)
     for inst in self.instrumentList:
         self.combo.addItem(inst)
     defaultInstrument = mantid.config.getInstrument().name()
     if defaultInstrument in self.instrumentList:
         self.instrument = defaultInstrument
         self.combo.setCurrentIndex(
             self.instrumentList.index(defaultInstrument))
     else:
         self.instrument = self.instrumentList[0]
         self.combo.setCurrentIndex(0)
     self.signaldict['instrument'] = self.instrument
     self.labelInst = QtWidgets.QLabel('Instrument')
     #S2 and Ei edits
     self.S2 = 0.0
     self.Ei = 10.0
     self.signaldict['S2'] = self.S2
     self.signaldict['Ei'] = self.Ei
     self.validatorS2 = QtGui.QDoubleValidator(-90., 90., 5, self)
     self.validatorEi = QtGui.QDoubleValidator(1., 10000., 5, self)
     self.labelS2 = QtWidgets.QLabel('S2')
     self.labelEi = QtWidgets.QLabel('Incident Energy')
     self.editS2 = QtWidgets.QLineEdit()
     self.editS2.setValidator(self.validatorS2)
     self.editEi = QtWidgets.QLineEdit()
     self.editEi.setValidator(self.validatorEi)
     self.editS2.setText(QString(format(self.S2, '.2f')))
     self.editEi.setText(QString(format(self.Ei, '.1f')))
     self.editEi.setFixedWidth(metrics.width("8888.88"))
     self.editS2.setFixedWidth(metrics.width("888.88"))
     #fast checkbox
     self.fast = QtWidgets.QCheckBox("Fast", self)
     self.fast.toggle()
     self.updateFast()
     #masking
     self.labelMask = QtWidgets.QLabel('Mask file')
     self.editMask = QtWidgets.QLineEdit()
     self.buttonMask = QtWidgets.QPushButton("LoadMask")
     #goniometer settings
     self.labelGon = QtWidgets.QLabel('Goniometer')
     self.tableViewGon = QtWidgets.QTableView(self)
     self.tableViewGon.setMinimumWidth(metrics.width("Minimum ") * 8)
     self.tableViewGon.horizontalHeader().setSectionResizeMode(
         QtWidgets.QHeaderView.Stretch)
     self.tableViewGon.verticalHeader().setSectionResizeMode(
         QtWidgets.QHeaderView.Stretch)
     self.goniometerNames = ['psi', 'gl', 'gs']
     self.goniometerDirections = ['0,1,0', '0,0,1', '1,0,0']
     self.goniometerRotationSense = [1, 1, 1]
     self.goniometerMin = [0., 0., 0.]
     self.goniometerMax = [0., 0., 0.]
     self.goniometerStep = [1., 1., 1.]
     values = {
         'gonioLabels': self.goniometerNames,
         'gonioDirs': self.goniometerDirections,
         'gonioSenses': self.goniometerRotationSense,
         'gonioMinvals': self.goniometerMin,
         'gonioMaxvals': self.goniometerMax,
         'gonioSteps': self.goniometerStep
     }
     self.goniomodel = GonioTableModel(values, self)
     self.tableViewGon.setModel(self.goniomodel)
     self.tableViewGon.update()
     self.signaldict.update(values)
     #goniometer figure
     self.figure = Figure(figsize=(2, 3))
     self.figure.patch.set_facecolor('white')
     self.canvas = FigureCanvasQTAgg(self.figure)
     self.gonfig = None
     self.updateFigure()
     #layout
     self.gridI = QtWidgets.QGridLayout()
     self.gridI.addWidget(self.labelInst, 0, 0)
     self.gridI.addWidget(self.combo, 0, 1)
     self.gridI.addWidget(self.labelEi, 0, 2)
     self.gridI.addWidget(self.editEi, 0, 3)
     self.gridI.addWidget(self.labelS2, 0, 4)
     self.gridI.addWidget(self.editS2, 0, 5)
     self.gridI.addWidget(self.fast, 0, 6)
     self.setLayout(QtWidgets.QHBoxLayout())
     self.rightside = QtWidgets.QVBoxLayout()
     self.maskLayout = QtWidgets.QHBoxLayout()
     self.maskLayout.addWidget(self.labelMask)
     self.maskLayout.addWidget(self.editMask)
     self.maskLayout.addWidget(self.buttonMask)
     self.layout().addLayout(self.rightside)
     self.rightside.addLayout(self.gridI)
     self.rightside.addLayout(self.maskLayout)
     self.rightside.addWidget(self.labelGon)
     self.rightside.addWidget(self.tableViewGon)
     self.layout().addWidget(self.canvas)
     #connections
     self.editS2.textEdited.connect(self.checkValidInputs)
     self.editMask.textEdited.connect(self.setMaskFile)
     self.combo.activated[str].connect(self.instrumentSelected)
     self.fast.stateChanged.connect(self.updateFast)
     self.buttonMask.clicked.connect(self.loadMaskFromFile)
     self.editEi.textEdited.connect(self.checkValidInputs)
     #call instrumentSelected once
     self.instrumentSelected(self.instrument)
     #connect goniometer change with figure
     self.goniomodel.changed.connect(self.updateFigure)
     self.updateAll()
Exemplo n.º 29
0
    def setupUi(self, DockWidget):
        DockWidget.setObjectName("DockWidget")
        DockWidget.resize(652, 491)
        self.dockWidgetContents = QtWidgets.QWidget()
        self.dockWidgetContents.setObjectName("dockWidgetContents")
        self.gridLayout = QtWidgets.QGridLayout(self.dockWidgetContents)
        self.gridLayout.setObjectName("gridLayout")
        self.label_72 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_72.setFont(font)
        self.label_72.setObjectName("label_72")
        self.gridLayout.addWidget(self.label_72, 0, 1, 1, 1)
        self.label_73 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_73.setFont(font)
        self.label_73.setObjectName("label_73")
        self.gridLayout.addWidget(self.label_73, 0, 3, 1, 1)
        self.label_26 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_26.setMinimumSize(QtCore.QSize(0, 0))
        self.label_26.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_26.setFont(font)
        self.label_26.setObjectName("label_26")
        self.gridLayout.addWidget(self.label_26, 1, 0, 1, 1)
        self.pushButton = QtWidgets.QPushButton(self.dockWidgetContents)
        self.pushButton.setMinimumSize(QtCore.QSize(0, 0))
        self.pushButton.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.pushButton.setObjectName("pushButton")
        self.gridLayout.addWidget(self.pushButton, 1, 1, 1, 1)
        self.pushButtonDis = QtWidgets.QPushButton(self.dockWidgetContents)
        self.pushButtonDis.setEnabled(False)
        self.pushButtonDis.setMinimumSize(QtCore.QSize(0, 0))
        self.pushButtonDis.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.pushButtonDis.setDefault(False)
        self.pushButtonDis.setObjectName("pushButtonDis")
        self.gridLayout.addWidget(self.pushButtonDis, 1, 3, 1, 1)
        self.label_74 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_74.setFont(font)
        self.label_74.setObjectName("label_74")
        self.gridLayout.addWidget(self.label_74, 2, 0, 1, 1)
        self.pushButtonChecked = QtWidgets.QPushButton(self.dockWidgetContents)
        self.pushButtonChecked.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.pushButtonChecked.setCheckable(True)
        self.pushButtonChecked.setChecked(True)
        self.pushButtonChecked.setObjectName("pushButtonChecked")
        self.gridLayout.addWidget(self.pushButtonChecked, 2, 1, 1, 1)
        self.pushButtonCheckedDis = QtWidgets.QPushButton(
            self.dockWidgetContents)
        self.pushButtonCheckedDis.setEnabled(False)
        self.pushButtonCheckedDis.setCheckable(True)
        self.pushButtonCheckedDis.setChecked(True)
        self.pushButtonCheckedDis.setObjectName("pushButtonCheckedDis")
        self.gridLayout.addWidget(self.pushButtonCheckedDis, 2, 3, 1, 1)
        self.label_76 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_76.setFont(font)
        self.label_76.setObjectName("label_76")
        self.gridLayout.addWidget(self.label_76, 3, 0, 1, 1)
        self.pushButtonUnchecked = QtWidgets.QPushButton(
            self.dockWidgetContents)
        self.pushButtonUnchecked.setCheckable(True)
        self.pushButtonUnchecked.setObjectName("pushButtonUnchecked")
        self.gridLayout.addWidget(self.pushButtonUnchecked, 3, 1, 1, 1)
        self.pushButtonUncheckedDis = QtWidgets.QPushButton(
            self.dockWidgetContents)
        self.pushButtonUncheckedDis.setEnabled(False)
        self.pushButtonUncheckedDis.setCheckable(True)
        self.pushButtonUncheckedDis.setObjectName("pushButtonUncheckedDis")
        self.gridLayout.addWidget(self.pushButtonUncheckedDis, 3, 3, 1, 1)
        self.label_33 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_33.setMinimumSize(QtCore.QSize(0, 0))
        self.label_33.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_33.setFont(font)
        self.label_33.setObjectName("label_33")
        self.gridLayout.addWidget(self.label_33, 4, 0, 1, 1)
        self.toolButton = QtWidgets.QToolButton(self.dockWidgetContents)
        self.toolButton.setMinimumSize(QtCore.QSize(0, 0))
        self.toolButton.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.toolButton.setObjectName("toolButton")
        self.gridLayout.addWidget(self.toolButton, 4, 1, 1, 1)
        self.toolButtonIcon = QtWidgets.QToolButton(self.dockWidgetContents)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/qss_icons/rc/[email protected]"),
                       QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButtonIcon.setIcon(icon)
        self.toolButtonIcon.setObjectName("toolButtonIcon")
        self.gridLayout.addWidget(self.toolButtonIcon, 4, 2, 1, 1)
        self.toolButtonDis = QtWidgets.QToolButton(self.dockWidgetContents)
        self.toolButtonDis.setEnabled(False)
        self.toolButtonDis.setMinimumSize(QtCore.QSize(0, 0))
        self.toolButtonDis.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.toolButtonDis.setObjectName("toolButtonDis")
        self.gridLayout.addWidget(self.toolButtonDis, 4, 3, 1, 1)
        self.toolButtonIconDis = QtWidgets.QToolButton(self.dockWidgetContents)
        self.toolButtonIconDis.setEnabled(False)
        self.toolButtonIconDis.setObjectName("toolButtonIconDis")
        self.gridLayout.addWidget(self.toolButtonIconDis, 4, 4, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 5, 0, 1, 1)
        self.toolButtonChecked = QtWidgets.QToolButton(self.dockWidgetContents)
        self.toolButtonChecked.setCheckable(True)
        self.toolButtonChecked.setChecked(True)
        self.toolButtonChecked.setPopupMode(QtWidgets.QToolButton.DelayedPopup)
        self.toolButtonChecked.setObjectName("toolButtonChecked")
        self.gridLayout.addWidget(self.toolButtonChecked, 5, 1, 1, 1)
        self.toolButtonCheckedIcon = QtWidgets.QToolButton(
            self.dockWidgetContents)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap(":/qss_icons/rc/window_undock.png"),
                        QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.toolButtonCheckedIcon.setIcon(icon1)
        self.toolButtonCheckedIcon.setCheckable(True)
        self.toolButtonCheckedIcon.setChecked(True)
        self.toolButtonCheckedIcon.setObjectName("toolButtonCheckedIcon")
        self.gridLayout.addWidget(self.toolButtonCheckedIcon, 5, 2, 1, 1)
        self.toolButtonCheckedDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonCheckedDis.setEnabled(False)
        self.toolButtonCheckedDis.setCheckable(True)
        self.toolButtonCheckedDis.setChecked(True)
        self.toolButtonCheckedDis.setPopupMode(
            QtWidgets.QToolButton.DelayedPopup)
        self.toolButtonCheckedDis.setObjectName("toolButtonCheckedDis")
        self.gridLayout.addWidget(self.toolButtonCheckedDis, 5, 3, 1, 1)
        self.toolButtonCheckedIconDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonCheckedIconDis.setEnabled(False)
        self.toolButtonCheckedIconDis.setCheckable(True)
        self.toolButtonCheckedIconDis.setChecked(True)
        self.toolButtonCheckedIconDis.setObjectName("toolButtonCheckedIconDis")
        self.gridLayout.addWidget(self.toolButtonCheckedIconDis, 5, 4, 1, 1)
        self.label_3 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_3.setObjectName("label_3")
        self.gridLayout.addWidget(self.label_3, 6, 0, 1, 1)
        self.gridLayout_3 = QtWidgets.QGridLayout()
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.toolButtonArrowUp = QtWidgets.QToolButton(self.dockWidgetContents)
        self.toolButtonArrowUp.setArrowType(QtCore.Qt.UpArrow)
        self.toolButtonArrowUp.setObjectName("toolButtonArrowUp")
        self.gridLayout_3.addWidget(self.toolButtonArrowUp, 0, 1, 1, 1)
        self.toolButtonArrowLeft = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonArrowLeft.setArrowType(QtCore.Qt.LeftArrow)
        self.toolButtonArrowLeft.setObjectName("toolButtonArrowLeft")
        self.gridLayout_3.addWidget(self.toolButtonArrowLeft, 0, 3, 1, 1)
        self.toolButtonArrowRight = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonArrowRight.setArrowType(QtCore.Qt.RightArrow)
        self.toolButtonArrowRight.setObjectName("toolButtonArrowRight")
        self.gridLayout_3.addWidget(self.toolButtonArrowRight, 0, 2, 1, 1)
        self.toolButtonArrowDown = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonArrowDown.setArrowType(QtCore.Qt.DownArrow)
        self.toolButtonArrowDown.setObjectName("toolButtonArrowDown")
        self.gridLayout_3.addWidget(self.toolButtonArrowDown, 0, 0, 1, 1)
        self.toolButtonDots = QtWidgets.QToolButton(self.dockWidgetContents)
        self.toolButtonDots.setObjectName("toolButtonDots")
        self.gridLayout_3.addWidget(self.toolButtonDots, 0, 4, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_3, 6, 1, 1, 2)
        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.toolButtonArrowUpDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonArrowUpDis.setEnabled(False)
        self.toolButtonArrowUpDis.setArrowType(QtCore.Qt.UpArrow)
        self.toolButtonArrowUpDis.setObjectName("toolButtonArrowUpDis")
        self.gridLayout_2.addWidget(self.toolButtonArrowUpDis, 0, 1, 1, 1)
        self.toolButtonArrowDownDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonArrowDownDis.setEnabled(False)
        self.toolButtonArrowDownDis.setArrowType(QtCore.Qt.DownArrow)
        self.toolButtonArrowDownDis.setObjectName("toolButtonArrowDownDis")
        self.gridLayout_2.addWidget(self.toolButtonArrowDownDis, 0, 0, 1, 1)
        self.toolButtonArrowRightDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonArrowRightDis.setEnabled(False)
        self.toolButtonArrowRightDis.setArrowType(QtCore.Qt.RightArrow)
        self.toolButtonArrowRightDis.setObjectName("toolButtonArrowRightDis")
        self.gridLayout_2.addWidget(self.toolButtonArrowRightDis, 0, 2, 1, 1)
        self.toolButtonArrowLeftDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonArrowLeftDis.setEnabled(False)
        self.toolButtonArrowLeftDis.setArrowType(QtCore.Qt.LeftArrow)
        self.toolButtonArrowLeftDis.setObjectName("toolButtonArrowLeftDis")
        self.gridLayout_2.addWidget(self.toolButtonArrowLeftDis, 0, 3, 1, 1)
        self.toolButtonDotsDis = QtWidgets.QToolButton(self.dockWidgetContents)
        self.toolButtonDotsDis.setEnabled(False)
        self.toolButtonDotsDis.setObjectName("toolButtonDotsDis")
        self.gridLayout_2.addWidget(self.toolButtonDotsDis, 0, 4, 1, 1)
        self.gridLayout.addLayout(self.gridLayout_2, 6, 3, 1, 2)
        self.label_4 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_4.setObjectName("label_4")
        self.gridLayout.addWidget(self.label_4, 7, 0, 1, 1)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.toolButtonDelayedPopup = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonDelayedPopup.setArrowType(QtCore.Qt.NoArrow)
        self.toolButtonDelayedPopup.setObjectName("toolButtonDelayedPopup")
        self.horizontalLayout.addWidget(self.toolButtonDelayedPopup)
        self.toolButtonMenuButtonPopup = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonMenuButtonPopup.setPopupMode(
            QtWidgets.QToolButton.MenuButtonPopup)
        self.toolButtonMenuButtonPopup.setObjectName(
            "toolButtonMenuButtonPopup")
        self.horizontalLayout.addWidget(self.toolButtonMenuButtonPopup)
        self.toolButtonInstantPopup = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonInstantPopup.setPopupMode(
            QtWidgets.QToolButton.InstantPopup)
        self.toolButtonInstantPopup.setObjectName("toolButtonInstantPopup")
        self.horizontalLayout.addWidget(self.toolButtonInstantPopup)
        self.gridLayout.addLayout(self.horizontalLayout, 7, 1, 1, 2)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.toolButtonDelayedPopupDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonDelayedPopupDis.setEnabled(False)
        self.toolButtonDelayedPopupDis.setArrowType(QtCore.Qt.NoArrow)
        self.toolButtonDelayedPopupDis.setObjectName(
            "toolButtonDelayedPopupDis")
        self.horizontalLayout_2.addWidget(self.toolButtonDelayedPopupDis)
        self.toolButtonMenuButtonPopupDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonMenuButtonPopupDis.setEnabled(False)
        self.toolButtonMenuButtonPopupDis.setPopupMode(
            QtWidgets.QToolButton.MenuButtonPopup)
        self.toolButtonMenuButtonPopupDis.setObjectName(
            "toolButtonMenuButtonPopupDis")
        self.horizontalLayout_2.addWidget(self.toolButtonMenuButtonPopupDis)
        self.toolButtonInstantPopupDis = QtWidgets.QToolButton(
            self.dockWidgetContents)
        self.toolButtonInstantPopupDis.setEnabled(False)
        self.toolButtonInstantPopupDis.setPopupMode(
            QtWidgets.QToolButton.InstantPopup)
        self.toolButtonInstantPopupDis.setObjectName(
            "toolButtonInstantPopupDis")
        self.horizontalLayout_2.addWidget(self.toolButtonInstantPopupDis)
        self.gridLayout.addLayout(self.horizontalLayout_2, 7, 3, 1, 2)
        self.label_75 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_75.setFont(font)
        self.label_75.setObjectName("label_75")
        self.gridLayout.addWidget(self.label_75, 8, 0, 1, 1)
        self.radioButtonChecked = QtWidgets.QRadioButton(
            self.dockWidgetContents)
        self.radioButtonChecked.setChecked(True)
        self.radioButtonChecked.setAutoExclusive(False)
        self.radioButtonChecked.setObjectName("radioButtonChecked")
        self.gridLayout.addWidget(self.radioButtonChecked, 8, 1, 1, 1)
        self.radioButtonCheckedDis = QtWidgets.QRadioButton(
            self.dockWidgetContents)
        self.radioButtonCheckedDis.setEnabled(False)
        self.radioButtonCheckedDis.setChecked(True)
        self.radioButtonCheckedDis.setAutoExclusive(False)
        self.radioButtonCheckedDis.setObjectName("radioButtonCheckedDis")
        self.gridLayout.addWidget(self.radioButtonCheckedDis, 8, 3, 1, 1)
        self.label_29 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_29.setMinimumSize(QtCore.QSize(0, 0))
        self.label_29.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_29.setFont(font)
        self.label_29.setObjectName("label_29")
        self.gridLayout.addWidget(self.label_29, 9, 0, 1, 1)
        self.radioButtonUnchecked = QtWidgets.QRadioButton(
            self.dockWidgetContents)
        self.radioButtonUnchecked.setMinimumSize(QtCore.QSize(0, 0))
        self.radioButtonUnchecked.setMaximumSize(
            QtCore.QSize(16777215, 16777215))
        self.radioButtonUnchecked.setAutoExclusive(False)
        self.radioButtonUnchecked.setObjectName("radioButtonUnchecked")
        self.gridLayout.addWidget(self.radioButtonUnchecked, 9, 1, 1, 1)
        self.radioButtonUncheckedDis = QtWidgets.QRadioButton(
            self.dockWidgetContents)
        self.radioButtonUncheckedDis.setEnabled(False)
        self.radioButtonUncheckedDis.setMinimumSize(QtCore.QSize(0, 0))
        self.radioButtonUncheckedDis.setMaximumSize(
            QtCore.QSize(16777215, 16777215))
        self.radioButtonUncheckedDis.setChecked(False)
        self.radioButtonUncheckedDis.setAutoExclusive(False)
        self.radioButtonUncheckedDis.setObjectName("radioButtonUncheckedDis")
        self.gridLayout.addWidget(self.radioButtonUncheckedDis, 9, 3, 1, 1)
        self.label_53 = QtWidgets.QLabel(self.dockWidgetContents)
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_53.setFont(font)
        self.label_53.setObjectName("label_53")
        self.gridLayout.addWidget(self.label_53, 10, 0, 1, 1)
        self.checkBoxChecked = QtWidgets.QCheckBox(self.dockWidgetContents)
        self.checkBoxChecked.setChecked(True)
        self.checkBoxChecked.setObjectName("checkBoxChecked")
        self.gridLayout.addWidget(self.checkBoxChecked, 10, 1, 1, 1)
        self.checkBoxCheckedDis = QtWidgets.QCheckBox(self.dockWidgetContents)
        self.checkBoxCheckedDis.setEnabled(False)
        self.checkBoxCheckedDis.setChecked(True)
        self.checkBoxCheckedDis.setObjectName("checkBoxCheckedDis")
        self.gridLayout.addWidget(self.checkBoxCheckedDis, 10, 3, 1, 1)
        self.label_30 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_30.setMinimumSize(QtCore.QSize(0, 0))
        self.label_30.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_30.setFont(font)
        self.label_30.setObjectName("label_30")
        self.gridLayout.addWidget(self.label_30, 11, 0, 1, 1)
        self.checkBoxEnabled = QtWidgets.QCheckBox(self.dockWidgetContents)
        self.checkBoxEnabled.setMinimumSize(QtCore.QSize(0, 0))
        self.checkBoxEnabled.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.checkBoxEnabled.setTristate(False)
        self.checkBoxEnabled.setObjectName("checkBoxEnabled")
        self.gridLayout.addWidget(self.checkBoxEnabled, 11, 1, 1, 1)
        self.checkBoxUncheckedDis = QtWidgets.QCheckBox(
            self.dockWidgetContents)
        self.checkBoxUncheckedDis.setEnabled(False)
        self.checkBoxUncheckedDis.setMinimumSize(QtCore.QSize(0, 0))
        self.checkBoxUncheckedDis.setMaximumSize(
            QtCore.QSize(16777215, 16777215))
        self.checkBoxUncheckedDis.setChecked(False)
        self.checkBoxUncheckedDis.setObjectName("checkBoxUncheckedDis")
        self.gridLayout.addWidget(self.checkBoxUncheckedDis, 11, 3, 1, 1)
        self.label = QtWidgets.QLabel(self.dockWidgetContents)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 12, 0, 1, 1)
        self.checkBoxTristate = QtWidgets.QCheckBox(self.dockWidgetContents)
        self.checkBoxTristate.setChecked(False)
        self.checkBoxTristate.setTristate(True)
        self.checkBoxTristate.setObjectName("checkBoxTristate")
        self.gridLayout.addWidget(self.checkBoxTristate, 12, 1, 1, 1)
        self.checkBoxTristateDis = QtWidgets.QCheckBox(self.dockWidgetContents)
        self.checkBoxTristateDis.setEnabled(False)
        self.checkBoxTristateDis.setChecked(False)
        self.checkBoxTristateDis.setTristate(True)
        self.checkBoxTristateDis.setObjectName("checkBoxTristateDis")
        self.gridLayout.addWidget(self.checkBoxTristateDis, 12, 3, 1, 1)
        self.label_31 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_31.setMinimumSize(QtCore.QSize(0, 0))
        self.label_31.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_31.setFont(font)
        self.label_31.setObjectName("label_31")
        self.gridLayout.addWidget(self.label_31, 13, 0, 1, 1)
        self.commandLinkButton = QtWidgets.QCommandLinkButton(
            self.dockWidgetContents)
        self.commandLinkButton.setMinimumSize(QtCore.QSize(0, 0))
        self.commandLinkButton.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.commandLinkButton.setObjectName("commandLinkButton")
        self.gridLayout.addWidget(self.commandLinkButton, 13, 1, 1, 2)
        self.commandLinkButtonDIs = QtWidgets.QCommandLinkButton(
            self.dockWidgetContents)
        self.commandLinkButtonDIs.setEnabled(False)
        self.commandLinkButtonDIs.setMaximumSize(
            QtCore.QSize(16777215, 16777215))
        self.commandLinkButtonDIs.setObjectName("commandLinkButtonDIs")
        self.gridLayout.addWidget(self.commandLinkButtonDIs, 13, 3, 1, 2)
        self.label_32 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_32.setMinimumSize(QtCore.QSize(0, 0))
        self.label_32.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setBold(True)
        font.setWeight(75)
        self.label_32.setFont(font)
        self.label_32.setObjectName("label_32")
        self.gridLayout.addWidget(self.label_32, 14, 0, 1, 1)
        self.buttonBox = QtWidgets.QDialogButtonBox(self.dockWidgetContents)
        self.buttonBox.setMinimumSize(QtCore.QSize(0, 0))
        self.buttonBox.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel
                                          | QtWidgets.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout.addWidget(self.buttonBox, 14, 1, 1, 2)
        self.buttonBoxDis = QtWidgets.QDialogButtonBox(self.dockWidgetContents)
        self.buttonBoxDis.setEnabled(False)
        self.buttonBoxDis.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel
                                             | QtWidgets.QDialogButtonBox.Ok)
        self.buttonBoxDis.setObjectName("buttonBoxDis")
        self.gridLayout.addWidget(self.buttonBoxDis, 14, 3, 1, 2)
        spacerItem = QtWidgets.QSpacerItem(20, 4,
                                           QtWidgets.QSizePolicy.Minimum,
                                           QtWidgets.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem, 15, 0, 1, 1)
        self.label_36 = QtWidgets.QLabel(self.dockWidgetContents)
        self.label_36.setAlignment(QtCore.Qt.AlignCenter)
        self.label_36.setObjectName("label_36")
        self.gridLayout.addWidget(self.label_36, 16, 0, 1, 5)
        DockWidget.setWidget(self.dockWidgetContents)

        self.retranslateUi(DockWidget)
        self.radioButtonChecked.clicked['bool'].connect(
            self.radioButtonCheckedDis.setChecked)
        self.radioButtonUnchecked.clicked['bool'].connect(
            self.radioButtonUncheckedDis.setChecked)
        self.checkBoxChecked.clicked['bool'].connect(
            self.checkBoxCheckedDis.setChecked)
        self.checkBoxEnabled.clicked['bool'].connect(
            self.checkBoxUncheckedDis.setChecked)
        self.checkBoxTristate.clicked['bool'].connect(
            self.checkBoxTristateDis.setChecked)
        self.commandLinkButton.clicked['bool'].connect(
            self.commandLinkButtonDIs.setChecked)
        self.toolButton.clicked['bool'].connect(self.toolButtonDis.setChecked)
        self.pushButtonChecked.clicked['bool'].connect(
            self.pushButtonCheckedDis.setChecked)
        self.pushButtonUnchecked.clicked['bool'].connect(
            self.pushButtonUncheckedDis.setChecked)
        self.pushButton.clicked['bool'].connect(self.pushButtonDis.click)
        QtCore.QMetaObject.connectSlotsByName(DockWidget)
Exemplo n.º 30
0
    def export(self):
        """ Displays a dialog for exporting HTML generated by Qt's rich text
        system.

        Returns
        -------
        The name of the file that was saved, or None if no file was saved.
        """
        parent = self.control.window()
        dialog = QtWidgets.QFileDialog(parent, 'Save as...')
        dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
        filters = [
            'HTML with PNG figures (*.html *.htm)',
            'XHTML with inline SVG figures (*.xhtml *.xml)'
        ]
        dialog.setNameFilters(filters)
        if self.filename:
            dialog.selectFile(self.filename)
            root,ext = os.path.splitext(self.filename)
            if ext.lower() in ('.xml', '.xhtml'):
                dialog.selectNameFilter(filters[-1])

        if dialog.exec_():
            self.filename = dialog.selectedFiles()[0]
            choice = dialog.selectedNameFilter()
            html = py3compat.cast_unicode(self.control.document().toHtml())

            # Configure the exporter.
            if choice.startswith('XHTML'):
                exporter = export_xhtml
            else:
                # If there are PNGs, decide how to export them.
                inline = self.inline_png
                if inline is None and IMG_RE.search(html):
                    dialog = QtWidgets.QDialog(parent)
                    dialog.setWindowTitle('Save as...')
                    layout = QtWidgets.QVBoxLayout(dialog)
                    msg = "Exporting HTML with PNGs"
                    info = "Would you like inline PNGs (single large html " \
                        "file) or external image files?"
                    checkbox = QtWidgets.QCheckBox("&Don't ask again")
                    checkbox.setShortcut('D')
                    ib = QtWidgets.QPushButton("&Inline")
                    ib.setShortcut('I')
                    eb = QtWidgets.QPushButton("&External")
                    eb.setShortcut('E')
                    box = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Question,
                                            dialog.windowTitle(), msg)
                    box.setInformativeText(info)
                    box.addButton(ib, QtWidgets.QMessageBox.NoRole)
                    box.addButton(eb, QtWidgets.QMessageBox.YesRole)
                    layout.setSpacing(0)
                    layout.addWidget(box)
                    layout.addWidget(checkbox)
                    dialog.setLayout(layout)
                    dialog.show()
                    reply = box.exec_()
                    dialog.hide()
                    inline = (reply == 0)
                    if checkbox.checkState():
                        # Don't ask anymore; always use this choice.
                        self.inline_png = inline
                exporter = lambda h, f, i: export_html(h, f, i, inline)

            # Perform the export!
            try:
                return exporter(html, self.filename, self.image_tag)
            except Exception as e:
                msg = "Error exporting HTML to %s\n" % self.filename + str(e)
                reply = QtWidgets.QMessageBox.warning(parent, 'Error', msg,
                    QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)

        return None