本文整理汇总了Python中calibre.gui2.tweak_book.widgets.PlainTextEdit类的典型用法代码示例。如果您正苦于以下问题:Python PlainTextEdit类的具体用法?Python PlainTextEdit怎么用?Python PlainTextEdit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlainTextEdit类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, parent=None, expected_geometry=(100, 50)):
PlainTextEdit.__init__(self, parent)
self.snippet_manager = SnippetManager(self)
self.completion_popup = CompletionPopup(self)
self.request_completion = self.completion_doc_name = None
self.clear_completion_cache_timer = t = QTimer(self)
t.setInterval(5000), t.timeout.connect(self.clear_completion_cache), t.setSingleShot(True)
self.textChanged.connect(t.start)
self.last_completion_request = -1
self.gutter_width = 0
self.tw = 2
self.expected_geometry = expected_geometry
self.saved_matches = {}
self.syntax = None
self.smarts = NullSmarts(self)
self.current_cursor_line = None
self.current_search_mark = None
self.smarts_highlight_timer = t = QTimer()
t.setInterval(750), t.setSingleShot(True), t.timeout.connect(self.update_extra_selections)
self.highlighter = SyntaxHighlighter()
self.line_number_area = LineNumbers(self)
self.apply_settings()
self.setMouseTracking(True)
self.cursorPositionChanged.connect(self.highlight_cursor_line)
self.blockCountChanged[int].connect(self.update_line_number_area_width)
self.updateRequest.connect(self.update_line_number_area)
示例2: mousePressEvent
def mousePressEvent(self, ev):
if self.completion_popup.isVisible() and not self.completion_popup.rect().contains(ev.pos()):
# For some reason using eventFilter for this does not work, so we
# implement it here
self.completion_popup.abort()
if ev.modifiers() & Qt.CTRL:
url = self.link_for_position(ev.pos())
if url is not None:
ev.accept()
self.link_clicked.emit(url)
return
return PlainTextEdit.mousePressEvent(self, ev)
示例3: override_shortcut
def override_shortcut(self, ev):
# Let the global cut/copy/paste/undo/redo shortcuts work, this avoids the nbsp
# problem as well, since they use the overridden createMimeDataFromSelection() method
# instead of the one from Qt (which makes copy() work), and allows proper customization
# of the shortcuts
if ev in (QKeySequence.Copy, QKeySequence.Cut, QKeySequence.Paste, QKeySequence.Undo, QKeySequence.Redo):
ev.ignore()
return True
# This is used to convert typed hex codes into unicode
# characters
if ev.key() == Qt.Key_X and ev.modifiers() == Qt.AltModifier:
ev.accept()
return True
return PlainTextEdit.override_shortcut(self, ev)
示例4: keyPressEvent
def keyPressEvent(self, ev):
if self.snippet_manager.handle_key_press(ev):
return
PlainTextEdit.keyPressEvent(self, ev)
示例5: __init__
def __init__(self, text, parent=None):
PlainTextEdit.__init__(self, parent)
if text:
self.setPlainText(text)
self.snippet_manager = SnippetManager(self)