本文整理汇总了Python中pyqode.core.api.utils.DelayJobRunner类的典型用法代码示例。如果您正苦于以下问题:Python DelayJobRunner类的具体用法?Python DelayJobRunner怎么用?Python DelayJobRunner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DelayJobRunner类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
Panel.__init__(self, dynamic=True)
self.job_runner = DelayJobRunner(delay=500)
Ui_SearchPanel.__init__(self)
self.setupUi(self)
self.toolButtonClose.clicked.connect(self.on_close)
self.actionSearch.triggered.connect(self.on_search)
self.actionActionSearchAndReplace.triggered.connect(self.on_search_and_replace)
self.lineEditReplace.prompt_text = _(' Replace')
#: Occurrences counter
self.cpt_occurences = 0
self._previous_stylesheet = ""
self._separator = None
self._decorations = []
self._occurrences = []
self._current_occurrence_index = 0
self._bg = None
self._fg = None
self._update_buttons(txt="")
self.lineEditSearch.installEventFilter(self)
self.lineEditReplace.installEventFilter(self)
self._init_actions()
self._init_style()
self.checkBoxRegex.stateChanged.connect(
self.checkBoxWholeWords.setDisabled)
示例2: __init__
def __init__(self):
Panel.__init__(self)
self._markers = []
self._icons = {}
self._previous_line = -1
self.scrollable = True
self._job_runner = DelayJobRunner(delay=100)
self.setMouseTracking(True)
self._to_remove = []
示例3: __init__
def __init__(self, worker,
delay=500,
show_tooltip=True):
"""
:param worker: The process function or class to call remotely.
:param delay: The delay used before running the analysis process when
trigger is set to
:class:pyqode.core.modes.CheckerTriggers`
:param show_tooltip: Specify if a tooltip must be displayed when the
mouse is over a checker message decoration.
"""
Mode.__init__(self)
QtCore.QObject.__init__(self)
# max number of messages to keep good performances
self.limit = 200
self._job_runner = DelayJobRunner(delay=delay)
self._messages = []
self._worker = worker
self._mutex = QtCore.QMutex()
self._show_tooltip = show_tooltip
self._pending_msg = []
self._finished = True
示例4: __init__
def __init__(self):
Mode.__init__(self)
QtCore.QObject.__init__(self)
self._current_completion = ""
# use to display a waiting cursor if completion provider takes too much
# time
self._job_runner = DelayJobRunner(delay=1000)
self._tooltips = {}
self._cursor_line = -1
self._cancel_next = False
self._request_cnt = 0
self._last_completion_prefix = ""
self._trigger_key = None
self._trigger_len = None
self._trigger_symbols = None
self._show_tooltips = None
self._case_sensitive = None
self._data = None
self._completer = None
self._col = 0
self._skip_next_backspace_released = False
self._init_settings()
示例5: __init__
def __init__(self):
Panel.__init__(self)
self.job_runner = DelayJobRunner(delay=500)
Ui_SearchPanel.__init__(self)
self.setupUi(self)
self.lineEditReplace.prompt_text = ' Replace'
#: Occurrences counter
self.cpt_occurences = 0
self._previous_stylesheet = ""
self._separator = None
self._decorations = []
self._occurrences = []
self._current_occurrence_index = -1
self._bg = None
self._fg = None
self._update_buttons(txt="")
self.lineEditSearch.installEventFilter(self)
self.lineEditReplace.installEventFilter(self)
self._init_actions()
self._init_style()
self.checkBoxRegex.stateChanged.connect(
self.checkBoxWholeWords.setDisabled)
示例6: __init__
def __init__(self, parent=None, create_default_actions=True):
"""
:param parent: Parent widget
:param create_default_actions: True to create the default context
menu actions (copy, paste, edit)
"""
super(CodeEdit, self).__init__(parent)
self.clones = []
self._default_font_size = 10
self._backend = BackendManager(self)
self._file = FileManager(self)
self._modes = ModesManager(self)
self._panels = PanelsManager(self)
self._decorations = TextDecorationsManager(self)
self.document().modificationChanged.connect(self._emit_dirty_changed)
self._word_separators = [
'~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '{',
'}', '|', ':', '"', "'", "<", ">", "?", ",", ".", "/", ";", '[',
']', '\\', '\n', '\t', '=', '-', ' '
]
self._save_on_focus_out = False
self._use_spaces_instead_of_tabs = True
self._whitespaces_foreground = None
self._sel_background = None
self._show_whitespaces = False
self._foreground = None
self._sel_foreground = None
self._tab_length = 4
self._zoom_level = 0
self._font_size = 10
self._background = None
QtGui.QFontDatabase.addApplicationFont(
':/fonts/rc/SourceCodePro-Regular.ttf')
QtGui.QFontDatabase.addApplicationFont(
':/fonts/rc/SourceCodePro-Bold.ttf')
self._font_family = self._DEFAULT_FONT
self._mimetypes = []
# Flags/Working variables
self._last_mouse_pos = QtCore.QPoint(0, 0)
self._modified_lines = set()
self._cleaning = False
self._visible_blocks = []
self._tooltips_runner = DelayJobRunner(delay=700)
self._prev_tooltip_block_nbr = -1
self._original_text = ""
self._dirty = False
# setup context menu
self._actions = []
self._menus = []
if create_default_actions:
self._init_actions()
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self._show_context_menu)
self._mnu = None # bug with PySide (github #63)
# init settings and styles from global settings/style modules
self._init_settings()
self._init_style()
# connect slots
self.textChanged.connect(self._on_text_changed)
self.blockCountChanged.connect(self.update)
self.cursorPositionChanged.connect(self.update)
self.selectionChanged.connect(self.update)
self.setMouseTracking(True)
self.setCenterOnScroll(True)
self.setLineWrapMode(self.NoWrap)
示例7: CodeEdit
#.........这里部分代码省略.........
self._modes = ModesManager(self)
self._panels = PanelsManager(self)
self._decorations = TextDecorationsManager(self)
self.document().modificationChanged.connect(self._emit_dirty_changed)
self._word_separators = [
'~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '{',
'}', '|', ':', '"', "'", "<", ">", "?", ",", ".", "/", ";", '[',
']', '\\', '\n', '\t', '=', '-', ' '
]
self._save_on_focus_out = False
self._use_spaces_instead_of_tabs = True
self._whitespaces_foreground = None
self._sel_background = None
self._show_whitespaces = False
self._foreground = None
self._sel_foreground = None
self._tab_length = 4
self._zoom_level = 0
self._font_size = 10
self._background = None
QtGui.QFontDatabase.addApplicationFont(
':/fonts/rc/SourceCodePro-Regular.ttf')
QtGui.QFontDatabase.addApplicationFont(
':/fonts/rc/SourceCodePro-Bold.ttf')
self._font_family = self._DEFAULT_FONT
self._mimetypes = []
# Flags/Working variables
self._last_mouse_pos = QtCore.QPoint(0, 0)
self._modified_lines = set()
self._cleaning = False
self._visible_blocks = []
self._tooltips_runner = DelayJobRunner(delay=700)
self._prev_tooltip_block_nbr = -1
self._original_text = ""
self._dirty = False
# setup context menu
self._actions = []
self._menus = []
if create_default_actions:
self._init_actions()
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self._show_context_menu)
self._mnu = None # bug with PySide (github #63)
# init settings and styles from global settings/style modules
self._init_settings()
self._init_style()
# connect slots
self.textChanged.connect(self._on_text_changed)
self.blockCountChanged.connect(self.update)
self.cursorPositionChanged.connect(self.update)
self.selectionChanged.connect(self.update)
self.setMouseTracking(True)
self.setCenterOnScroll(True)
self.setLineWrapMode(self.NoWrap)
def __repr__(self):
return '%s(path=%r)' % (self.__class__.__name__, self.file.path)
def split(self):
示例8: SearchAndReplacePanel
#.........这里部分代码省略.........
@background.setter
def background(self, value):
self._bg = value
self._refresh_decorations()
# propagate changes to every clone
if self.editor:
for clone in self.editor.clones:
try:
clone.modes.get(self.__class__).background = value
except KeyError:
# this should never happen since we're working with clones
pass
@property
def foreground(self):
""" Text decoration foreground """
return self._fg
@foreground.setter
def foreground(self, value):
self._fg = value
self._refresh_decorations()
# propagate changes to every clone
if self.editor:
for clone in self.editor.clones:
try:
clone.modes.get(self.__class__).foreground = value
except KeyError:
# this should never happen since we're working with clones
pass
def __init__(self):
Panel.__init__(self, dynamic=True)
self.job_runner = DelayJobRunner(delay=500)
Ui_SearchPanel.__init__(self)
self.setupUi(self)
self.lineEditReplace.prompt_text = ' Replace'
#: Occurrences counter
self.cpt_occurences = 0
self._previous_stylesheet = ""
self._separator = None
self._decorations = []
self._occurrences = []
self._current_occurrence_index = 0
self._bg = None
self._fg = None
self._update_buttons(txt="")
self.lineEditSearch.installEventFilter(self)
self.lineEditReplace.installEventFilter(self)
self._init_actions()
self._init_style()
self.checkBoxRegex.stateChanged.connect(
self.checkBoxWholeWords.setDisabled)
def _init_actions(self):
icon_size = QtCore.QSize(16, 16)
icon = icons.icon('edit-find', ':/pyqode-icons/rc/edit-find.png',
'fa.search')
self.actionSearch.setIcon(icon)
self.actionSearch.setShortcut('Ctrl+F')
self.labelSearch.setPixmap(icon.pixmap(icon_size))
icon = icons.icon(
'edit-find-replace', ':/pyqode-icons/rc/edit-find-replace.png',
'fa.search-plus')
示例9: CheckerMode
class CheckerMode(Mode, QtCore.QObject):
"""
Performs a user defined code analysis job using the backend and
display the results on the editor instance.
The user defined code analysis job is a simple **function** with the
following signature:
.. code-block:: python
def analysisProcess(data)
where data is the request data:
.. code-block:: python
request_data = {
'code': self.editor.toPlainText(),
'path': self.editor.file.path,
'encoding': self.editor.file.encoding
}
and the return value is a tuple made up of the following elements:
(description, status, line, [col], [icon], [color], [path])
The background process is ran when the text changed and the ide is an idle
state for a few seconds.
You can also request an analysis manually using
:meth:`pyqode.core.modes.CheckerMode.request_analysis`
Messages are displayed as text decorations on the editor. A checker panel
will take care of display message icons next to each line.
"""
@property
def messages(self):
"""
Returns the entire list of checker messages.
"""
return self._messages
def __init__(self, worker,
delay=500,
show_tooltip=True):
"""
:param worker: The process function or class to call remotely.
:param delay: The delay used before running the analysis process when
trigger is set to
:class:pyqode.core.modes.CheckerTriggers`
:param show_tooltip: Specify if a tooltip must be displayed when the
mouse is over a checker message decoration.
"""
Mode.__init__(self)
QtCore.QObject.__init__(self)
# max number of messages to keep good performances
self.limit = 200
self._job_runner = DelayJobRunner(delay=delay)
self._messages = []
self._worker = worker
self._mutex = QtCore.QMutex()
self._show_tooltip = show_tooltip
self._pending_msg = []
self._finished = True
def add_messages(self, messages):
"""
Adds a message or a list of message.
:param messages: A list of messages or a single message
"""
# remove old messages
if len(messages) > self.limit:
messages = messages[:self.limit]
_logger(self.__class__).debug('adding %s messages' % len(messages))
self._finished = False
self._new_messages = messages
self._to_check = list(self._messages)
self._pending_msg = messages
# start removing messages, new message won't be added until we
# checked all message that need to be removed
QtCore.QTimer.singleShot(1, self._remove_batch)
def _remove_batch(self):
if self.editor is None:
return
for i in range(100):
if not len(self._to_check):
# all messages checker, start adding messages now
QtCore.QTimer.singleShot(1, self._add_batch)
self.editor.repaint()
return False
msg = self._to_check.pop(0)
if msg.block is None:
msg.block = self.editor.document().findBlockByNumber(msg.line)
if msg not in self._new_messages:
self.remove_message(msg)
self.editor.repaint()
QtCore.QTimer.singleShot(1, self._remove_batch)
#.........这里部分代码省略.........
示例10: CodeCompletionMode
#.........这里部分代码省略.........
@property
def case_sensitive(self):
"""
True to performs case sensitive completion matching.
"""
return self._case_sensitive
@case_sensitive.setter
def case_sensitive(self, value):
self._case_sensitive = value
if self.editor:
# propagate changes to every clone
for clone in self.editor.clones:
try:
clone.modes.get(CodeCompletionMode).case_sensitive = value
except KeyError:
# this should never happen since we're working with clones
pass
@property
def completion_prefix(self):
"""
Returns the current completion prefix
"""
return self._helper.word_under_cursor(
select_whole_word=False).selectedText().strip()
def __init__(self):
Mode.__init__(self)
QtCore.QObject.__init__(self)
self._current_completion = ""
# use to display a waiting cursor if completion provider takes too much
# time
self._job_runner = DelayJobRunner(delay=1000)
self._tooltips = {}
self._cursor_line = -1
self._cancel_next = False
self._request_cnt = 0
self._last_completion_prefix = ""
self._trigger_key = None
self._trigger_len = None
self._trigger_symbols = None
self._show_tooltips = None
self._case_sensitive = None
self._data = None
self._completer = None
self._col = 0
self._skip_next_backspace_released = False
self._init_settings()
def _init_settings(self):
self._trigger_key = QtCore.Qt.Key_Space
self._trigger_len = 1
self._trigger_symbols = ['.']
self._show_tooltips = True
self._case_sensitive = False
def request_completion(self):
"""
Requests a code completion at the current cursor position.
"""
_logger().debug('request code completion')
self._col = self.editor.textCursor().positionInBlock() - len(
self.completion_prefix)
helper = TextHelper(self.editor)
if not self._request_cnt:
示例11: MarkerPanel
class MarkerPanel(Panel):
"""
General purpose marker panel.
This panels takes care of drawing icons at a specific line number.
Use addMarker, removeMarker and clearMarkers to manage the collection of
displayed makers.
You can create a user editable panel (e.g. a breakpoints panel) by using
the following signals:
- :attr:`pyqode.core.panels.MarkerPanel.add_marker_requested`
- :attr:`pyqode.core.panels.MarkerPanel.remove_marker_requested`
"""
#: Signal emitted when the user clicked in a place where there is no
#: marker.
add_marker_requested = QtCore.Signal(int)
#: Signal emitted when the user clicked on an existing marker.
remove_marker_requested = QtCore.Signal(int)
def __init__(self):
Panel.__init__(self)
self._markers = []
self._icons = {}
self._previous_line = -1
self.scrollable = True
self._job_runner = DelayJobRunner(delay=100)
self.setMouseTracking(True)
self._to_remove = []
def add_marker(self, marker):
"""
Adds the marker to the panel.
:param marker: Marker to add
:type marker: pyqode.core.modes.Marker
"""
key, val = self.make_marker_icon(marker.icon)
if key and val:
self._icons[key] = val
self._markers.append(marker)
doc = self.editor.document()
assert isinstance(doc, QtGui.QTextDocument)
block = doc.findBlockByLineNumber(marker.position - 1)
user_data = block.userData()
if user_data is None:
user_data = TextBlockUserData()
block.setUserData(user_data)
marker.panel_ref = self
user_data.markers.append(marker)
self.repaint()
@staticmethod
@memoized
def make_marker_icon(icon):
"""
Make (and memoize) an icon from an icon filename.
:param icon: Icon filename or tuple (to use a theme).
"""
if isinstance(icon, tuple):
return icon[0], QtGui.QIcon.fromTheme(
icon[0], QtGui.QIcon(icon[1]))
elif isinstance(icon, str):
return icon, QtGui.QIcon(icon)
else:
return None, None
def remove_marker(self, marker):
"""
Removes a marker from the panel
:param marker: Marker to remove
:type marker: pyqode.core.Marker
"""
self._markers.remove(marker)
self._to_remove.append(marker)
self.repaint()
def clear_markers(self):
""" Clears the markers list """
while len(self._markers):
self.remove_marker(self._markers[0])
def marker_for_line(self, line):
"""
Returns the marker that is displayed at the specified line number if
any.
:param line: The marker line.
:return: Marker of None
:rtype: pyqode.core.Marker
"""
markers = []
for marker in self._markers:
if line == marker.position:
markers.append(marker)
return markers
#.........这里部分代码省略.........
示例12: __init__
def __init__(self, parent=None, create_default_actions=True):
"""
:param parent: Parent widget
:param create_default_actions: True to create the action for the
standard shortcuts (copy, paste, delete, undo, redo,...).
Non-standard actions will always get created. If you would like
to prevent the context menu from showing, just set the
:attr:`show_menu_enabled` to False.
"""
super(CodeEdit, self).__init__(parent)
self.installEventFilter(self)
self.clones = []
self._show_ctx_mnu = True
self._default_font_size = 10
self._backend = BackendManager(self)
self._file = FileManager(self)
self._modes = ModesManager(self)
self._panels = PanelsManager(self)
self._decorations = TextDecorationsManager(self)
self.document().modificationChanged.connect(self._emit_dirty_changed)
self._word_separators = [
"~",
"!",
"@",
"#",
"$",
"%",
"^",
"&",
"*",
"(",
")",
"+",
"{",
"}",
"|",
":",
'"',
"'",
"<",
">",
"?",
",",
".",
"/",
";",
"[",
"]",
"\\",
"\n",
"\t",
"=",
"-",
" ",
]
self._save_on_focus_out = False
self._use_spaces_instead_of_tabs = True
self._whitespaces_foreground = None
self._sel_background = None
self._show_whitespaces = False
self._foreground = None
self._sel_foreground = None
self._tab_length = 4
self._zoom_level = 0
self._font_size = 10
self._background = None
QtGui.QFontDatabase.addApplicationFont(":/fonts/rc/SourceCodePro-Regular.ttf")
QtGui.QFontDatabase.addApplicationFont(":/fonts/rc/SourceCodePro-Bold.ttf")
self._font_family = self._DEFAULT_FONT
self._mimetypes = []
self._select_line_on_copy_empty = True
# Flags/Working variables
self._last_mouse_pos = QtCore.QPoint(0, 0)
self._modified_lines = set()
self._cleaning = False
self._visible_blocks = []
self._tooltips_runner = DelayJobRunner(delay=700)
self._prev_tooltip_block_nbr = -1
self._original_text = ""
self._dirty = False
# setup context menu
self._actions = []
self._menus = []
self._init_actions(create_default_actions)
self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self._show_context_menu)
self._mnu = None # bug with PySide (github #63)
# init settings and styles from global settings/style modules
self._init_settings()
self._init_style()
# connect slots
self.textChanged.connect(self._on_text_changed)
self.blockCountChanged.connect(self.update)
#.........这里部分代码省略.........
示例13: MarkerPanel
class MarkerPanel(Panel):
"""
General purpose marker panel.
This panels takes care of drawing icons at a specific line number.
Use addMarker, removeMarker and clearMarkers to manage the collection of
displayed makers.
You can create a user editable panel (e.g. a breakpoints panel) by using
the following signals:
- :attr:`pyqode.core.panels.MarkerPanel.add_marker_requested`
- :attr:`pyqode.core.panels.MarkerPanel.remove_marker_requested`
"""
#: Signal emitted when the user clicked in a place where there is no
#: marker.
add_marker_requested = QtCore.Signal(int)
#: Signal emitted when the user right clicked on an existing marker.
edit_marker_requested = QtCore.Signal(int)
#: Signal emitted when the user left clicked on an existing marker.
remove_marker_requested = QtCore.Signal(int)
@property
def background(self):
"""
Marker background color in editor. Use None if no text decoration
should be used.
"""
return self._background
@background.setter
def background(self, value):
self._background = value
def __init__(self):
Panel.__init__(self)
self._background = QtGui.QColor('#FFC8C8')
self._markers = []
self._icons = {}
self._previous_line = -1
self.scrollable = True
self._job_runner = DelayJobRunner(delay=100)
self.setMouseTracking(True)
self._to_remove = []
@property
def markers(self):
"""
Gets all markers.
"""
return self._markers
def add_marker(self, marker):
"""
Adds the marker to the panel.
:param marker: Marker to add
:type marker: pyqode.core.modes.Marker
"""
self._markers.append(marker)
doc = self.editor.document()
assert isinstance(doc, QtGui.QTextDocument)
block = doc.findBlockByLineNumber(marker._position)
marker.block = block
d = TextDecoration(block)
d.set_full_width()
if self._background:
d.set_background(QtGui.QBrush(self._background))
marker.decoration = d
self.editor.decorations.append(d)
self.repaint()
def remove_marker(self, marker):
"""
Removes a marker from the panel
:param marker: Marker to remove
:type marker: pyqode.core.Marker
"""
self._markers.remove(marker)
self._to_remove.append(marker)
if hasattr(marker, 'decoration'):
self.editor.decorations.remove(marker.decoration)
self.repaint()
def clear_markers(self):
""" Clears the markers list """
while len(self._markers):
self.remove_marker(self._markers[0])
def marker_for_line(self, line):
"""
Returns the marker that is displayed at the specified line number if
any.
:param line: The marker line.
:return: Marker of None
:rtype: pyqode.core.Marker
#.........这里部分代码省略.........