当前位置: 首页>>代码示例>>Python>>正文


Python api.DelayJobRunner类代码示例

本文整理汇总了Python中pyqode.core.api.DelayJobRunner的典型用法代码示例。如果您正苦于以下问题:Python DelayJobRunner类的具体用法?Python DelayJobRunner怎么用?Python DelayJobRunner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DelayJobRunner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: HtmlPreviewWidget

class HtmlPreviewWidget(QtWebWidgets.QWebView):
    hide_requested = QtCore.Signal()
    show_requested = QtCore.Signal()

    def __init__(self, parent=None):
        super(HtmlPreviewWidget, self).__init__(parent)
        self._editor = None
        self._timer = DelayJobRunner(delay=1000)
        try:
            # prevent opening internal links when using QtWebKit
            self.page().setLinkDelegationPolicy(
                QtWebWidgets.QWebPage.DelegateAllLinks)
        except (TypeError, AttributeError):
            # no needed with QtWebEngine, internal links are properly handled
            # by the default implementation
            pass

    def set_editor(self, editor):
        url = QtCore.QUrl('')
        if editor is not None:
            url = QtCore.QUrl.fromLocalFile(editor.file.path)
        try:
            self.setHtml(editor.to_html(), url)
        except (TypeError, AttributeError):
            self.setHtml('<center>No preview available...</center>', url)
            self._editor = None
            self.hide_requested.emit()
        else:
            if self._editor is not None and editor != self._editor:
                try:
                    self._editor.textChanged.disconnect(self._on_text_changed)
                except TypeError:
                    pass
            editor.textChanged.connect(self._on_text_changed)
            self._editor = proxy(editor)
            self.show_requested.emit()

    def _on_text_changed(self, *_):
        self._timer.request_job(self._update_preview)

    def _update_preview(self):
        url = QtCore.QUrl('')
        if self._editor is not None:
            url = QtCore.QUrl.fromLocalFile(self._editor.file.path)
        try:
            try:
                pos = self.page().mainFrame().scrollBarValue(QtCore.Qt.Vertical)
                self.setHtml(self._editor.to_html(), url)
                self.page().mainFrame().setScrollBarValue(QtCore.Qt.Vertical, pos)
            except AttributeError:
                # Not possible with QtWebEngine???
                # self._scroll_pos = self.page().mainFrame().scrollBarValue(
                    # QtCore.Qt.Vertical)
                self.setHtml(self._editor.to_html(), url)
        except (TypeError, AttributeError):
            self.setHtml('<center>No preview available...</center>', url)
            self.hide_requested.emit()
开发者ID:must40,项目名称:pyqode.core,代码行数:57,代码来源:preview.py

示例2: HtmlPreviewWidget

class HtmlPreviewWidget(QtWidgets.QTextEdit):
    """
    Display html preview of a document as rich text in a QTextEdit.
    """
    hide_requested = QtCore.Signal()
    show_requested = QtCore.Signal()

    def __init__(self, parent=None):
        super(HtmlPreviewWidget, self).__init__(parent)
        self._editor = None
        self._timer = DelayJobRunner(delay=1000)

    def set_editor(self, editor):
        try:
            self.setHtml(editor.to_html())
        except (TypeError, AttributeError):
            self.setHtml('<center>No preview available...</center>')
            self._editor = None
            self.hide_requested.emit()
        else:
            if self._editor is not None and editor != self._editor:
                try:
                    self._editor.textChanged.disconnect(self._on_text_changed)
                except TypeError:
                    pass
            editor.textChanged.connect(self._on_text_changed)
            self._editor = proxy(editor)
            self.show_requested.emit()

    def _on_text_changed(self, *_):
        self._timer.request_job(self._update_preview)

    def _update_preview(self):
        try:
            # remember cursor/scrollbar position
            p = self.textCursor().position()
            v = self.verticalScrollBar().value()

            # display new html
            self.setHtml(self._editor.to_html())

            # restore cursor/scrollbar position
            c = self.textCursor()
            c.setPosition(p)
            self.setTextCursor(c)
            self.verticalScrollBar().setValue(v)
        except (TypeError, AttributeError):
            self.setHtml('<center>No preview available...</center>')
            self.hide_requested.emit()
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:49,代码来源:preview.py

示例3: __init__

 def __init__(self, highlight_caret_scope=False):
     Panel.__init__(self)
     self._native = True
     self._custom_indicators = (
         ':/pyqode-icons/rc/arrow_right_off.png',
         ':/pyqode-icons/rc/arrow_right_on.png',
         ':/pyqode-icons/rc/arrow_down_off.png',
         ':/pyqode-icons/rc/arrow_down_on.png'
     )
     self._custom_color = QtGui.QColor('gray')
     self._block_nbr = -1
     self._highlight_caret = False
     self.highlight_caret_scope = highlight_caret_scope
     self._indic_size = 16
     #: the list of deco used to highlight the current fold region (
     #: surrounding regions are darker)
     self._scope_decos = []
     #: the list of folded blocs decorations
     self._block_decos = []
     self.setMouseTracking(True)
     self.scrollable = True
     self._mouse_over_line = None
     self._current_scope = None
     self._prev_cursor = None
     self.context_menu = None
     self.action_collapse = None
     self.action_expand = None
     self.action_collapse_all = None
     self.action_expand_all = None
     self._original_background = None
     self._highlight_runner = DelayJobRunner(delay=250)
开发者ID:sopak,项目名称:cadquery-freecad-module,代码行数:31,代码来源:folding.py

示例4: __init__

 def __init__(self):
     QObject.__init__(self)
     Mode.__init__(self)
     self._root_node = None
     self._vars = []
     self._paragraphs = []
     self._runner = DelayJobRunner()
开发者ID:dtonal,项目名称:pyqode.cobol,代码行数:7,代码来源:doc_outline.py

示例5: __init__

 def __init__(self, delay=1000):
     Mode.__init__(self)
     QtCore.QObject.__init__(self)
     self._jobRunner = DelayJobRunner(delay=delay)
     #: The list of results (elements might have children; this is actually
     #: a tree).
     self.results = []
开发者ID:AlexLee,项目名称:cadquery-freecad-module,代码行数:7,代码来源:document_analyser.py

示例6: __init__

 def __init__(self):
     QtCore.QObject.__init__(self)
     Mode.__init__(self)
     self._previous_cursor_start = -1
     self._previous_cursor_end = -1
     self._deco = None
     self._cursor = None
     self._timer = DelayJobRunner(delay=200)
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:8,代码来源:wordclick.py

示例7: __init__

 def __init__(self, worker, delay=1000):
     Mode.__init__(self)
     QtCore.QObject.__init__(self)
     self._worker = worker
     self._jobRunner = DelayJobRunner(delay=delay)
     #: The list of definitions found in the file, each item is a
     #: pyqode.core.share.Definition.
     self._results = []
开发者ID:abdullahtahiriyo,项目名称:cadquery-freecad-module,代码行数:8,代码来源:outline.py

示例8: __init__

 def __init__(self):
     super(OccurrencesHighlighterMode, self).__init__()
     self._decorations = []
     #: Timer used to run the search request with a specific delay
     self.timer = DelayJobRunner(delay=1000)
     self._sub = None
     self._background = QtGui.QColor('#CCFFCC')
     self._foreground = None
     self._underlined = False
开发者ID:SirmoGames,项目名称:hackedit,代码行数:9,代码来源:occurences.py

示例9: __init__

 def __init__(self):
     super(GoToAssignmentsMode, self).__init__()
     self._definitions = []
     self._goto_requested = False
     self.action_goto = QtWidgets.QAction("Go to assignments", self)
     self.action_goto.setShortcut(self.shortcut)
     self.action_goto.triggered.connect(self.request_goto)
     self.word_clicked.connect(self._on_word_clicked)
     self._runner = DelayJobRunner(delay=1)
开发者ID:AlexLee,项目名称:cadquery-freecad-module,代码行数:9,代码来源:goto_assignements.py

示例10: __init__

 def __init__(self, parent=None):
     super(HtmlPreviewWidget, self).__init__(parent)
     self._editor = None
     self._timer = DelayJobRunner(delay=1000)
     try:
         # prevent opening internal links when using QtWebKit
         self.page().setLinkDelegationPolicy(
             QtWebWidgets.QWebPage.DelegateAllLinks)
     except (TypeError, AttributeError):
         # no needed with QtWebEngine, internal links are properly handled
         # by the default implementation
         pass
开发者ID:must40,项目名称:pyqode.core,代码行数:12,代码来源:preview.py

示例11: __init__

 def __init__(self):
     super(GoToAssignmentsMode, self).__init__()
     self._definitions = []
     self._goto_requested = False
     self.action_goto = QtWidgets.QAction(_("Go to assignments"), self)
     self.action_goto.setShortcut(self.shortcut)
     self.action_goto.triggered.connect(self.request_goto)
     icon = icons.icon(qta_name='fa.share')
     if icon:
         self.action_goto.setIcon(icon)
     self.word_clicked.connect(self._on_word_clicked)
     self._runner = DelayJobRunner(delay=1)
开发者ID:SirmoGames,项目名称:hackedit,代码行数:12,代码来源:goto_assignements.py

示例12: TabBar

class TabBar(QtWidgets.QTabBar):
    """
    Tab bar specialized to allow the user to close a tab using mouse middle
    click. Also exposes a double clicked signal.
    """
    double_clicked = QtCore.Signal()

    def __init__(self, parent):
        QtWidgets.QTabBar.__init__(self, parent)
        self.setTabsClosable(True)
        self._timer = DelayJobRunner(delay=1)

    def mousePressEvent(self, event):
        QtWidgets.QTabBar.mousePressEvent(self, event)
        if event.button() == QtCore.Qt.MiddleButton:
            tab = self.tabAt(event.pos())
            self._timer.request_job(
                self.parentWidget().tabCloseRequested.emit, tab)

    def mouseDoubleClickEvent(self, event):
        if event.button() == QtCore.Qt.LeftButton:
            self.double_clicked.emit()
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:22,代码来源:tab_bar.py

示例13: __init__

 def __init__(self):
     QObject.__init__(self)
     Mode.__init__(self)
     self._previous_cursor_start = -1
     self._previous_cursor_end = -1
     self._definition = None
     self._deco = None
     self._pending = False
     self.action_goto = QAction(_("Go to assignments"), self)
     self.action_goto.setShortcut('F7')
     self.action_goto.triggered.connect(self.request_goto)
     self.word_clicked.connect(self.request_goto)
     self._timer = DelayJobRunner(delay=200)
开发者ID:brunoviu,项目名称:OpenCobolIDE,代码行数:13,代码来源:goto.py

示例14: __init__

 def __init__(self):
     super(CheckerPanel, self).__init__()
     self._previous_line = -1
     self.scrollable = True
     self._job_runner = DelayJobRunner(delay=100)
     self.setMouseTracking(True)
     #: Info icon
     self.info_icon = QtGui.QIcon.fromTheme(
         'dialog-info', QtGui.QIcon(':pyqode-icons/rc/dialog-info.png'))
     #: Warning icon
     self.warning_icon = QtGui.QIcon.fromTheme(
         'dialog-warning',
         QtGui.QIcon(':pyqode-icons/rc/dialog-warning.png'))
     #: Error icon
     self.error_icon = QtGui.QIcon.fromTheme(
         'dialog-error', QtGui.QIcon(':pyqode-icons/rc/dialog-error.png'))
开发者ID:AlexLee,项目名称:cadquery-freecad-module,代码行数:16,代码来源:checker.py

示例15: __init__

 def __init__(self):
     super(CheckerPanel, self).__init__()
     self._previous_line = -1
     self.scrollable = True
     self._job_runner = DelayJobRunner(delay=100)
     self.setMouseTracking(True)
     #: Info icon
     self.info_icon = icons.icon(
         'dialog-info', ':pyqode-icons/rc/dialog-info.png',
         'fa.info-circle', qta_options={'color': '#4040DD'})
     self.warning_icon = icons.icon(
         'dialog-warning', ':pyqode-icons/rc/dialog-warning.png',
         'fa.exclamation-triangle', qta_options={'color': '#DDDD40'})
     self.error_icon = icons.icon(
         'dialog-error', ':pyqode-icons/rc/dialog-error.png',
         'fa.exclamation-circle', qta_options={'color': '#DD4040'})
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:16,代码来源:checker.py


注:本文中的pyqode.core.api.DelayJobRunner类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。