예제 #1
0
    def reset_par(self):

        for i in reversed(list(range(self._vbox.count()))):
            widgetToRemove = self._vbox.itemAt(i).widget()
            self._vbox.removeWidget(widgetToRemove)
            widgetToRemove.setParent(None)

        self.build_param_widget()

        self._vbox.addWidget(self.step_label)
        self._vbox.addWidget(self.dual_level_tab)

        self.command_lst[0] = [self.command_lst[0][0]]
        self.lst_pair = []

        self.update_command_lst_low_level.emit(self.command_lst[0])

        try:
            max_nproc = self.simpler_widget.set_max_nproc()
            if max_nproc > 1:
                self.raise_nproc_str = (
                    str(self.simpler_widget.box_nproc.local_path) + "=" + str(max_nproc)
                )
                QTimer.singleShot(1000, self.raise_nproc_to_max)

        except AttributeError:
            pass
예제 #2
0
 def refresh(self):
     """load this game and this player. Keep parameter list identical with
     ExplainView"""
     if not self.game:
         # keep scores of previous game on display
         return
     if self.scoreModel:
         expandGroups = [
             self.viewLeft.isExpanded(
                 self.scoreModel.index(x, 0, QModelIndex()))
             for x in range(4)
         ]
     else:
         expandGroups = [True, False, True, True]
     gameid = str(self.game.seed or self.game.gameid)
     if self.game.finished():
         title = i18n('Final scores for game <numid>%1</numid>', gameid)
     else:
         title = i18n('Scores for game <numid>%1</numid>', gameid)
     decorateWindow(self, title)
     self.ruleTree.rulesets = list([self.game.ruleset])
     self.scoreModel = ScoreModel(self)
     if Debug.modelTest:
         self.scoreModelTest = ModelTest(self.scoreModel, self)
     for view in [self.viewLeft, self.viewRight]:
         view.setModel(self.scoreModel)
         header = view.header()
         header.setStretchLastSection(False)
         view.setAlternatingRowColors(True)
     self.viewRight.header().setSectionResizeMode(QHeaderView.Fixed)
     for col in range(self.viewLeft.header().count()):
         self.viewLeft.header().setSectionHidden(col, col > 0)
         self.viewRight.header().setSectionHidden(col, col == 0)
     self.scoreLayout.setStretch(1, 100)
     self.scoreLayout.setSpacing(0)
     self.viewLeft.setFrameStyle(QFrame.NoFrame)
     self.viewRight.setFrameStyle(QFrame.NoFrame)
     self.viewLeft.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     for master, slave in ((self.viewRight, self.viewLeft),
                           (self.viewLeft, self.viewRight)):
         master.expanded.connect(slave.expand)
         master.collapsed.connect(slave.collapse)
         master.verticalScrollBar().valueChanged.connect(
             slave.verticalScrollBar().setValue)
     for row, expand in enumerate(expandGroups):
         self.viewLeft.setExpanded(
             self.scoreModel.index(row, 0, QModelIndex()), expand)
     self.viewLeft.resizeColumnToContents(0)
     self.viewRight.setColWidth()
     # we need a timer since the scrollbar is not yet visible
     QTimer.singleShot(0, self.scrollRight)
예제 #3
0
    def receive_delayed_response(self, data, server_url):
        timer = QTimer()

        delayed_url = server_url.replace('/predict', '/responses')

        def check_response():
            print('TRYING TO OBTAIN DELAYED RESPONSE')
            reply = SSLUtil.post(delayed_url,
                                 data={'request_id': data['request_id']},
                                 timeout=5.0)
            responses_json = reply.json()
            self.process_responses(responses_json, server_url)

        timer.singleShot(1000, check_response)
예제 #4
0
 def refresh(self):
     """load this game and this player. Keep parameter list identical with
     ExplainView"""
     if not self.game:
         # keep scores of previous game on display
         return
     if self.scoreModel:
         expandGroups = [self.viewLeft.isExpanded(self.scoreModel.index(x, 0, QModelIndex())) for x in range(4)]
     else:
         expandGroups = [True, False, True, True]
     gameid = str(self.game.seed or self.game.gameid)
     if self.game.finished():
         title = m18n("Final scores for game <numid>%1</numid>", gameid)
     else:
         title = m18n("Scores for game <numid>%1</numid>", gameid)
     decorateWindow(self, title)
     self.ruleTree.rulesets = list([self.game.ruleset])
     self.scoreModel = ScoreModel(self)
     if Debug.modelTest:
         self.scoreModelTest = ModelTest(self.scoreModel, self)
     for view in [self.viewLeft, self.viewRight]:
         view.setModel(self.scoreModel)
         header = view.header()
         header.setStretchLastSection(False)
         view.setAlternatingRowColors(True)
     if usingQt5:
         self.viewRight.header().setSectionResizeMode(QHeaderView.Fixed)
     else:
         self.viewRight.header().setResizeMode(QHeaderView.Fixed)
     for col in range(self.viewLeft.header().count()):
         self.viewLeft.header().setSectionHidden(col, col > 0)
         self.viewRight.header().setSectionHidden(col, col == 0)
     self.scoreLayout.setStretch(1, 100)
     self.scoreLayout.setSpacing(0)
     self.viewLeft.setFrameStyle(QFrame.NoFrame)
     self.viewRight.setFrameStyle(QFrame.NoFrame)
     self.viewLeft.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     for master, slave in ((self.viewRight, self.viewLeft), (self.viewLeft, self.viewRight)):
         master.expanded.connect(slave.expand)
         master.collapsed.connect(slave.collapse)
         master.verticalScrollBar().valueChanged.connect(slave.verticalScrollBar().setValue)
     for row, expand in enumerate(expandGroups):
         self.viewLeft.setExpanded(self.scoreModel.index(row, 0, QModelIndex()), expand)
     self.viewLeft.resizeColumnToContents(0)
     self.viewRight.setColWidth()
     # we need a timer since the scrollbar is not yet visible
     QTimer.singleShot(0, self.scrollRight)
예제 #5
0
파일: pdf.py 프로젝트: Alwnikrotikz/lilykde
def openFile(pdf):
    """ Open the specified PDF document """

    global _file

    c = KApplication.dcopClient()
    kpdf = DCOPApp(c.appId(), c).kpdf

    # When LilyPond writes a PDF, it first deletes the old one.
    # So the new PDF gets a different inode number, which causes
    # KPDF to sometimes loose the 'watch' on the file.
    # So we call KPDF to open the file, and remember the page number
    # displayed ourselves, because KPDF also seems to forget the scroll
    # position due to LilyPond deleting the old PDF first.
    # It would be best that either KPDF is fixed to just look for a
    # named file, even if it has a different inode number, or that
    # LilyPond is fixed to not delete the old PDF first, but just
    # truncate it and write the new data into it.

    # Update June 17, 2008: LilyPond >= 2.11.49 does not delete the PDF
    # anymore on unix platforms!

    # Document already shown?
    if _file == pdf:
        # Yes this is the same PDF, see if we need to force KPDF to
        # reload the document. If not, we trust that KPDF automatically
        # updates its view.
        from lilykde.version import version
        if (
            # User can force reload of PDF with config option
            config('preferences')['force reload pdf'] == '1'
            # LilyPond >= 2.11.49 does not delete the PDF anymore on unix
            or version < (2, 11, 49) or os.name not in ('posix', 'mac')
            # read KPDF's 'watch file' option (default is true)
            or kconfig('kpdfpartrc', True, False).group('General')['WatchFile']
                in ('false', '0', 'off', 'no')):
            # Reopen same document, remembering page number
            page = kpdf.currentPage()[1]
            kpdf.openDocument(KURL(pdf))
            QTimer.singleShot(100, lambda: kpdf.goToPage(page))
    else:
        # This is another PDF, just open it.
        kpdf.openDocument(KURL(pdf))
        _file = pdf
예제 #6
0
 def __init__(self, parent):
     self.parent = parent
     self.comar = commander.Commander()
     self.step = 0
     self.connect(self.comar, PYSIGNAL("stepStarted(QString)"), self.stepStarted)
     self.connect(self.comar, PYSIGNAL("stepFinished(QString)"), self.stepFinished)
     self.connect(self.comar, PYSIGNAL("stepFinished(QString)"), lambda: QTimer.singleShot(1000, self.runNextStep))
     self.connect(self.comar, PYSIGNAL("statusDownloading(int, int)"), self.statusDownloading)
     self.connect(self.comar, PYSIGNAL("statusInstalling(QString, int, int)"), self.statusInstalling)
     self.connect(self.comar, PYSIGNAL("statusConfiguring()"), self.statusConfiguring)
예제 #7
0
    def queryExit(self):
        """see queryClose"""
        def quitDebug(*args, **kwargs):
            """reducing branches in queryExit"""
            if Debug.quit:
                logDebug(*args, **kwargs)

        if self.exitReady:
            quitDebug(
                'MainWindow.queryExit returns True because exitReady is set')
            return True
        if self.exitConfirmed:
            # now we can get serious
            self.exitReady = False
            for widget in chain(
                (x.tableList for x in HumanClient.humanClients),
                [self.confDialog, self.rulesetWindow, self.playerWindow]):
                if isAlive(widget):
                    widget.hide()
            if self.exitWaitTime is None:
                self.exitWaitTime = 0
            if Internal.reactor and Internal.reactor.running:
                self.exitWaitTime += 10
                if self.exitWaitTime % 1000 == 0:
                    logDebug('waiting since %d seconds for reactor to stop' %
                             (self.exitWaitTime // 1000))
                try:
                    quitDebug('now stopping reactor')
                    Internal.reactor.stop()
                    assert isAlive(self)
                    QTimer.singleShot(10, self.close)
                except ReactorNotRunning:
                    self.exitReady = True
                    quitDebug(
                        'MainWindow.queryExit returns True: It got exception ReactorNotRunning'
                    )
            else:
                self.exitReady = True
                quitDebug(
                    'MainWindow.queryExit returns True: Reactor is not running'
                )
        return bool(self.exitReady)
예제 #8
0
파일: mainwindow.py 프로젝트: KDE/kajongg
    def queryExit(self):
        """see queryClose"""
        def quitDebug(*args, **kwargs):
            """reducing branches in queryExit"""
            if Debug.quit:
                logDebug(*args, **kwargs)

        if self.exitReady:
            quitDebug(u'MainWindow.queryExit returns True because exitReady is set')
            return True
        if self.exitConfirmed:
            # now we can get serious
            self.exitReady = False
            for widget in chain(
                    (x.tableList for x in HumanClient.humanClients), [
                        self.confDialog,
                        self.rulesetWindow, self.playerWindow]):
                if isAlive(widget):
                    widget.hide()
            if self.exitWaitTime is None:
                self.exitWaitTime = 0
            if Internal.reactor and Internal.reactor.running:
                self.exitWaitTime += 10
                if self.exitWaitTime % 1000 == 0:
                    logDebug(
                        u'waiting since %d seconds for reactor to stop' %
                        (self.exitWaitTime // 1000))
                try:
                    quitDebug(u'now stopping reactor')
                    Internal.reactor.stop()
                    assert isAlive(self)
                    QTimer.singleShot(10, self.close)
                except ReactorNotRunning:
                    self.exitReady = True
                    quitDebug(
                        u'MainWindow.queryExit returns True: It got exception ReactorNotRunning')
            else:
                self.exitReady = True
                quitDebug(u'MainWindow.queryExit returns True: Reactor is not running')
        return bool(self.exitReady)
예제 #9
0
 def closeEvent(self, event):
     KXmlGuiWindow.closeEvent(self, event)
     if event.isAccepted() and self.exitReady:
         QTimer.singleShot(5000, self.aboutToQuit)
예제 #10
0
 def stopCommand(self):
     self.resetButtons()
     self.process.tryTerminate()
     QTimer.singleShot(5000, self.process, SLOT("kill()"))
예제 #11
0
파일: mainwindow.py 프로젝트: KDE/kajongg
 def closeEvent(self, event):
     KXmlGuiWindow.closeEvent(self, event)
     if event.isAccepted() and self.exitReady:
         QTimer.singleShot(5000, self.aboutToQuit)
예제 #12
0
 def action(func):
     QTimer.singleShot(msec, func)
     return func
 def executeCommandDelayed(self, method, delay=100):
     # Order of OpenIGTLink message receiving and processing is not guaranteed to be the same
     # therefore we wait a bit to make sure the image message is processed as well
     QTimer.singleShot(delay, method)
예제 #14
0
    cmd = [pdftk(), pdf, 'attach_files'] + files + ['output', temp]

    try:
        retcode = subprocess.call(cmd, cwd = directory)
    except OSError, e:
        log.fail(_("Could not start Pdftk: %s") % e)
        os.remove(temp)
    else:
        if retcode == 0:
            # copy temp to the pdf, but do it not too quick if wait
            # was specified, otherwise KPDF could still be reading, and
            # will then possibly read a truncated file.
            def finish():
                shutil.copy(temp, pdf)
                os.remove(temp)
                log.ok(_(
                    "Embedded file %s in PDF.",
                    "Embedded files %s in PDF.",
                    len(files)
                    ) % '[%s]' % ', '.join(files))
            QTimer.singleShot(int(wait * 1000), finish)
        else:
            os.remove(temp)
            log.fail('%s %s' % (
                _("Embedding files in PDF failed."),
                _("Return code: %i") % retcode))


# kate: indent-width 4;
 def executeCommandDelayed(self, method, delay=100):
   # Order of OpenIGTLink message receiving and processing is not guaranteed to be the same
   # therefore we wait a bit to make sure the image message is processed as well
   QTimer.singleShot(delay, method)