本文整理汇总了Python中qutepart.Qutepart.setLineWrapMode方法的典型用法代码示例。如果您正苦于以下问题:Python Qutepart.setLineWrapMode方法的具体用法?Python Qutepart.setLineWrapMode怎么用?Python Qutepart.setLineWrapMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qutepart.Qutepart
的用法示例。
在下文中一共展示了Qutepart.setLineWrapMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EditorTab
# 需要导入模块: from qutepart import Qutepart [as 别名]
# 或者: from qutepart.Qutepart import setLineWrapMode [as 别名]
class EditorTab(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setupEditor()
mainLayout = QtGui.QVBoxLayout()
mainLayout.addWidget(self.editor)
# mainLayout.addStretch(1)
mainLayout.setContentsMargins(0, 0, 0, 0)
self.editor.adjustSize()
self.setLayout(mainLayout)
def setupEditor(self):
font = QtGui.QFont()
font.setFamily('Monaco')
# font.setFixedPitch(True)
font.setPointSize(12)
self.editor = Qutepart()
self.editor.setFont(font)
self.editor.adjustSize()
self.editor.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
# self.highlighter = Highlighter(self.editor.document())
示例2: Document
# 需要导入模块: from qutepart import Qutepart [as 别名]
# 或者: from qutepart.Qutepart import setLineWrapMode [as 别名]
#.........这里部分代码省略.........
elif self._externallyRemoved:
icon = "close.png"
elif self._externallyModified and self.qutepart.document().isModified():
icon = "modified-externally-modified.png"
elif self._externallyModified:
icon = "modified-externally.png"
elif self.qutepart.document().isModified():
icon = "save.png"
else:
icon = "transparent.png"
return QIcon(":/enkiicons/" + icon)
def invokeGoTo(self):
"""Show GUI dialog, go to line, if user accepted it
"""
line = self.qutepart.cursorPosition[0]
gotoLine, accepted = QInputDialog.getInt(self, self.tr("Go To Line..."),
self.tr("Enter the line you want to go to:"),
line, 1, len(self.qutepart.lines), 1)
if accepted:
gotoLine -= 1
self.qutepart.cursorPosition = gotoLine, None
self.setFocus()
def printFile(self):
"""Print file
"""
raise NotImplemented()
def _configureEolMode(self, originalText):
"""Detect end of line mode automatically and apply detected mode
"""
modes = set()
for line in originalText.splitlines(True):
if line.endswith('\r\n'):
modes.add('\r\n')
elif line.endswith('\n'):
modes.add('\n')
elif line.endswith('\r'):
modes.add('\r')
if len(modes) == 1: # exactly one
detectedMode = modes.pop()
else:
detectedMode = None
default = self._EOL_CONVERTOR[core.config()["Qutepart"]["EOL"]["Mode"]]
if len(modes) > 1:
message = "%s contains mix of End Of Line symbols. It will be saved with '%s'" % \
(self.filePath(), repr(default))
core.mainWindow().appendMessage(message)
self.qutepart.eol = default
self.qutepart.document().setModified(True)
elif core.config()["Qutepart"]["EOL"]["AutoDetect"]:
if detectedMode is not None:
self.qutepart.eol = detectedMode
else: # empty set, not detected
self.qutepart.eol = default
else: # no mix, no autodetect. Force EOL
if detectedMode is not None and \
detectedMode != default:
message = "%s: End Of Line mode is '%s', but file will be saved with '%s'. " \
"EOL autodetection is disabled in the settings" % \
(self.fileName(), repr(detectedMode), repr(default))
core.mainWindow().appendMessage(message)
self.qutepart.document().setModified(True)
self.qutepart.eol = default
@pyqtSlot()
def _applyQpartSettings(self):
"""Apply qutepart settings
"""
conf = core.config()['Qutepart']
self.qutepart.setFont(QFont(conf['Font']['Family'], conf['Font']['Size']))
self.qutepart.indentUseTabs = conf['Indentation']['UseTabs']
self.qutepart.indentWidth = conf['Indentation']['Width']
if conf['Edge']['Enabled']:
self.qutepart.lineLengthEdge = conf['Edge']['Column']
else:
self.qutepart.lineLengthEdge = None
self.qutepart.lineLengthEdgeColor = QColor(conf['Edge']['Color'])
self.qutepart.completionEnabled = conf['AutoCompletion']['Enabled']
self.qutepart.completionThreshold = conf['AutoCompletion']['Threshold']
self.qutepart.setLineWrapMode(QPlainTextEdit.WidgetWidth if conf['Wrap']['Enabled'] else QPlainTextEdit.NoWrap)
if conf['Wrap']['Mode'] == 'WrapAtWord':
self.qutepart.setWordWrapMode(QTextOption.WrapAtWordBoundaryOrAnywhere)
elif conf['Wrap']['Mode'] == 'WrapAnywhere':
self.qutepart.setWordWrapMode(QTextOption.WrapAnywhere)
else:
assert 'Invalid wrap mode', conf['Wrap']['Mode']
# EOL is managed by _configureEolMode(). But, if autodetect is disabled, we may apply new value here
if not conf['EOL']['AutoDetect']:
self.qutepart.eol = self._EOL_CONVERTOR[conf['EOL']['Mode']]