Ejemplo n.º 1
0
    def __init__(self, oba, parent):
        super(EditOBAUI, self).__init__()
        self.parent = parent
        self.oba = oba
        self.setLayout(QVBoxLayout(self))
        self.layout().setAlignment(Qt.AlignCenter)

        # Init Name text control
        self._nameControl = LineEdit('Name', self)
        self._nameControl.setText(self.oba.name)
        self._nameControl.kb.connect(self.showOSK)
        # Init Output Pin dropdown control
        self._outputPinControlLabel = QLabel('Output Pin', self)
        self._outputPinControl = QComboBox(self)
        for _pin in self.parent.availablePins():
            self._outputPinControl.addItem(str(_pin))
        for _i in range(self._outputPinControl.count()):
            if self._outputPinControl.itemText(_i) == str(self.oba.outputPin):
                self._outputPinControl.setCurrentIndex(_i)
                break
        # Init Momentary checkbox control and set value
        self._momentaryControl = QCheckBox('Momentary', self)
        self._momentaryControl.setChecked(self.oba.momentary)
        # Init Enabled checkbox control and set value
        self._enabledControl = QCheckBox('Enabled', self)
        self._enabledControl.setChecked(self.oba.enabled)
        # Init Icon dropdown control
        self._iconControlLabel = QLabel('Icon Path', self)
        self._iconControl = QComboBox(self)
        for _key in Config.icons['oba'].keys():
            icon = Config.icon('oba', _key)
            self._iconControl.addItem(icon['name'], _key)
            self._iconControl.setItemIcon(self._iconControl.count() - 1,
                                          QIcon(icon['path']))
        for _i in range(self._iconControl.count()):
            # Set current index if matching icon attribute
            if self.oba.icon is not None and self._iconControl.itemData(
                    _i) == self.oba.icon:
                self._iconControl.setCurrentIndex(_i)
                break
        # Init Save button
        self._saveBtn = QPushButton('Save', self)
        self._saveBtn.clicked.connect(self.__saveBtnAction)
        # Init cancel button
        self._cancelBtn = QPushButton('Cancel', self)
        self._cancelBtn.clicked.connect(self.__cancel)
        # Assign control layout
        _layout = [['_nameControl'],
                   ['_outputPinControlLabel', '_outputPinControl'],
                   ['_momentaryControl', '_enabledControl'],
                   ['_iconControlLabel', '_iconControl'],
                   ['_saveBtn', '_cancelBtn']]
        for _list in _layout:
            _panel = QWidget(self)
            _panel.setLayout(QHBoxLayout(_panel))
            _panel.layout().setAlignment(Qt.AlignCenter)
            _panel.layout().setSpacing(20)
            for _control in _list:
                _panel.layout().addWidget(eval('self.%s' % _control))
            self.layout().addWidget(_panel)
Ejemplo n.º 2
0
 def _create_default_buttons(self):
     # These buttons are inserted in buttons_area, if it exists
     # Otherwise it is up to the widget to add them to some layout
     if self.graph_name is not None:
         self.graphButton = QPushButton("&Save Image", autoDefault=False)
         self.graphButton.clicked.connect(self.save_graph)
     if hasattr(self, "send_report"):
         self.report_button = QPushButton("&Report", autoDefault=False)
         self.report_button.clicked.connect(self.show_report)
Ejemplo n.º 3
0
    def addButton(self, button, *rolearg):
        """
        addButton(QAbstractButton, ButtonRole)
        addButton(str, ButtonRole)
        addButton(StandardButton)

        Add and return a button
        """
        stdbutton = None
        if isinstance(button, QAbstractButton):
            if len(rolearg) != 1:
                raise TypeError(
                    "Wrong number of arguments for " "addButton(QAbstractButton, role)"
                )
            role = rolearg[0]
        elif isinstance(button, MessageWidget.StandardButton):
            if len(rolearg) != 0:
                raise TypeError(
                    "Wrong number of arguments for " "addButton(StandardButton)"
                )
            stdbutton = button
            if button == MessageWidget.Ok:
                role = MessageWidget.AcceptRole
                button = QPushButton("Ok", default=False, autoDefault=False)
            elif button == MessageWidget.Close:
                role = MessageWidget.RejectRole
                #                 button = QPushButton(
                #                     default=False, autoDefault=False, flat=True,
                #                     icon=QIcon(self.style().standardIcon(
                #                                QStyle.SP_TitleBarCloseButton)))
                button = SimpleButton(
                    icon=QIcon(self.style().standardIcon(QStyle.SP_TitleBarCloseButton))
                )
            elif button == MessageWidget.Help:
                role = MessageWidget.HelpRole
                button = QPushButton("Help", default=False, autoDefault=False)
        elif isinstance(button, str):
            if len(rolearg) != 1:
                raise TypeError(
                    "Wrong number of arguments for " "addButton(str, ButtonRole)"
                )
            role = rolearg[0]
            button = QPushButton(button, default=False, autoDefault=False)

        if sys.platform == "darwin":
            button.setAttribute(Qt.WA_MacSmallSize)
        self.__buttons.append(MessageWidget._Button(button, role, stdbutton))
        button.clicked.connect(self.__button_clicked)
        self.__relayout()

        return button
Ejemplo n.º 4
0
    def __init__(self, obas, parent):
        super(OBAConfigUI, self).__init__()
        self.title = 'OnBoard Air Configuration'
        self.setLayout(QVBoxLayout(self))
        self.layout().setAlignment(Qt.AlignCenter)
        self.parent = parent
        self.obas = obas

        # Init logger
        self.logger = Logger('obaConfig', "UI : OBAConfig")

        # Create layout
        self._plus = QPushButton('+', self)
        self._plus.clicked.connect(self.__createOBA)
        self._minus = QPushButton('-', self)
        self._minus.clicked.connect(self.__destroyOBA)
        _panel = QWidget(self)
        _panel.layout = QHBoxLayout(_panel)
        _panel.layout.setAlignment(Qt.AlignRight)
        _panel.layout.addWidget(self._plus)
        _panel.layout.addWidget(self._minus)
        self.layout().addWidget(_panel)
        self._obaList = QTableWidget(0, 5, self)
        self._obaList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self._obaList.setHorizontalHeaderLabels(
            ['Name', 'Output Pin', 'Momentary', 'Enabled', 'Icon'])
        self._obaList.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        self.keyPressed.connect(self.__onKey)
        self.layout().addWidget(self._obaList)
        self._editBtn = QPushButton('Edit', self)
        self._editBtn.clicked.connect(self.__editOBA)
        self.layout().addWidget(self._editBtn)
        self._closeBtn = QPushButton('Close', self)
        self._closeBtn.clicked.connect(self.__closeBtnAction)
        self.layout().addWidget(self._closeBtn)

        # Populate table
        for _oba in self.obas:
            _i = self._obaList.rowCount()
            self._obaList.setRowCount(_i + 1)
            for _c, _item in enumerate([
                    _oba.name,
                    str(_oba.outputPin),
                    str(_oba.momentary),
                    str(_oba.enabled), _oba.icon
            ]):
                _tblItem = QTableWidgetItem(_item)
                _tblItem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
                self._obaList.setItem(_i, _c, _tblItem)
Ejemplo n.º 5
0
    def __init__(self, trac, parent):
        super(EditTracUI, self).__init__()
        self.title = 'Edit TracControl Element'
        self.setLayout(QVBoxLayout(self))
        self.layout().setAlignment(Qt.AlignCenter)
        self.parent = parent
        self.trac = trac

        # Init controls
        self._nameControl = LineEdit('Name', self)
        self._nameControl.setText(self.trac.name)
        self._nameControl.kb.connect(self.showOSK)
        self._outputPinControlLabel = QLabel('Output Pin', self)
        self._outputPinControl = QComboBox(self)
        for _pins in self.parent.availablePins():
            self._outputPinControl.addItem(str(_pins))
        for _i in range(self._outputPinControl.count()):
            if self._outputPinControl.itemText(_i) == str(self.trac.outputPin):
                self._outputPinControl.setCurrentIndex(_i)
                break
        self._enabledControl = QCheckBox('Enabled', self)
        self._enabledControl.setChecked(self.trac.enabled)
        self._iconControlLabel = QLabel('Icon Path', self)
        self._iconControl = QComboBox(self)
        for _key in Config.icons['tracControl'].keys():
            icon = Config.icon('tracControl', _key)
            self._iconControl.addItem(icon['name'], _key)
            self._iconControl.setItemIcon(self._iconControl.count() - 1,
                                          QIcon(icon['path']))
        # Set combobox selection to icon variable
        for iconIdx in range(self._iconControl.count()):
            if self.trac.icon is not None and self._iconControl.itemData(
                    iconIdx) == self.trac.icon:
                self._iconControl.setCurrentIndex(iconIdx)
                break
        self._saveBtn = QPushButton('Save', self)
        self._saveBtn.clicked.connect(self.__saveBtnAction)
        self._cancelBtn = QPushButton('Cancel', self)
        self._cancelBtn.clicked.connect(self.__cancel)
        _layout = [['_nameControl'],
                   ['_outputPinControlLabel', '_outputPinControl'],
                   ['_enabledControl'], ['_iconControlLabel', '_iconControl'],
                   ['_saveBtn', '_cancelBtn']]
        for _list in _layout:
            _panel = QWidget(self)
            _panel.setLayout(QHBoxLayout(_panel))
            _panel.layout().setAlignment(Qt.AlignCenter)
            for _ctrl in _list:
                _panel.layout().addWidget(eval('self.%s' % _ctrl))
            self.layout().addWidget(_panel)
Ejemplo n.º 6
0
    def __init__(self, lights, parent):
        super(LightConfigUI, self).__init__()
        self.title = 'Lighting Configuration'
        self.setLayout(QVBoxLayout(self))
        self.layout().setAlignment(Qt.AlignCenter)
        self.parent = parent
        self.lights = lights

        # Init logger
        self.logger = Logger('lightConfig', "UI : LightConfig", level='debug')

        # Create layout
        self._plus = QPushButton('+', self)
        self._plus.clicked.connect(self.__createLight)
        self._minus = QPushButton('-', self)
        self._minus.clicked.connect(self.__destroyLight)
        _panel = QWidget(self)
        _panel.setLayout(QHBoxLayout(_panel))
        _panel.layout().setAlignment(Qt.AlignRight)
        _panel.layout().addWidget(self._plus)
        _panel.layout().addWidget(self._minus)
        self.layout().addWidget(_panel)
        self._lightsList = QTableWidget(0, 5, self)
        self._lightsList.setSelectionBehavior(QAbstractItemView.SelectRows)
        self._lightsList.setHorizontalHeaderLabels(
            ['Name', 'Output Pin', 'Enabled', 'Icon', 'Strobe'])
        self._lightsList.horizontalHeader().setSectionResizeMode(
            QHeaderView.Stretch)
        self.keyPressed.connect(self.__onKey)
        self.layout().addWidget(self._lightsList)
        self._editBtn = QPushButton('Edit', self)
        self._editBtn.clicked.connect(self.__editLight)
        self.layout().addWidget(self._editBtn)
        self._closeBtn = QPushButton('Close', self)
        self._closeBtn.clicked.connect(self.__closeBtnAction)
        self.layout().addWidget(self._closeBtn)

        # Populate table
        for _light in self.lights:
            _i = self._lightsList.rowCount()
            self._lightsList.setRowCount(_i + 1)
            for _c, _item in enumerate([
                    _light.name,
                    str(_light.outputPin),
                    str(_light.enabled), _light.icon,
                    str(_light.strobe)
            ]):
                _tblItem = QTableWidgetItem(_item)
                _tblItem.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
                self._lightsList.setItem(_i, _c, _tblItem)
Ejemplo n.º 7
0
    def __init__(self, master, model):
        QDialog.__init__(self)

        self.master = master

        self.setWindowFlags(Qt.Tool)
        self.setLayout(QVBoxLayout())
        self.setWindowTitle("Hidden Axes")

        btns_area = gui.widgetBox(
            self,
            addSpace=0,
            spacing=9,
            orientation=Qt.Horizontal,
            sizePolicy=QSizePolicy(*SIZE_POLICY_FIXED),
        )
        self.btn_add = QPushButton("Add",
                                   autoDefault=False,
                                   sizePolicy=QSizePolicy(*SIZE_POLICY_FIXED))
        self.btn_add.clicked.connect(self._add)
        self.btn_cancel = QPushButton(
            "Cancel",
            autoDefault=False,
            sizePolicy=QSizePolicy(*SIZE_POLICY_FIXED))
        self.btn_cancel.clicked.connect(self._cancel)

        btns_area.layout().addWidget(self.btn_add)
        btns_area.layout().addWidget(self.btn_cancel)

        filter_edit, view = variables_filter(model=model)
        self.view_other = view
        view.setMinimumSize(QSize(30, 60))
        view.setSizePolicy(*SIZE_POLICY_ADAPTING)
        view.viewport().setAcceptDrops(True)

        self.layout().addWidget(filter_edit)
        self.layout().addWidget(view)
        self.layout().addWidget(btns_area)

        master = self.master
        box = master.box
        master.master.setEnabled(False)
        self.move(box.mapToGlobal(QPoint(0, box.pos().y() + box.height())))
        self.setFixedWidth(master.master.controlArea.width())
        self.setMinimumHeight(300)
        self.show()
        self.raise_()
        self.activateWindow()
Ejemplo n.º 8
0
    def add_row(self, attr=None, condition_type=None, condition_value=None):
        model = self.cond_list.model()
        row = model.rowCount()
        model.insertRow(row)

        attr_combo = ComboBoxSearch(
            minimumContentsLength=12,
            sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon)
        attr_combo.setModel(self.variable_model)
        attr_combo.row = row
        attr_combo.setCurrentIndex(
            self.variable_model.indexOf(attr) if attr else len(self.AllTypes) +
            1)
        self.cond_list.setCellWidget(row, 0, attr_combo)

        index = QPersistentModelIndex(model.index(row, 3))
        temp_button = QPushButton(
            '×',
            self,
            flat=True,
            styleSheet='* {font-size: 16pt; color: silver}'
            '*:hover {color: black}')
        temp_button.clicked.connect(lambda: self.remove_one(index.row()))
        self.cond_list.setCellWidget(row, 3, temp_button)

        self.remove_all_button.setDisabled(False)
        self.set_new_operators(attr_combo, attr is not None, condition_type,
                               condition_value)
        attr_combo.currentIndexChanged.connect(
            lambda _: self.set_new_operators(attr_combo, False))

        self.cond_list.resizeRowToContents(row)
Ejemplo n.º 9
0
 def __init__(self):
     self.data = None
     self.plots = []
     self.configs = []
     self.forecasts = OrderedDict()
     self.varmodel = VariableListModel(parent=self)
     icon = QIcon(join(dirname(__file__), 'icons', 'LineChart-plus.png'))
     self.add_button = button = QPushButton(icon, ' &Add plot', self)
     button.clicked.connect(self.add_plot)
     self.controlArea.layout().addWidget(button)
     self.configsArea = gui.vBox(self.controlArea)
     self.controlArea.layout().addStretch(1)
     # TODO: allow selecting ranges that are sent to output as subset table
     self.chart = highstock = Highstock(self, highchart='StockChart')
     self.mainArea.layout().addWidget(highstock)
     # highstock.evalJS('Highcharts.setOptions({navigator: {enabled:false}});')
     highstock.chart(
         # For some reason, these options don't work as global opts applied at Highstock init time
         # Disable top range selector
         rangeSelector_enabled=False,
         rangeSelector_inputEnabled=False,
         # Disable bottom miniview navigator (it doesn't update)
         navigator_enabled=False,
     )
     QTimer.singleShot(0, self.add_plot)
Ejemplo n.º 10
0
 def init_form(self):
     self._form = QPushButton()
     self._form.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
     self._form.setCheckable(self._checkable)
     self.label = self._label
     self._form.setToolTip(self.help)
     super(ControlButton, self).init_form()
Ejemplo n.º 11
0
    def __init__(self):
        super().__init__()

        # GUI
        box = gui.widgetBox(self.controlArea, "Info")
        self.infoLabel = gui.widgetLabel(box, '')

        #self.display_no_source_selected()

        self.code_editor = CodeEditorTextEdit()
        self.controlArea.layout().addWidget(self.code_editor)

        self.configMoreButton = QPushButton("Configuration")
        self.configMoreButton.setCheckable(True)
        self.configMoreButton.clicked.connect(
            self.switch_configuration_visibility)
        self.controlArea.layout().addWidget(self.configMoreButton)

        self.configurationBox = gui.widgetBox(self.controlArea,
                                              "Configuration")
        gui.lineEdit(self.configurationBox,
                     self,
                     'directory',
                     'Source Directory',
                     callback=self.directory_changed)
        self.refresh_configuration_box()
Ejemplo n.º 12
0
    def __init__(self):
        OWWidget.__init__(self)
        ConcurrentWidgetMixin.__init__(self)
        self.corpus = None
        self.last_config = None     # to avoid reruns with the same params
        self.strings_attrs = []
        self.profiler = TweetProfiler(on_server_down=self.Error.server_down)

        # Settings
        self.controlArea.layout().addWidget(self.generate_grid_layout())

        # Auto commit
        buttons_layout = QHBoxLayout()
        buttons_layout.addSpacing(15)
        buttons_layout.addWidget(
            gui.auto_commit(None, self, 'auto_commit', 'Commit', box=False)
        )
        self.controlArea.layout().addLayout(buttons_layout)

        self.cancel_button = QPushButton(
            'Cancel',
            icon=self.style()
            .standardIcon(QStyle.SP_DialogCancelButton))

        self.cancel_button.clicked.connect(self.cancel)

        hbox = gui.hBox(self.controlArea)
        hbox.layout().addWidget(self.cancel_button)
        self.cancel_button.setDisabled(True)
Ejemplo n.º 13
0
    def __init__(self):
        super().__init__()
        self.cap = None
        self.snapshot_flash = 0
        self.IMAGE_DIR = tempfile.mkdtemp(prefix='Orange-WebcamCapture-')

        self.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)
        box = self.controlArea
        image = self.imageLabel = QLabel(margin=0,
                                         alignment=Qt.AlignCenter,
                                         sizePolicy=QSizePolicy(
                                             QSizePolicy.Ignored,
                                             QSizePolicy.Ignored))
        box.layout().addWidget(image, 100)

        self.name_edit = line_edit = gui.lineEdit(box,
                                                  self,
                                                  'image_title',
                                                  'Title:',
                                                  orientation=Qt.Horizontal)
        line_edit.setPlaceholderText(self.DEFAULT_TITLE)

        hbox = gui.hBox(box)
        gui.checkBox(hbox, self, 'avatar_filter', 'Avatar filter')
        button = self.capture_button = QPushButton('Capture',
                                                   self,
                                                   clicked=self.capture_image)
        hbox.layout().addWidget(button, 1000)
        box.layout().addWidget(hbox)

        timer = QTimer(self, interval=40)
        timer.timeout.connect(self.update_webcam_image)
        timer.start()
Ejemplo n.º 14
0
    def add_row(self, attr=None, condition_type=None, condition_value=None):
        model = self.cond_list.model()
        row = model.rowCount()
        model.insertRow(row)

        attr_combo = gui.OrangeComboBox(
            minimumContentsLength=12,
            sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon)
        attr_combo.row = row
        for var in self._visible_variables(self.data.domain):
            attr_combo.addItem(*gui.attributeItem(var))
        attr_combo.setCurrentIndex(attr or 0)
        self.cond_list.setCellWidget(row, 0, attr_combo)

        index = QPersistentModelIndex(model.index(row, 3))
        temp_button = QPushButton(
            '×',
            self,
            flat=True,
            styleSheet='* {font-size: 16pt; color: silver}'
            '*:hover {color: black}')
        temp_button.clicked.connect(lambda: self.remove_one(index.row()))
        self.cond_list.setCellWidget(row, 3, temp_button)

        self.remove_all_button.setDisabled(False)
        self.set_new_operators(attr_combo, attr is not None, condition_type,
                               condition_value)
        attr_combo.currentIndexChanged.connect(
            lambda _: self.set_new_operators(attr_combo, False))

        self.cond_list.resizeRowToContents(row)
Ejemplo n.º 15
0
    def __init__(self, parent=None, acceptDrops=True, **kwargs):
        super().__init__(parent, acceptDrops=acceptDrops, **kwargs)
        self.setLayout(QVBoxLayout())

        self.addonwidget = AddonManagerWidget()
        self.addonwidget.layout().setContentsMargins(0, 0, 0, 0)
        self.layout().addWidget(self.addonwidget)
        buttons = QDialogButtonBox(
            orientation=Qt.Horizontal,
            standardButtons=QDialogButtonBox.Ok | QDialogButtonBox.Cancel,

        )
        addmore = QPushButton(
            "Add more...", toolTip="Add an add-on not listed below",
            autoDefault=False
        )
        self.addonwidget.tophlayout.addWidget(addmore)
        addmore.clicked.connect(self.__run_add_package_dialog)

        buttons.accepted.connect(self.__accepted)
        buttons.rejected.connect(self.reject)

        self.layout().addWidget(buttons)
        self.__progress = None  # type: Optional[QProgressDialog]

        self.__executor = ThreadPoolExecutor(max_workers=1)
        # The installer thread
        self.__thread = None
        # The installer object
        self.__installer = None
        self.__add_package_by_name_dialog = None  # type: Optional[QDialog]
    def __init__(self, parent=None):
        super(FileUploadHelper, self).__init__(
            parent, Qt.Window | Qt.WindowTitleHint | Qt.CustomizeWindowHint
            | Qt.WindowCloseButtonHint | Qt.WindowMaximizeButtonHint)
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.setWindowTitle('Add new file')

        self.info_state = INFO_FILE_SCHEMA
        self.layout = QVBoxLayout(self)

        # domain selection combobox
        self.domain_selection = QComboBox()
        self.domain_selection.addItems(self.supported_domains.keys())
        self.domain_selection.currentIndexChanged.connect(
            self.__on_domain_selection)
        self.__create_selection_row('Domain: ', self.domain_selection)

        # domain selection combobox
        self.hierarchy_selection = QComboBox()
        self.hierarchy_selection.addItems(self.hierarchies.keys())
        self.layout.addWidget(self.hierarchy_selection,
                              alignment=Qt.AlignVCenter)
        self.__on_domain_selection()

        # select organism
        self.organism_selection = QComboBox()
        self.organism_selection.addItems(self.supported_organisms)
        self.__create_selection_row('Organism: ', self.organism_selection)

        # title
        self.line_edit_title = QLineEdit()
        self.__create_selection_row('Title: ', self.line_edit_title)

        # tags
        self.line_edit_tags = QLineEdit()
        self.__create_selection_row('Tags (comma-separated): ',
                                    self.line_edit_tags)

        # file selector
        self.file_info = QLabel()
        self.file_select_btn = QPushButton('Select File', self)
        self.file_select_btn.clicked.connect(self.__handle_file_selector)
        self.__create_selection_row(' ', self.file_select_btn)

        # add file info section
        self.layout.addWidget(self.file_info, alignment=Qt.AlignCenter)

        self.layout.addStretch(1)

        # Ok and Cancel buttons
        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
        self.layout.addWidget(self.buttons, alignment=Qt.AlignJustify)

        self.buttons.accepted.connect(self.__accept)
        self.buttons.rejected.connect(self.__close)

        # path to a selected file
        self.file_path = None
Ejemplo n.º 17
0
 def __init__(self):
     super().__init__()
     self.cancel_button = QPushButton(
         "Cancel", icon=self.style().standardIcon(QStyle.SP_DialogCancelButton)
     )
     self.cancel_button.clicked.connect(self.cancel)
     self.buttonsArea.layout().addWidget(self.cancel_button)
     self.cancel_button.setDisabled(True)
Ejemplo n.º 18
0
    def __init__(self, parent):
        super(AddLightUI, self).__init__()
        self.title = 'Create Lighting Element'
        self.setLayout(QVBoxLayout(self))
        self.parent = parent
        self.light = Light(name='',
                           outputPin=0,
                           enabled=False,
                           icon=Config.faIcon('lightbulb'),
                           strobe=False)
        self._nameControl = LineEdit('Name', self)
        self._nameControl.kb.connect(self.showOSK)
        self._outputPinControlLabel = QLabel('Output Pin', self)
        self._outputPinControl = QComboBox(self)
        for _pin in self.parent.availablePins():
            self._outputPinControl.addItem(str(_pin))
        self._outputPinControl.setCurrentIndex(
            self._outputPinControl.findText(str(self.light.outputPin)))
        self._enabledControl = QCheckBox('Enabled', self)
        self._iconControlLabel = QLabel('Icon', self)
        self._iconControl = QComboBox(self)
        for _key in Config.icons['lights'].keys():
            icon = Config.icon('lights', _key)
            self._iconControl.addItem(icon['name'], _key)
            self._iconControl.setItemIcon(self._iconControl.count() - 1,
                                          QIcon(icon['path']))
        self._strobeControl = QCheckBox('Strobe', self)
        self._addLightBtn = QPushButton('Add Lighting Element', self)
        self._addLightBtn.clicked.connect(self.__createLightBtnAction)
        self._cancelBtn = QPushButton('Cancel', self)
        self._cancelBtn.clicked.connect(self.__cancel)

        _layout = [['_nameControl'],
                   ['_outputPinControlLabel', '_outputPinControl'],
                   ['_enabledControl', '_strobeControl'],
                   ['_iconControlLabel', '_iconControl'],
                   ['_addLightBtn', '_cancelBtn']]

        for _list in _layout:
            _panel = QWidget(self)
            _panel.setLayout(QHBoxLayout(_panel))
            _panel.layout().setAlignment(Qt.AlignCenter)
            for _control in _list:
                _panel.layout().addWidget(eval('self.%s' % _control))
            self.layout().addWidget(_panel)
Ejemplo n.º 19
0
    def addButton(self, button, *rolearg):
        """
        addButton(QAbstractButton, ButtonRole)
        addButton(str, ButtonRole)
        addButton(StandardButton)

        Add and return a button
        """
        stdbutton = None
        if isinstance(button, QAbstractButton):
            if len(rolearg) != 1:
                raise TypeError("Wrong number of arguments for "
                                "addButton(QAbstractButton, role)")
            role = rolearg[0]
        elif isinstance(button, NotificationMessageWidget.StandardButton):
            if rolearg:
                raise TypeError("Wrong number of arguments for "
                                "addButton(StandardButton)")
            stdbutton = button
            if button == NotificationMessageWidget.Ok:
                role = NotificationMessageWidget.AcceptRole
                button = QPushButton(self._acceptLabel,
                                     default=False,
                                     autoDefault=False)
            elif button == NotificationMessageWidget.Close:
                role = NotificationMessageWidget.RejectRole
                button = QPushButton(self._rejectLabel,
                                     default=False,
                                     autoDefault=False)
        elif isinstance(button, str):
            if len(rolearg) != 1:
                raise TypeError("Wrong number of arguments for "
                                "addButton(str, ButtonRole)")
            role = rolearg[0]
            button = QPushButton(button, default=False, autoDefault=False)

        if sys.platform == "darwin":
            button.setAttribute(Qt.WA_MacSmallSize)

        self._buttons.append(
            NotificationMessageWidget._Button(button, role, stdbutton))
        button.clicked.connect(self._button_clicked)
        self._relayout()

        return button
Ejemplo n.º 20
0
    def __init__(self):
        super().__init__()
        self.recent_paths = []

        self.file_combo = QComboBox()
        self.file_combo.setMinimumWidth(80)
        self.file_combo.activated.connect(self._activate)

        self.browse_btn = QPushButton("...")
        icon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
        self.browse_btn.setIcon(icon)
        self.browse_btn.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
        self.browse_btn.clicked.connect(self.browse)

        self.load_btn = QPushButton("")
        icon = self.style().standardIcon(QStyle.SP_BrowserReload)
        self.load_btn.setIcon(icon)
        self.load_btn.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed)
        self.load_btn.setAutoDefault(True)
        self.load_btn.clicked.connect(self.file_loaded)
Ejemplo n.º 21
0
    def __init__(self, owwidget, ax, varmodel):
        QWidget.__init__(self, owwidget)
        gui.OWComponent.__init__(self)

        self.ax = ax
        self.view = view = QListView(
            self,
            selectionMode=QTreeWidget.ExtendedSelection,
        )
        view.setModel(varmodel)
        selection = view.selectionModel()
        selection.selectionChanged.connect(self.selection_changed)

        box = QVBoxLayout(self)
        box.setContentsMargins(0, 0, 0, 0)
        self.setLayout(box)

        hbox = gui.hBox(self)
        gui.comboBox(
            hbox,
            self,
            "plot_type",
            label="类型:",
            orientation="horizontal",
            items=("线", "折线", "柱", "面积", "样条曲线"),
            sendSelectedValue=True,
            callback=lambda: self.sigType.emit(ax, self.plot_types[self.
                                                                   plot_type]),
        )
        gui.rubber(hbox)
        self.button_close = button = QPushButton(
            "×",
            hbox,
            visible=False,
            minimumSize=QSize(20, 20),
            maximumSize=QSize(20, 20),
            styleSheet="""
                                                     QPushButton {
                                                         font-weight: bold;
                                                         font-size:14pt;
                                                         margin:0;
                                                         padding:0;
                                                     }""",
        )
        button.clicked.connect(lambda: self.sigClosed.emit(ax, self))
        hbox.layout().addWidget(button)
        gui.checkBox(
            self,
            self,
            "is_logarithmic",
            "对数轴",
            callback=lambda: self.sigLogarithmic.emit(ax, self.is_logarithmic),
        )
        box.addWidget(view)
Ejemplo n.º 22
0
    def _setup_layout(self):
        self.controlArea.setMinimumWidth(self.controlArea.sizeHint().width())
        self.layout().setSizeConstraint(QLayout.SetFixedSize)

        widget_box = widgetBox(self.controlArea, 'Info')
        self.input_data_info = widgetLabel(widget_box, self._NO_DATA_INFO_TEXT)
        self.connection_info = widgetLabel(widget_box, "")

        widget_box = widgetBox(self.controlArea, 'Settings')
        self.cb_image_attr = comboBox(
            widget=widget_box,
            master=self,
            value='cb_image_attr_current_id',
            label='Image attribute:',
            orientation=Qt.Horizontal,
            callback=self._cb_image_attr_changed
        )

        self.cb_embedder = comboBox(
            widget=widget_box,
            master=self,
            value='cb_embedder_current_id',
            label='Embedder:',
            orientation=Qt.Horizontal,
            callback=self._cb_embedder_changed
        )
        self.cb_embedder.setModel(VariableListModel(
            [EMBEDDERS_INFO[e]['name'] for e in self.embedders]))
        if not self.cb_embedder_current_id < len(self.embedders):
            self.cb_embedder_current_id = 0
        self.cb_embedder.setCurrentIndex(self.cb_embedder_current_id)

        current_embedder = self.embedders[self.cb_embedder_current_id]
        self.embedder_info = widgetLabel(
            widget_box,
            EMBEDDERS_INFO[current_embedder]['description']
        )

        self.auto_commit_widget = auto_commit(
            widget=self.controlArea,
            master=self,
            value='_auto_apply',
            label='Apply',
            commit=self.commit
        )

        self.cancel_button = QPushButton(
            'Cancel',
            icon=self.style().standardIcon(QStyle.SP_DialogCancelButton),
        )
        self.cancel_button.clicked.connect(self.cancel)
        hbox = hBox(self.controlArea)
        hbox.layout().addWidget(self.cancel_button)
        self.cancel_button.setDisabled(True)
Ejemplo n.º 23
0
    def _setup_layout(self):
        self.controlArea.setMinimumWidth(self.controlArea.sizeHint().width())
        self.layout().setSizeConstraint(QLayout.SetFixedSize)

        widget_box = widgetBox(self.controlArea, "Settings")
        self.cb_image_attr = comboBox(
            widget=widget_box,
            master=self,
            value="cb_image_attr_current_id",
            label="Image attribute:",
            orientation=Qt.Horizontal,
            callback=self._cb_image_attr_changed,
        )

        self.cb_embedder = comboBox(
            widget=widget_box,
            master=self,
            value="cb_embedder_current_id",
            label="Embedder:",
            orientation=Qt.Horizontal,
            callback=self._cb_embedder_changed,
        )
        names = [
            EMBEDDERS_INFO[e]["name"] +
            (" (local)" if EMBEDDERS_INFO[e].get("is_local") else "")
            for e in self.embedders
        ]
        self.cb_embedder.setModel(VariableListModel(names))
        if not self.cb_embedder_current_id < len(self.embedders):
            self.cb_embedder_current_id = 0
        self.cb_embedder.setCurrentIndex(self.cb_embedder_current_id)

        current_embedder = self.embedders[self.cb_embedder_current_id]
        self.embedder_info = widgetLabel(
            widget_box, EMBEDDERS_INFO[current_embedder]["description"])

        self.auto_commit_widget = auto_commit(
            widget=self.controlArea,
            master=self,
            value="_auto_apply",
            label="Apply",
            commit=self.commit,
        )

        self.cancel_button = QPushButton(
            "Cancel",
            icon=self.style().standardIcon(QStyle.SP_DialogCancelButton),
        )
        self.cancel_button.clicked.connect(self.cancel)
        hbox = hBox(self.controlArea)
        hbox.layout().addWidget(self.cancel_button)
        self.cancel_button.setDisabled(True)
Ejemplo n.º 24
0
 def __init__(self, rWidget=None):
     super(OSK, self).__init__()
     self.showFullScreen()
     self._rWidget = rWidget
     self.layout = QVBoxLayout(self)
     self.currentText = QLabel(self)
     self.currentText.setAlignment(Qt.AlignCenter)
     if rWidget is not None:
         self.currentText.setText(rWidget.text())
     self.layout.addWidget(self.currentText)
     keyLayout = [['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-'],
                  ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'],
                  ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'],
                  ['z', 'x', 'c', 'v', 'b', 'n', 'm']]
     for l in keyLayout:
         panel = QWidget(self)
         panel.layout = QHBoxLayout(panel)
         for key in l:
             button = OSKKey(key, self, parent=self)
             panel.layout.addWidget(button)
         self.layout.addWidget(panel)
     contolPanel = QWidget(self)
     contolPanel.layout = QHBoxLayout(contolPanel)
     self._shift = QPushButton('Shift', self)
     self._shift.setCheckable(True)
     self._shift.setFixedWidth(150)
     contolPanel.layout.addWidget(self._shift)
     spaceBar = OSKKey('space', self, parent=self)
     spaceBar.rKey = ' '
     spaceBar.setFixedWidth(2 * self.window().geometry().width() / 3)
     contolPanel.layout.addWidget(spaceBar)
     bkspc = OSKKey('delete', self, parent=self)
     bkspc.rKey = '<<'
     contolPanel.layout.addWidget(bkspc)
     self.layout.addWidget(contolPanel)
     self.closeButton = QPushButton("OK", self)
     self.closeButton.clicked.connect(self.__closeButtonAction)
     self.layout.addWidget(self.closeButton)
Ejemplo n.º 25
0
    def __init__(self, parent=None, **kwargs):
        super().__init__(parent, acceptDrops=True, **kwargs)
        self.setLayout(QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.addonwidget = AddonManagerWidget()
        self.layout().addWidget(self.addonwidget)

        info_bar = QWidget()
        info_layout = QHBoxLayout()
        info_bar.setLayout(info_layout)
        self.layout().addWidget(info_bar)

        buttons = QDialogButtonBox(
            orientation=Qt.Horizontal,
            standardButtons=QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
        )
        buttons.button(QDialogButtonBox.Ok).setText("确定")
        buttons.button(QDialogButtonBox.Cancel).setText("取消")

        addmore = QPushButton(
            "添加更多...", toolTip="添加一个未出现在列表中的附加组件",
            autoDefault=False
        )
        self.addonwidget.tophlayout.addWidget(addmore)
        addmore.clicked.connect(self.__run_add_package_dialog)

        buttons.accepted.connect(self.__accepted)
        buttons.rejected.connect(self.reject)

        self.layout().addWidget(buttons)

        self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
        if AddonManagerDialog._packages is None:
            self._f_pypi_addons = self._executor.submit(list_available_versions)
        else:
            self._f_pypi_addons = concurrent.futures.Future()
            self._f_pypi_addons.set_result(AddonManagerDialog._packages)

        self._f_pypi_addons.add_done_callback(
            method_queued(self._set_packages, (object,))
        )

        self.__progress = None  # type: Optional[QProgressDialog]
        self.__thread = None
        self.__installer = None

        if not self._f_pypi_addons.done():
            self.__progressDialog()
Ejemplo n.º 26
0
    def __init__(self, owwidget, ax, varmodel):
        QWidget.__init__(self, owwidget)
        gui.OWComponent.__init__(self)

        self.ax = ax
        self.view = view = QListView(
            self,
            selectionMode=QTreeWidget.ExtendedSelection,
        )
        view.setModel(varmodel)
        selection = view.selectionModel()
        selection.selectionChanged.connect(self.selection_changed)

        box = QVBoxLayout(self)
        box.setContentsMargins(0, 0, 0, 0)
        self.setLayout(box)

        hbox = gui.hBox(self)
        gui.comboBox(hbox,
                     self,
                     'plot_type',
                     label='Type:',
                     orientation='horizontal',
                     items=('line', 'step line', 'column', 'area', 'spline'),
                     sendSelectedValue=True,
                     callback=lambda: self.sigType.emit(ax, self.plot_type))
        gui.rubber(hbox)
        self.button_close = button = QPushButton('×',
                                                 hbox,
                                                 visible=False,
                                                 minimumSize=QSize(20, 20),
                                                 maximumSize=QSize(20, 20),
                                                 styleSheet='''
                                                     QPushButton {
                                                         font-weight: bold;
                                                         font-size:14pt;
                                                         margin:0;
                                                         padding:0;
                                                     }''')
        button.clicked.connect(lambda: self.sigClosed.emit(ax, self))
        hbox.layout().addWidget(button)
        gui.checkBox(
            self,
            self,
            "is_logarithmic",
            "Logarithmic axis",
            callback=self.on_logarithmic,
        )
        box.addWidget(view)
Ejemplo n.º 27
0
    def __init__(self, flags, *args, server_type: str = 'resolwe', **kwargs):
        super().__init__(flags, *args, **kwargs)

        self.server_type: str = server_type
        self.cm: CredentialManager = get_credential_manager(server_type)

        self.setWindowTitle('Sign in')
        self.setFixedSize(400, 250)

        self.server_cb_label = QLabel('Server *')
        self.server_cb = QComboBox(self)
        self.server_cb.addItems(resapi.RESOLWE_URLS if server_type ==
                                RESOLWE_PLATFORM else [genapi.DEFAULT_URL])
        self.server_cb.setEditable(True)

        self.username_label = QLabel('Username *')
        self.username_line_edit = QLineEdit(self)
        self.username_line_edit.setPlaceholderText('Enter correct username')
        self.username_line_edit.returnPressed.connect(self.sign_in)
        self.username_line_edit.textChanged.connect(self.handle_sign_in_btn)

        self.password_label = QLabel('Password *')
        self.password_line_edit = QLineEdit(self)
        self.password_line_edit.setPlaceholderText('Enter correct password')
        self.password_line_edit.returnPressed.connect(self.sign_in)
        self.password_line_edit.textChanged.connect(self.handle_sign_in_btn)
        self.password_line_edit.setEchoMode(QLineEdit.Password)

        self.sign_in_btn = QPushButton('Sign in', self)
        self.sign_in_btn.setDisabled(True)
        self.sign_in_btn.clicked.connect(self.sign_in)

        self.error_msg = QLabel('Unable to log in with provided credentials.')
        self.error_msg.setStyleSheet('color:red')
        self.error_msg.hide()

        layout = QVBoxLayout(self)
        layout.addWidget(self.server_cb_label)
        layout.addWidget(self.server_cb)
        layout.addWidget(self.username_label)
        layout.addWidget(self.username_line_edit)
        layout.addWidget(self.password_label)
        layout.addWidget(self.password_line_edit)
        layout.addWidget(self.error_msg)
        layout.addStretch()
        layout.addWidget(self.sign_in_btn)

        self.resolwe_instance = None
    def __init__(self):
        self.data = None
        self.classifier = None
        self.selected = None

        self.model = CustomRuleViewerTableModel(parent=self)
        self.model.set_horizontal_header_labels(
            [
                "IF conditions",
                "",
                "THEN class",
                "Distribution",
                "Probabilities [%]",
                "Quality",
                "Length",
            ]
        )

        self.proxy_model = QSortFilterProxyModel(parent=self)
        self.proxy_model.setSourceModel(self.model)
        self.proxy_model.setSortRole(self.model.SortRole)

        self.view = gui.TableView(self, wordWrap=False)
        self.view.setModel(self.proxy_model)
        self.view.verticalHeader().setVisible(True)
        self.view.horizontalHeader().setStretchLastSection(False)
        self.view.selectionModel().selectionChanged.connect(self.commit)

        self.dist_item_delegate = DistributionItemDelegate(self)
        self.view.setItemDelegateForColumn(3, self.dist_item_delegate)

        self.mainArea.layout().setContentsMargins(0, 0, 0, 0)
        self.mainArea.layout().addWidget(self.view)
        bottom_box = gui.hBox(widget=self.mainArea, box=None, margin=0, spacing=0)

        original_order_button = QPushButton("Restore original order", autoDefault=False)
        original_order_button.setFixedWidth(180)
        bottom_box.layout().addWidget(original_order_button)
        original_order_button.clicked.connect(self.restore_original_order)

        gui.separator(bottom_box, width=5, height=0)
        gui.checkBox(
            widget=bottom_box,
            master=self,
            value="compact_view",
            label="Compact view",
            callback=self.on_update,
        )
Ejemplo n.º 29
0
    def __init__(self, title, text, parent=None):
        super().__init__(parent)

        self.setLayout(QVBoxLayout())
        self.title_le = QLineEdit()
        self.title_le.setPlaceholderText("Document title")
        self.title_le.setText(title)
        self.title_le.editingFinished.connect(self._on_text_changed)
        self.text_area = CustomQPlainTextEdit()
        self.text_area.setPlaceholderText("Document text")
        self.text_area.setPlainText(text)
        self.text_area.editingFinished.connect(self._on_text_changed)

        remove_button = QPushButton("x")
        remove_button.setFixedWidth(35)
        remove_button.setFocusPolicy(Qt.NoFocus)
        remove_button.clicked.connect(self._on_remove_clicked)
        box = gui.hBox(self)
        box.layout().addWidget(self.title_le)
        box.layout().addWidget(remove_button)
        self.layout().addWidget(self.text_area)
Ejemplo n.º 30
0
    def __init__(self):
        self.data = None
        # List of all features (model for ComboBox)
        self.features = itemmodels.VariableListModel(
            ["Select Feature"], parent=self)

        box = gui.vBox(self.controlArea, "Select ")
        self.features_widget = QComboBox(
            self.controlArea,
            minimumContentsLength=16,
            sizeAdjustPolicy=QComboBox.AdjustToMinimumContentsLengthWithIcon,
            sizePolicy=QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum)
        )
        self.features_widget.setModel(self.features)
        self.features_widget.currentIndexChanged.connect(self.feature_changed)
        self.button = QPushButton("Split")
        self.button.clicked.connect(self.split)
        self.button.setEnabled(False)

        box.layout().addWidget(self.features_widget)
        box.layout().addWidget(self.button)