Exemplo n.º 1
0
 def _select_data(self):
     area = self.widget.areas[0]
     self.widget.select_area(
         area,
         QMouseEvent(QEvent.MouseButtonPress, QPoint(), Qt.LeftButton,
                     Qt.LeftButton, Qt.KeyboardModifiers()))
     return [0, 4, 6, 7, 11, 17, 19, 21, 22, 24, 26, 39, 40, 43, 44, 46]
Exemplo n.º 2
0
        def navigate_completion(down=True):
            """ Sends an "arrow press" to the completion popup to navigate
            results.

            Not the best way to do this. It would be better to find out what
            function is being called by that arrow press.

            """

            if down:
                event = QtGui.QKeyEvent(QEvent.KeyPress, Qt.Key_Down,
                                        Qt.KeyboardModifiers())
            else:
                event = QtGui.QKeyEvent(QEvent.KeyPress, Qt.Key_Up,
                                        Qt.KeyboardModifiers())

            QtGui.QApplication.sendEvent(self.address_bar.completer().popup(),
                                         event)
Exemplo n.º 3
0
    def test_step_space(self):
        """
        Test step
        """
        w = self.widget

        event = QKeyEvent(
            QEvent.KeyPress, Qt.Key_Space, Qt.KeyboardModifiers(0))

        # test function not crashes when no data and learner
        w.keyPressEvent(event)

        self.send_signal("Data", self.iris)

        # test theta set after step if not set yet
        w.keyPressEvent(event)
        self.assertIsNotNone(w.learner.theta)

        # check theta is changing when step
        old_theta = np.copy(w.learner.theta)
        w.keyPressEvent(event)
        self.assertNotEqual(sum(old_theta - w.learner.theta), 0)

        # with linear regression
        self.send_signal("Data", self.housing)

        # test theta set after step if not set yet
        w.keyPressEvent(event)
        self.assertIsNotNone(w.learner.theta)

        # check theta is changing when step
        old_theta = np.copy(w.learner.theta)
        w.keyPressEvent(event)
        self.assertNotEqual(sum(old_theta - w.learner.theta), 0)

        old_theta = np.copy(w.learner.theta)
        # to cover else example and check not crashes
        event = QKeyEvent(
            QEvent.KeyPress, Qt.Key_Q, Qt.KeyboardModifiers(0))
        w.keyPressEvent(event)

        # check nothing changes
        assert_array_equal(old_theta, w.learner.theta)
Exemplo n.º 4
0
    def fetchAvailablePlugins(self, reloadMode):
        """ Fetch plugins from all enabled repositories."""
        """  reloadMode = true:  Fully refresh data from QSettings to mRepositories  """
        """  reloadMode = false: Fetch unready repositories only """
        QApplication.setOverrideCursor(Qt.WaitCursor)

        if reloadMode:
            repositories.load()
            plugins.clearRepoCache()
            plugins.getAllInstalled()

        for key in repositories.allEnabled():
            if reloadMode or repositories.all(
            )[key]["state"] == 3:  # if state = 3 (error or not fetched yet), try to fetch once again
                repositories.requestFetching(key)

        if repositories.fetchingInProgress():
            fetchDlg = QgsPluginInstallerFetchingDialog(iface.mainWindow())
            fetchDlg.exec_()
            del fetchDlg
            for key in repositories.all():
                repositories.killConnection(key)

        QApplication.restoreOverrideCursor()

        # display error messages for every unavailable reposioty, unless Shift pressed nor all repositories are unavailable
        keepQuiet = QgsApplication.keyboardModifiers() == Qt.KeyboardModifiers(
            Qt.ShiftModifier)
        if repositories.allUnavailable(
        ) and repositories.allUnavailable() != repositories.allEnabled():
            for key in repositories.allUnavailable():
                if not keepQuiet:
                    QMessageBox.warning(
                        iface.mainWindow(),
                        self.tr("QGIS Python Plugin Installer"),
                        self.tr("Error reading repository:") + " " + key +
                        "\n\n" + repositories.all()[key]["error"])
                if QgsApplication.keyboardModifiers() == Qt.KeyboardModifiers(
                        Qt.ShiftModifier):
                    keepQuiet = True
        # finally, rebuild plugins from the caches
        plugins.rebuild()
Exemplo n.º 5
0
    def keyClick(self, key, modifiers=Qt.NoModifier, widget=None):
        """Alias for ``QTest.keyClick``.

        If widget is none - focused widget will be keyclicked

        key may be QKeySequence or string
        """
        if widget is None:
            widget = self.app.focusWidget()

        if widget is None:
            widget = core.mainWindow()

        assert widget is not None

        if isinstance(key, basestring):
            assert modifiers == Qt.NoModifier, 'Do not set modifiers, if using text key'
            code = QKeySequence(key)[0]
            key = Qt.Key(code & 0x01ffffff)
            modifiers = Qt.KeyboardModifiers(code & 0xfe000000)

        QTest.keyClick(widget, key, modifiers)
Exemplo n.º 6
0
 def handle_enter():
     """ Generate a fake Enter in the webkit, to send a form """
     enter_event = QtGui.QKeyEvent(
             QEvent.KeyPress, Qt.Key_Enter, Qt.KeyboardModifiers())
     QtGui.QApplication.sendEvent(self, enter_event)
Exemplo n.º 7
0
 def _select_data(self):
     self.widget.select_area(
         1,
         QMouseEvent(QEvent.MouseButtonPress, QPoint(), Qt.LeftButton,
                     Qt.LeftButton, Qt.KeyboardModifiers()))
     return [2, 3, 9, 23, 29, 30, 34, 35, 37, 42, 47, 49]