当前位置: 首页>>代码示例>>Python>>正文


Python functions.mainWindow函数代码示例

本文整理汇总了Python中manuskript.functions.mainWindow函数的典型用法代码示例。如果您正苦于以下问题:Python mainWindow函数的具体用法?Python mainWindow怎么用?Python mainWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mainWindow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: addCharacterInfo

    def addCharacterInfo(self, ID):
        c = self.getCharacterByID(ID)
        self.beginInsertRows(c.index(), len(c.infos), len(c.infos))
        c.infos.append(CharacterInfo(c, description="Description", value="Value"))
        self.endInsertRows()

        mainWindow().updatePersoInfoView()
开发者ID:olivierkes,项目名称:manuskript,代码行数:7,代码来源:characterModel.py

示例2: refToLink

def refToLink(ref):
    """Transforms the reference ``ref`` in a link displaying useful infos
    about that reference. For character, character's name. For text item,
    item's name, etc.
    """
    match = re.fullmatch(RegEx, ref)
    if match:
        _type = match.group(1)
        _ref = match.group(2)
        text = ""
        if _type == TextLetter:
            m = mainWindow().mdlOutline
            idx = m.getIndexByID(_ref)
            if idx.isValid():
                item = idx.internalPointer()
                text = item.title()

        elif _type == PersoLetter:
            m = mainWindow().mdlPersos
            text = m.item(int(_ref), Perso.name.value).text()

        elif _type == PlotLetter:
            m = mainWindow().mdlPlots
            text = m.getPlotNameByID(_ref)

        elif _type == WorldLetter:
            m = mainWindow().mdlWorld
            text = m.itemByID(_ref).text()

        if text:
            return "<a href='{ref}'>{text}</a>".format(
                    ref=ref,
                    text=text)
        else:
            return ref
开发者ID:georgehank,项目名称:manuskript,代码行数:35,代码来源:references.py

示例3: open

def open(ref):
    """Identify ``ref`` and open it."""
    match = re.fullmatch(RegEx, ref)
    if not match:
        return

    _type = match.group(1)
    _ref = match.group(2)

    if _type == CharacterLetter:
        mw = mainWindow()
        item = mw.lstCharacters.getItemByID(_ref)

        if item:
            mw.tabMain.setCurrentIndex(mw.TabPersos)
            mw.lstCharacters.setCurrentItem(item)
            return True

        print("Error: Ref {} not found".format(ref))
        return False

    elif _type == TextLetter:
        mw = mainWindow()
        index = mw.mdlOutline.getIndexByID(_ref)

        if index.isValid():
            mw.tabMain.setCurrentIndex(mw.TabRedac)
            mw.mainEditor.setCurrentModelIndex(index, newTab=True)
            return True
        else:
            print("Ref not found")
            return False

    elif _type == PlotLetter:
        mw = mainWindow()
        item = mw.lstPlots.getItemByID(_ref)

        if item:
            mw.tabMain.setCurrentIndex(mw.TabPlots)
            mw.lstPlots.setCurrentItem(item)
            return True

        print("Ref not found")
        return False

    elif _type == WorldLetter:
        mw = mainWindow()
        item = mw.mdlWorld.itemByID(_ref)

        if item:
            mw.tabMain.setCurrentIndex(mw.TabWorld)
            mw.treeWorld.setCurrentIndex(
                    mw.mdlWorld.indexFromItem(item))
            return True

        print("Ref not found")
        return False

    print("Ref not implemented")
    return False
开发者ID:olivierkes,项目名称:manuskript,代码行数:60,代码来源:references.py

示例4: output

 def output(self, settingsWidget):
     settings = settingsWidget.getSettings()
     try:
         return self.concatenate(mainWindow().mdlOutline.rootItem, settings)
     except re.error as e:
         QMessageBox.warning(mainWindow().dialog, qApp.translate("Export", "Error"),
                             qApp.translate("Export", "Error processing regular expression : \n{}").format(str(e)))
         return ""
开发者ID:olivierkes,项目名称:manuskript,代码行数:8,代码来源:plainText.py

示例5: setAppFontSize

 def setAppFontSize(self, val):
     """
     Set application default font point size.
     """
     f = qApp.font()
     f.setPointSize(val)
     qApp.setFont(f)
     mainWindow().setFont(f)
     sttgs = QSettings(qApp.organizationName(), qApp.applicationName())
     sttgs.setValue("appFontSize", val)
开发者ID:olivierkes,项目名称:manuskript,代码行数:10,代码来源:settingsWindow.py

示例6: choseCharacterColor

 def choseCharacterColor(self):
     ID = self.currentCharacterID()
     c = self._model.getCharacterByID(ID)
     if c:
         color = iconColor(c.icon)
     else:
         color = Qt.white
     self.colorDialog = QColorDialog(color, mainWindow())
     color = self.colorDialog.getColor(color)
     if color.isValid():
         c.setColor(color)
         mainWindow().updateCharacterColor(ID)
开发者ID:olivierkes,项目名称:manuskript,代码行数:12,代码来源:characterTreeView.py

示例7: updateAllWidgets

    def updateAllWidgets(self):

        # Update font and defaultBlockFormat to all textEditView. Drastically.
        for w in mainWindow().findChildren(textEditView, QRegExp(".*")):
            w.loadFontSettings()

        # Update background color in all tabSplitter (tabs)
        for w in mainWindow().findChildren(tabSplitter, QRegExp(".*")):
            w.updateStyleSheet()

        # Update background color in all folder text view:
        for w in mainWindow().findChildren(QWidget, QRegExp("editorWidgetFolderText")):
            w.setStyleSheet("background: {};".format(settings.textEditor["background"]))
开发者ID:olivierkes,项目名称:manuskript,代码行数:13,代码来源:settingsWindow.py

示例8: tooltip

def tooltip(ref):
    """Returns a tooltip in HTML for the reference ``ref``."""
    match = re.fullmatch(RegEx, ref)

    if not match:
        return qApp.translate("references", "Not a reference: {}.").format(ref)

    _type = match.group(1)
    _ref = match.group(2)

    if _type == TextLetter:
        m = mainWindow().mdlOutline
        idx = m.getIndexByID(_ref)

        if not idx.isValid():
            return qApp.translate("references", "Unknown reference: {}.").format(ref)

        item = idx.internalPointer()

        if item.isFolder():
            tt = qApp.translate("references", "Folder: <b>{}</b>").format(item.title())
        else:
            tt = qApp.translate("references", "Text: <b>{}</b>").format(item.title())
        tt += "<br><i>{}</i>".format(item.path())

        return tt

    elif _type == PersoLetter:
        m = mainWindow().mdlPersos
        item = m.item(int(_ref), Perso.name.value)
        if item:
            return qApp.translate("references", "Character: <b>{}</b>").format(item.text())

    elif _type == PlotLetter:
        m = mainWindow().mdlPlots
        name = m.getPlotNameByID(_ref)
        if name:
            return qApp.translate("references", "Plot: <b>{}</b>").format(name)

    elif _type == WorldLetter:
        m = mainWindow().mdlWorld
        item = m.itemByID(_ref)
        if item:
            name = item.text()
            path = m.path(item)
            return qApp.translate("references", "World: <b>{name}</b>{path}").format(
                    name=name,
                    path=" <span style='color:gray;'>({})</span>".format(path) if path else "")

    return qApp.translate("references", "<b>Unknown reference:</b> {}.").format(ref)
开发者ID:georgehank,项目名称:manuskript,代码行数:50,代码来源:references.py

示例9: convert

    def convert(self, src, args, outputfile=None):
        args = [self.cmd] + args

        if outputfile:
            args.append("--output={}".format(outputfile))

        for name, col, var in [
            ("Title", 0, "title"),
            ("Subtitle", 1, "subtitle"),
            ("Serie", 2, ""),
            ("Volume", 3, ""),
            ("Genre", 4, ""),
            ("License", 5, ""),
            ("Author", 6, "author"),
            ("Email", 7, ""),
            ]:
            item = mainWindow().mdlFlatData.item(0, col)
            if var and item and item.text().strip():
                args.append("--variable={}:{}".format(var, item.text().strip()))

        # Add title metatadata required for pandoc >= 2.x
        args.append("--metadata=title:{}".format(mainWindow().mdlFlatData.item(0, 0).text().strip()))

        qApp.setOverrideCursor(QCursor(Qt.WaitCursor))

        p = subprocess.Popen(
            args,
            stdin=subprocess.PIPE,
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE
        )

        if not type(src) == bytes:
            src = src.encode("utf-8")  # assumes utf-8

        stdout, stderr = p.communicate(src)

        qApp.restoreOverrideCursor()

        if stderr or p.returncode != 0:
            err = "ERROR on export" + "\n" \
                + "Return code" + ": %d\n" % (p.returncode) \
                + "Command and parameters" + ":\n%s\n" % (p.args) \
                + "Stderr content" + ":\n" + stderr.decode("utf-8") 
            print(err)
            QMessageBox.critical(mainWindow().dialog, qApp.translate("Export", "Error"), err)
            return None

        return stdout.decode("utf-8")
开发者ID:olivierkes,项目名称:manuskript,代码行数:49,代码来源:__init__.py

示例10: doCompile

    def doCompile(self, filename):
        mw = mainWindow()
        root = mw.mdlOutline.rootItem

        doc = QTextDocument()
        cursor = QTextCursor(doc)

        def appendItem(item):
            if item.isFolder():

                cursor.setPosition(doc.characterCount() - 1)
                title = "<h{l}>{t}</h{l}><br>\n".format(
                        l=str(item.level() + 1),
                        t=item.title())
                cursor.insertHtml(title)

                for c in item.children():
                    appendItem(c)

            else:
                text = self.formatText(item.text(), item.type())
                cursor.setPosition(doc.characterCount() - 1)
                cursor.insertHtml(text)

        for c in root.children():
            appendItem(c)

        dw = QTextDocumentWriter(filename, "odt")
        dw.write(doc)
开发者ID:TenKeyAngle,项目名称:manuskript,代码行数:29,代码来源:odt_old.py

示例11: doCompile

    def doCompile(self, path):
        # FIXME: overwrites when items have identical names
        mw = mainWindow()
        root = mw.mdlOutline.rootItem

        def writeItem(item, path):
            if item.isFolder():
                path2 = os.path.join(path, item.title())

                try:
                    os.mkdir(path2)
                except FileExistsError:
                    pass

                for c in item.children():
                    writeItem(c, path2)

            else:
                ext = ".t2t" if item.isT2T() else \
                    ".html" if item.isHTML() else \
                        ".txt"
                path2 = os.path.join(path, item.title() + ext)
                f = open(path2, "w")
                text = self.formatText(item.text(), item.type())
                f.write(text)

        for c in root.children():
            writeItem(c, path)
开发者ID:georgehank,项目名称:manuskript,代码行数:28,代码来源:arbo.py

示例12: itemContains

    def itemContains(self, text, columns, mainWindow=mainWindow(), caseSensitive=False):
        lst = []
        text = text.lower() if not caseSensitive else text
        for c in columns:

            if c == Outline.POV.value and self.POV():
                c = mainWindow.mdlCharacter.getCharacterByID(self.POV())
                if c:
                    searchIn = c.name()
                else:
                    searchIn = ""
                    print("Character POV not found:", self.POV())

            elif c == Outline.status.value:
                searchIn = mainWindow.mdlStatus.item(toInt(self.status()), 0).text()

            elif c == Outline.label.value:
                searchIn = mainWindow.mdlLabels.item(toInt(self.label()), 0).text()

            else:
                searchIn = self.data(c)

            searchIn = searchIn.lower() if not caseSensitive else searchIn

            if text in searchIn:
                if not self.ID() in lst:
                    lst.append(self.ID())

        return lst
开发者ID:TenKeyAngle,项目名称:manuskript,代码行数:29,代码来源:outlineModel.py

示例13: saveProject

def saveProject():
    """
    Saves the whole project. Call this function to save the project in Version 0 format.
    """

    files = []
    mw = mainWindow()

    files.append((saveStandardItemModelXML(mw.mdlFlatData),
                  "flatModel.xml"))
    print("ERROR: file format 0 does not save characters !")
    # files.append((saveStandardItemModelXML(mw.mdlCharacter),
    #               "perso.xml"))
    files.append((saveStandardItemModelXML(mw.mdlWorld),
                  "world.xml"))
    files.append((saveStandardItemModelXML(mw.mdlLabels),
                  "labels.xml"))
    files.append((saveStandardItemModelXML(mw.mdlStatus),
                  "status.xml"))
    files.append((saveStandardItemModelXML(mw.mdlPlots),
                  "plots.xml"))
    files.append((mw.mdlOutline.saveToXML(),
                  "outline.xml"))
    files.append((settings.save(),
                  "settings.pickle"))

    saveFilesToZip(files, mw.currentProject)
开发者ID:TenKeyAngle,项目名称:manuskript,代码行数:27,代码来源:version_0.py

示例14: __init__

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.setupUi(self)
        self._updating = False

        self.mw = mainWindow()
        self.tab.tabCloseRequested.connect(self.closeTab)
        self.tab.currentChanged.connect(self.tabChanged)

        # UI
        try:
            self.tab.setTabBarAutoHide(True)
        except AttributeError:
            print("Info: install Qt 5.4 or higher to use tabbar auto-hide in editor.")

        # Connections --------------------------------------------------------

        self.sldCorkSizeFactor.valueChanged.connect(
                self.setCorkSizeFactor, AUC)
        self.btnRedacFolderCork.toggled.connect(
                self.sldCorkSizeFactor.setVisible, AUC)
        self.btnRedacFolderText.clicked.connect(
                lambda v: self.setFolderView("text"), AUC)
        self.btnRedacFolderCork.clicked.connect(
                lambda v: self.setFolderView("cork"), AUC)
        self.btnRedacFolderOutline.clicked.connect(
                lambda v: self.setFolderView("outline"), AUC)

        self.btnRedacFullscreen.clicked.connect(
                self.showFullScreen, AUC)
开发者ID:georgehank,项目名称:manuskript,代码行数:30,代码来源:mainEditor.py

示例15: callMainTreeView

 def callMainTreeView(self, functionName):
     """
     The tree view in main window must have same index as the text
     edit that has focus. So we can pass it the call for documents
     edits like: duplicate, move up, etc.
     """
     if self._index and self._column == Outline.text:
         function = getattr(F.mainWindow().treeRedacOutline, functionName)
         function()
开发者ID:olivierkes,项目名称:manuskript,代码行数:9,代码来源:textEditView.py


注:本文中的manuskript.functions.mainWindow函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。