本文整理汇总了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)
示例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
示例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