Exemplo n.º 1
0
    # The model emits signals when it is starting to rebuild the table
    # and when it has finished rebuilding the table. Use these to put up
    # a status message, as the wait can be significant.
    def sigResetStarting(self):
        pqMsgs.showStatusMsg(QString(u"Rebuilding Character Table..."))

    def sigResetOver(self):
        pqMsgs.clearStatusMsg()


if __name__ == "__main__":
    import sys
    from PyQt4.QtCore import (Qt, QFile, QIODevice, QTextStream)
    from PyQt4.QtGui import (QApplication, QFileDialog, QMainWindow)
    import pqIMC
    IMC = pqIMC.tricorder()  # create inter-module communicator
    app = QApplication(sys.argv)  # create an app
    import pqMsgs
    pqMsgs.IMC = IMC
    import pqLists
    IMC.charCensus = pqLists.vocabList()
    CP = charsPanel()  # create the widget with the table view and model
    MW = QMainWindow()
    MW.setCentralWidget(CP)
    IMC.statusBar = MW.statusBar()
    MW.show()
    utname = QFileDialog.getOpenFileName(MW, "UNIT TEST DATA FOR CHARS", ".")
    utfile = QFile(utname)
    if not utfile.open(QIODevice.ReadOnly):
        raise IOError, unicode(utfile.errorString())
Exemplo n.º 2
0
            mhFile.write(modName + ' ' + blobTab[modName][1] + '\n')
        mhFile.close()
    except Exception as e:
        pass

    pqMsgs.infoMsg('Updates applied.',
                   'Changes take effect when PPQT is restarted.')
    return


# Unit test code when executed as main. Be sure to have committed and
# pushed all legit changes before running this as it will try to make
# everything match the current master branch. To create a difference for it
# to see, you can edit any module and make a trivial change. Or you can
# edit modulehashes.txt if it exists, and change one or more hashcodes.
if __name__ == "__main__":
    import sys
    from PyQt4.QtGui import (QApplication, QWidget)
    app = QApplication(sys.argv)  # create an app
    import pqIMC
    IMC = pqIMC.tricorder()
    IMC.mainWindow = QWidget()
    import os
    IMC.appBasePath = os.path.dirname(__file__)  # assume not running bundled
    # test slurp
    # 404 or something like it
    # p = slurp('https://github.com/DoesNotExist/PPQT')
    # turn off airport or pull the ethernet cable to force an error here
    # p = slurp('https://github.com/tallforasmurf/PPQT')
    checkForUpdates()
Exemplo n.º 3
0
                fac += self.lastIndex
                if (fac >= 0) and (fac < IMC.pageTable.size()) :
                    # not off either end of the book, so,
                    self.nextIndex = fac
                    self.showPage()
        if not event.isAccepted() : # we don't do those, pass them on
            super(pngDisplay, self).keyPressEvent(event)

if __name__ == "__main__":
    pass
    import sys
    from PyQt4.QtCore import (Qt,QSettings,QFileInfo,QDir,QStringList)
    from PyQt4.QtGui import (QApplication,QFileDialog,QPlainTextEdit,QTextCursor)
    app = QApplication(sys.argv) # create an app
    import pqIMC
    IMC = pqIMC.tricorder() # set up a fake IMC for unit test
    IMC.settings = QSettings()
    IMC.editWidget = QPlainTextEdit()
    import pqPages
    pqPages.IMC = IMC
    IMC.pageTable=pqPages.pagedb()
    widj = pngDisplay()
    widj.pngPath = QFileDialog.getExistingDirectory(widj,"Pick a Folder of Pngs",".")
    widj.pngPath.append(u'/')
    png_dir = QDir(widj.pngPath)
    png_dir.setFilter(QDir.Files | QDir.NoSymLinks)
    png_dir.setSorting(QDir.Name)
    png_dir.setNameFilters(QStringList(QString(u'*.png')))
    fnumber = 1
    for finf in png_dir.entryInfoList():
        # Read all the pngs and for each cobble up a "page" just to get
Exemplo n.º 4
0
    def doFind(self,kkey):
        if (kkey == IMC.ctl_F) or (self.userFindText.isEmpty()) :
            # ctl+F, or ctl+G but no previous find done, show the find dialog
            # with a COPY of current selection as pqMsgs might truncate it
            prepText = QString(self.page().selectedText())
            (ok, self.userFindText) = pqMsgs.getFindMsg(self,prepText)
        # We should have some findText now, either left from previous find
        # on a ctl-G, or entered by user. If none, then user cleared dialog.
        if not self.userFindText.isEmpty() :
            if not self.page().findText(
                self.userFindText, QWebPage.FindWrapsAroundDocument
                ) :
                pqMsgs.beep()

if __name__ == "__main__":
    import sys
    from PyQt4.QtCore import (Qt)
    from PyQt4.QtGui import (QApplication)
    import pqIMC
    IMC = pqIMC.tricorder()
    if hasattr(sys, 'frozen') : # bundled by pyinstaller?
        base = os.path.dirname(sys.executable)
    else: # running under normal python e.g. from command line or an IDE
        base = os.path.dirname(__file__)
    IMC.appBasePath = base

    app = QApplication(sys.argv) # create an app
    W = helpDisplay()
    W.show()
    app.exec_()
Exemplo n.º 5
0
            (ok, self.findText) = pqMsgs.getFindMsg(self,prepText)
        # dialog or no dialog, we should have some findText now
        if not self.findText.isEmpty() :
            if not self.webPage.findText(
                self.findText, QWebPage.FindWrapsAroundDocument
                ) :
                pqMsgs.beep()

if __name__ == "__main__":
    import sys
    import os
    from PyQt4.QtCore import (Qt,QFile,QIODevice,QFileInfo,QTextStream,QSettings)
    from PyQt4.QtGui import (QApplication,QPlainTextEdit,QFileDialog,QMainWindow)
    import pqIMC
    app = QApplication(sys.argv) # create an app
    IMC = pqIMC.tricorder() # create inter-module communicator
    pqMsgs.IMC = IMC
    IMC.bookType = QString(u"html")
    M = QMainWindow()
    pqMsgs.makeBarIn(M.statusBar())
    utname = QFileDialog.getOpenFileName(M,
                                         "UNIT TEST DATA FOR FLOW", ".")
    utfile = QFile(utname)
    if not utfile.open(QIODevice.ReadOnly):
        raise IOError, unicode(utfile.errorString())
    utinfo = QFileInfo(utfile)
    IMC.bookDirPath = utinfo.absolutePath()
    utstream = QTextStream(utfile)
    utstream.setCodec("UTF-8")
    utqs = utstream.readAll()
    IMC.editWidget = QPlainTextEdit()