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


Python QTextDocument.setDocumentLayout方法代码示例

本文整理汇总了Python中PyQt5.QtGui.QTextDocument.setDocumentLayout方法的典型用法代码示例。如果您正苦于以下问题:Python QTextDocument.setDocumentLayout方法的具体用法?Python QTextDocument.setDocumentLayout怎么用?Python QTextDocument.setDocumentLayout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtGui.QTextDocument的用法示例。


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

示例1: __init__

# 需要导入模块: from PyQt5.QtGui import QTextDocument [as 别名]
# 或者: from PyQt5.QtGui.QTextDocument import setDocumentLayout [as 别名]
 def __init__(self, my_book, parent=None):
     super().__init__(parent)
     self.book = my_book
     # Where we store the last-sought-for find string
     self.find_text = None
     # Register to read and write metadata
     my_book.get_meta_manager().register( C.MD_NO, self.read_meta, self.save_meta )
     # Set our only font (we don't care about the general font, only mono)
     # n.b. this gets the Book's default size as it hasn't loaded a document
     # yet.
     self.setFont(fonts.get_fixed(my_book.get_font_size()))
     # hook up to be notified of a change in font choice
     fonts.notify_me(self.font_change)
     # Set up our document not using the default one
     a_document = QTextDocument()
     a_document.setDocumentLayout(QPlainTextDocumentLayout(a_document))
     self.setDocument(a_document)
     # Turn off linewrap mode
     self.setLineWrapMode(QPlainTextEdit.NoWrap)
     # The following kludge allows us to get the correct highlight
     # color on focus-in. For unknown reasons Qt makes us use the
     # "Inactive" color group even after focus-in. See focusInEvent()
     # and focusOutEvent() below.
     self.palette_active = QPalette(self.palette())
     self.palette_inactive = QPalette(self.palette())
     b = self.palette().brush(QPalette.Active,QPalette.Highlight)
     self.palette_active.setBrush(QPalette.Inactive,QPalette.Highlight,b)
     # Set the cursor shape to IBeam -- no idea why this supposed default
     # inherited from QTextEdit, doesn't happen. But it doesn't.
     self.viewport().setCursor(Qt.IBeamCursor)
     # Hook up a slot to notice that the document has changed its
     # modification state.
     self.document().modificationChanged.connect(self.yikes)
     # Create our edit menu and stow it in the menu bar. Disable it.
     ed_menu = QMenu(C.ED_MENU_EDIT,self)
     ed_menu.addAction(C.ED_MENU_UNDO,self.undo,QKeySequence.Undo)
     ed_menu.addAction(C.ED_MENU_REDO,self.redo,QKeySequence.Redo)
     ed_menu.addSeparator()
     ed_menu.addAction(C.ED_MENU_CUT,self.cut,QKeySequence.Cut)
     ed_menu.addAction(C.ED_MENU_COPY,self.copy,QKeySequence.Copy)
     ed_menu.addAction(C.ED_MENU_PASTE,self.paste,QKeySequence.Paste)
     ed_menu.addSeparator()
     ed_menu.addAction(C.ED_MENU_FIND,self.find_action,QKeySequence.Find)
     ed_menu.addAction(C.ED_MENU_NEXT,self.find_next_action,QKeySequence.FindNext)
     self.edit_menu = mainwindow.get_menu_bar().addMenu(ed_menu)
     self.edit_menu.setVisible(False)
     # In order to get focus events, we need to set focus policy
     self.setFocusPolicy(Qt.StrongFocus)
开发者ID:B-Rich,项目名称:PPQT2,代码行数:50,代码来源:noteview.py

示例2: updatedocs

# 需要导入模块: from PyQt5.QtGui import QTextDocument [as 别名]
# 或者: from PyQt5.QtGui.QTextDocument import setDocumentLayout [as 别名]
 def updatedocs (self):
     newnodedocs = dict()
     for nodeID, nodeobj in self.nodecontainer.nodes.items():
         if nodeID in self.nodedocs:
             newnodedocs[nodeID] = self.nodedocs[nodeID]
         else:
             newnodedocs[nodeID] = dict()
             if nodeobj.typename in ("talk", "response"):
                 textdoc = QTextDocument(self)
                 textdoc.setDocumentLayout(QPlainTextDocumentLayout(textdoc))
                 textdoc.setPlainText(nodeobj.text)
                 newnodedocs[nodeID]["text"] = textdoc
             commentdoc = QTextDocument(self)
             commentdoc.setDocumentLayout(QPlainTextDocumentLayout(commentdoc))
             commentdoc.setPlainText(nodeobj.comment)
             newnodedocs[nodeID]["comment"] = commentdoc
             
             for s in ("enterscripts", "exitscripts", "condition"):
                 scriptdoc = QTextDocument(self)
                 scriptdoc.setDocumentLayout(QPlainTextDocumentLayout(scriptdoc))
                 scriptdoc.setPlainText(self.scripttotext(nodeobj.__dict__[s]))
                 newnodedocs[nodeID][s] = scriptdoc
     self.nodedocs = newnodedocs
开发者ID:bucaneer,项目名称:flint,代码行数:25,代码来源:tree_editor.py

示例3: __init__

# 需要导入模块: from PyQt5.QtGui import QTextDocument [as 别名]
# 或者: from PyQt5.QtGui.QTextDocument import setDocumentLayout [as 别名]
 def __init__ (self, parent):
     super().__init__(parent)
     self.setEnabled(False)
     layout = QFormLayout(self)
     
     l_persistence = QLabel("&Persistence", self)
     persistence = QComboBox(self)
     persvals = ("", "Mark", "OnceEver", "OncePerConv")
     persistence.insertItems(len(persvals), persvals)
     persistence.currentTextChanged.connect(self.persistencechanged)
     l_persistence.setBuddy(persistence)
     self.persistence = persistence
     
     l_bankmode = QLabel("&Bank play mode", self)
     bankmode = QComboBox(self)
     bankmodes = ("First", "All", "Append")
     bankmode.insertItems(len(bankmodes), bankmodes)
     bankmode.currentTextChanged.connect(self.bankmodechanged)
     l_bankmode.setBuddy(bankmode)
     self.bankmode = bankmode
     
     l_questionhub = QLabel("&Question hub", self)
     questionhub = QComboBox(self)
     qhubtypes = ("", "ShowOnce", "ShowNever")
     questionhub.insertItems(len(qhubtypes), qhubtypes)
     questionhub.currentTextChanged.connect(self.questionhubchanged)
     l_questionhub.setBuddy(questionhub)
     self.questionhub = questionhub
     
     l_trigger = QLabel("&Trigger conversation", self)
     trigger = QComboBox(self)
     trigger.currentTextChanged.connect(self.triggerchanged)
     l_trigger.setBuddy(trigger)
     self.trigger = trigger
     
     l_randweight = QLabel("&Random weight", self)
     randweight = QLineEdit(self)
     rwvalidator = QDoubleValidator(self)
     rwvalidator.setBottom(0)
     rwvalidator.setDecimals(3)
     randweight.setValidator(rwvalidator)
     randweight.editingFinished.connect(self.randweightchanged)
     l_randweight.setBuddy(randweight)
     self.randweight = randweight
     
     l_comment = QLabel("&Comment", self)
     comment = ParagraphEdit(self)
     comment.textChanged.connect(self.commentchanged)
     self.comment = comment
     l_comment.setBuddy(comment)
     
     layout.addRow(l_persistence, persistence)
     layout.addRow(l_bankmode, bankmode)
     layout.addRow(l_questionhub, questionhub)
     layout.addRow(l_trigger, trigger)
     layout.addRow(l_randweight, randweight)
     layout.addRow(l_comment, comment)
     
     textdoc = QTextDocument(self)
     textdoc.setDocumentLayout(QPlainTextDocumentLayout(textdoc))
     self.blankdoc = textdoc
开发者ID:bucaneer,项目名称:flint,代码行数:63,代码来源:propeditwidget.py


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