本文整理匯總了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)