本文整理汇总了Python中qutebrowser.utils.usertypes.enum函数的典型用法代码示例。如果您正苦于以下问题:Python enum函数的具体用法?Python enum怎么用?Python enum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enum函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: enum
def enum():
return usertypes.enum('Enum', ['one', 'two'])
开发者ID:Link-Satonaka,项目名称:qutebrowser,代码行数:2,代码来源:test_enum.py
示例2: WebView
import itertools
import functools
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QTimer, QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebKit import QWebSettings
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
from qutebrowser.config import config
from qutebrowser.keyinput import modeman
from qutebrowser.utils import message, log, usertypes, utils, qtutils, objreg
from qutebrowser.browser import webpage, hints, webelem
from qutebrowser.commands import cmdexc
LoadStatus = usertypes.enum('LoadStatus', ['none', 'success', 'error', 'warn',
'loading'])
tab_id_gen = itertools.count(0)
class WebView(QWebView):
"""One browser tab in TabbedBrowser.
Our own subclass of a QWebView with some added bells and whistles.
Attributes:
hintmanager: The HintManager instance for this view.
progress: loading progress of this page.
scroll_pos: The current scroll position as (x%, y%) tuple.
开发者ID:larryhynes,项目名称:qutebrowser,代码行数:32,代码来源:webview.py
示例3:
SELECTORS: CSS selectors for different groups of elements.
FILTERS: A dictionary of filter functions for the modes.
The filter for "links" filters javascript:-links and a-tags
without "href".
"""
import collections.abc
from PyQt5.QtCore import QUrl, Qt, QEvent, QTimer
from PyQt5.QtGui import QMouseEvent
from qutebrowser.config import config
from qutebrowser.utils import log, usertypes, utils, qtutils
Group = usertypes.enum('Group', ['all', 'links', 'images', 'url', 'prevnext',
'inputs'])
SELECTORS = {
Group.all: ('a, area, textarea, select, input:not([type=hidden]), button, '
'frame, iframe, link, [onclick], [onmousedown], [role=link], '
'[role=option], [role=button], img'),
Group.links: 'a, area, link, [role=link]',
Group.images: 'img',
Group.url: '[src], [href]',
Group.prevnext: 'a, area, button, link, [role=button]',
Group.inputs: ('input[type=text], input[type=email], input[type=url], '
'input[type=tel], input[type=number], '
'input[type=password], input[type=search], '
'input:not([type]), textarea'),
}
开发者ID:julianuu,项目名称:qutebrowser,代码行数:32,代码来源:webelem.py
示例4: import
"""The tab widget used for TabbedBrowser from browser.py."""
import collections
import functools
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QSize, QRect, QTimer
from PyQt5.QtWidgets import (QTabWidget, QTabBar, QSizePolicy, QCommonStyle,
QStyle, QStylePainter, QStyleOptionTab)
from PyQt5.QtGui import QIcon, QPalette, QColor
from qutebrowser.utils import qtutils, objreg, utils, usertypes
from qutebrowser.config import config
from qutebrowser.browser import webview
PixelMetrics = usertypes.enum('PixelMetrics', ['icon_padding'],
start=QStyle.PM_CustomBase, is_int=True)
class TabWidget(QTabWidget):
"""The tab widget used for TabbedBrowser.
Signals:
tab_index_changed: Emitted when the current tab was changed.
arg 0: The index of the tab which is now focused.
arg 1: The total count of tabs.
"""
tab_index_changed = pyqtSignal(int, int)
def __init__(self, win_id, parent=None):
开发者ID:ProtractorNinja,项目名称:qutebrowser,代码行数:32,代码来源:tabwidget.py
示例5: on_mode_entered
from PyQt5.QtWebKit import QWebElement
from PyQt5.QtWebKitWidgets import QWebPage
from qutebrowser.config import config
from qutebrowser.keyinput import modeman, modeparsers
from qutebrowser.browser import webelem
from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
from qutebrowser.utils import usertypes, log, qtutils, message, objreg
from qutebrowser.misc import guiprocess
ElemTuple = collections.namedtuple('ElemTuple', ['elem', 'label'])
Target = usertypes.enum('Target', ['normal', 'tab', 'tab_fg', 'tab_bg',
'window', 'yank', 'yank_primary', 'run',
'fill', 'hover', 'download', 'userscript',
'spawn'])
@pyqtSlot(usertypes.KeyMode)
def on_mode_entered(mode, win_id):
"""Stop hinting when insert mode was entered."""
if mode == usertypes.KeyMode.insert:
modeman.maybe_leave(win_id, usertypes.KeyMode.hint, 'insert mode')
class HintContext:
"""Context namespace used for hinting.
Attributes:
开发者ID:xManusx,项目名称:qutebrowser,代码行数:32,代码来源:hints.py
示例6: __init__
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""Tests for qutebrowser.commands.argparser."""
import inspect
import pytest
from PyQt5.QtCore import QUrl
from qutebrowser.commands import argparser, cmdexc
from qutebrowser.utils import usertypes, objreg
Enum = usertypes.enum('Enum', ['foo', 'foo_bar'])
class FakeTabbedBrowser:
def __init__(self):
self.opened_url = None
def tabopen(self, url):
self.opened_url = url
class TestArgumentParser:
@pytest.fixture
def parser(self):
开发者ID:DoITCreative,项目名称:qutebrowser,代码行数:31,代码来源:test_argparser.py
示例7: test_start
def test_start(self):
"""Test the start= argument."""
e = usertypes.enum('Enum', ['three', 'four'], start=3)
self.assertEqual(e.three.value, 3)
self.assertEqual(e.four.value, 4)
开发者ID:HalosGhost,项目名称:qutebrowser,代码行数:5,代码来源:test_enum.py
示例8: import
import collections
from PyQt5.QtCore import (pyqtSignal, pyqtSlot, pyqtProperty, Qt, QTime, QSize,
QTimer)
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QStackedLayout, QSizePolicy
from qutebrowser.config import config, style
from qutebrowser.utils import usertypes, log, objreg, utils
from qutebrowser.mainwindow.statusbar import (command, progress, keystring,
percentage, url, prompt,
tabindex)
from qutebrowser.mainwindow.statusbar import text as textwidget
PreviousWidget = usertypes.enum('PreviousWidget', ['none', 'prompt',
'command'])
Severity = usertypes.enum('Severity', ['normal', 'warning', 'error'])
CaretMode = usertypes.enum('CaretMode', ['off', 'on', 'selection'])
class StatusBar(QWidget):
"""The statusbar at the bottom of the mainwindow.
Attributes:
txt: The Text widget in the statusbar.
keystring: The KeyString widget in the statusbar.
percentage: The Percentage widget in the statusbar.
url: The UrlText widget in the statusbar.
prog: The Progress widget in the statusbar.
cmd: The Command widget in the statusbar.
开发者ID:Konubinix,项目名称:qutebrowser,代码行数:31,代码来源:bar.py
示例9: distribution
from qutebrowser.browser import pdfjs
@attr.s
class DistributionInfo:
"""Information about the running distribution."""
id = attr.ib()
parsed = attr.ib()
version = attr.ib()
pretty = attr.ib()
Distribution = usertypes.enum(
'Distribution', ['unknown', 'ubuntu', 'debian', 'void', 'arch',
'gentoo', 'fedora', 'opensuse', 'linuxmint', 'manjaro'])
def distribution():
"""Get some information about the running Linux distribution.
Returns:
A DistributionInfo object, or None if no info could be determined.
parsed: A Distribution enum member
version: A Version object, or None
pretty: Always a string (might be "Unknown")
"""
filename = os.environ.get('QUTE_FAKE_OS_RELEASE', '/etc/os-release')
info = {}
try:
开发者ID:nanjekyejoannah,项目名称:qutebrowser,代码行数:31,代码来源:version.py
示例10: on_mode_entered
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QEvent, Qt, QUrl
from PyQt5.QtGui import QMouseEvent, QClipboard
from PyQt5.QtWidgets import QApplication
from qutebrowser.config import config
from qutebrowser.keyinput import modeman
from qutebrowser.browser import webelem
from qutebrowser.commands import userscripts, cmdexc, cmdutils
from qutebrowser.utils import usertypes, log, qtutils, message, objreg
ElemTuple = collections.namedtuple('ElemTuple', ['elem', 'label'])
Target = usertypes.enum('Target', ['normal', 'tab', 'tab_bg', 'yank',
'yank_primary', 'fill', 'rapid', 'download',
'userscript', 'spawn'])
@pyqtSlot(usertypes.KeyMode)
def on_mode_entered(mode):
"""Stop hinting when insert mode was entered."""
if mode == usertypes.KeyMode.insert:
modeman.maybe_leave(usertypes.KeyMode.hint, 'insert mode')
class HintContext:
"""Context namespace used for hinting.
Attributes:
开发者ID:har5ha,项目名称:qutebrowser,代码行数:31,代码来源:hints.py
示例11: StatusBar
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""The main statusbar widget."""
import collections
from PyQt5.QtCore import pyqtSignal, pyqtSlot, pyqtProperty, Qt, QTime, QSize, QTimer
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QStackedLayout, QSizePolicy
from qutebrowser.config import config, style
from qutebrowser.utils import usertypes, log, objreg, utils
from qutebrowser.mainwindow.statusbar import command, progress, keystring, percentage, url, prompt, tabindex
from qutebrowser.mainwindow.statusbar import text as textwidget
PreviousWidget = usertypes.enum("PreviousWidget", ["none", "prompt", "command"])
Severity = usertypes.enum("Severity", ["normal", "warning", "error"])
CaretMode = usertypes.enum("CaretMode", ["off", "on", "selection"])
class StatusBar(QWidget):
"""The statusbar at the bottom of the mainwindow.
Attributes:
txt: The Text widget in the statusbar.
keystring: The KeyString widget in the statusbar.
percentage: The Percentage widget in the statusbar.
url: The UrlText widget in the statusbar.
prog: The Progress widget in the statusbar.
cmd: The Command widget in the statusbar.
开发者ID:shioyama,项目名称:qutebrowser,代码行数:31,代码来源:bar.py
示例12: EmptyValueError
import sys
import shutil
import os.path
import contextlib
from PyQt5.QtCore import QStandardPaths
from PyQt5.QtWidgets import QApplication
from qutebrowser.utils import log, debug, usertypes, message
# The cached locations
_locations = {}
Location = usertypes.enum('Location', ['config', 'auto_config',
'data', 'system_data',
'cache', 'download', 'runtime'])
APPNAME = 'qutebrowser'
class EmptyValueError(Exception):
"""Error raised when QStandardPaths returns an empty value."""
@contextlib.contextmanager
def _unset_organization():
"""Temporarily unset QApplication.organizationName().
开发者ID:swalladge,项目名称:qutebrowser,代码行数:30,代码来源:standarddir.py
示例13: test_unique
def test_unique():
"""Make sure elements need to be unique."""
with pytest.raises(TypeError):
usertypes.enum('Enum', ['item', 'item'])
开发者ID:Link-Satonaka,项目名称:qutebrowser,代码行数:4,代码来源:test_enum.py
示例14: test_start
def test_start():
"""Test the start= argument."""
e = usertypes.enum('Enum', ['three', 'four'], start=3)
assert e.three.value == 3
assert e.four.value == 4
开发者ID:Link-Satonaka,项目名称:qutebrowser,代码行数:5,代码来源:test_enum.py
示例15:
"""pytest helper to monkeypatch the message module."""
import logging
import collections
import pytest
from qutebrowser.utils import usertypes
Message = collections.namedtuple('Message', ['level', 'win_id', 'text',
'immediate'])
Level = usertypes.enum('Level', ('error', 'info', 'warning'))
class MessageMock:
"""Helper object for message_mock.
Attributes:
_monkeypatch: The pytest monkeypatch fixture.
Message: A namedtuple representing a message.
messages: A list of Message tuples.
caplog: The pytest-capturelog fixture.
Level: The Level type for easier usage as a fixture.
"""
Level = Level
开发者ID:DoITCreative,项目名称:qutebrowser,代码行数:30,代码来源:messagemock.py
示例16: UrlText
#
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""URL displayed in the statusbar."""
from PyQt5.QtCore import pyqtSlot, pyqtProperty, Qt
from qutebrowser.browser import webview
from qutebrowser.mainwindow.statusbar import textbase
from qutebrowser.config import style
from qutebrowser.utils import usertypes
# Note this has entries for success/error/warn from widgets.webview:LoadStatus
UrlType = usertypes.enum('UrlType', ['success', 'error', 'warn', 'hover',
'normal'])
class UrlText(textbase.TextBase):
"""URL displayed in the statusbar.
Attributes:
_normal_url: The normal URL to be displayed as a UrlType instance.
_normal_url_type: The type of the normal URL as a UrlType instance.
_hover_url: The URL we're currently hovering over.
_ssl_errors: Whether SSL errors occured while loading.
Class attributes:
_urltype: The URL type to show currently (normal/ok/error/warn/hover).
Accessed via the urltype property.
开发者ID:larryhynes,项目名称:qutebrowser,代码行数:32,代码来源:url.py
示例17: BaseCompletionModel
# You should have received a copy of the GNU General Public License
# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>.
"""The base completion model for completion in the command line.
Module attributes:
Role: An enum of user defined model roles.
"""
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QStandardItemModel, QStandardItem
from qutebrowser.utils import usertypes, qtutils
Role = usertypes.enum('Role', ['marks', 'sort'], start=Qt.UserRole,
is_int=True)
class BaseCompletionModel(QStandardItemModel):
"""A simple QStandardItemModel adopted for completions.
Used for showing completions later in the CompletionView. Supports setting
marks and adding new categories/items easily.
"""
def __init__(self, parent=None):
super().__init__(parent)
self.setColumnCount(3)
def _get_marks(self, needle, haystack):
开发者ID:har5ha,项目名称:qutebrowser,代码行数:32,代码来源:basecompletion.py
示例18: setUp
def setUp(self):
self.enum = usertypes.enum('Enum', ['one', 'two'])
开发者ID:HalosGhost,项目名称:qutebrowser,代码行数:2,代码来源:test_enum.py
示例19: WebTabError
class WebTabError(Exception):
"""Base class for various errors."""
class UnsupportedOperationError(WebTabError):
"""Raised when an operation is not supported with the given backend."""
TerminationStatus = usertypes.enum('TerminationStatus', [
'normal',
'abnormal', # non-zero exit status
'crashed', # e.g. segfault
'killed',
'unknown',
])
@attr.s
class TabData:
"""A simple namespace with a fixed set of attributes.
Attributes:
keep_icon: Whether the (e.g. cloned) icon should not be cleared on page
load.
inspector: The QWebInspector used for this webview.
viewing_source: Set if we're currently showing a source view.
开发者ID:swalladge,项目名称:qutebrowser,代码行数:29,代码来源:browsertab.py
示例20:
FILTERS: A dictionary of filter functions for the modes.
The filter for "links" filters javascript:-links and a-tags
without "href".
"""
import collections.abc
import functools
from PyQt5.QtCore import QRect, QUrl
from PyQt5.QtWebKit import QWebElement
from qutebrowser.config import config
from qutebrowser.utils import log, usertypes, utils
Group = usertypes.enum("Group", ["all", "links", "images", "url", "prevnext", "focus"])
SELECTORS = {
Group.all: (
"a, area, textarea, select, input:not([type=hidden]), button, "
"frame, iframe, link, [onclick], [onmousedown], [role=link], "
"[role=option], [role=button], img"
),
Group.links: "a, area, link, [role=link]",
Group.images: "img",
Group.url: "[src], [href]",
Group.prevnext: "a, area, button, link, [role=button]",
Group.focus: "*:focus",
}
开发者ID:axs221,项目名称:qutebrowser,代码行数:30,代码来源:webelem.py
注:本文中的qutebrowser.utils.usertypes.enum函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论