本文整理汇总了Python中PyQt5.QtWebKit.QWebSettings.globalSettings方法的典型用法代码示例。如果您正苦于以下问题:Python QWebSettings.globalSettings方法的具体用法?Python QWebSettings.globalSettings怎么用?Python QWebSettings.globalSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWebKit.QWebSettings
的用法示例。
在下文中一共展示了QWebSettings.globalSettings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def init():
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
if config.get('general', 'private-browsing') or cache_path is None:
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(cache_path)
if cache_path is not None:
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cache_path, 'application-cache'))
if data_path is not None:
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(data_path, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(data_path, 'offline-storage'))
for sectname, section in MAPPINGS.items():
for optname, mapping in section.items():
default = mapping.save_default()
log.config.vdebug("Saved default for {} -> {}: {!r}".format(
sectname, optname, default))
value = config.get(sectname, optname)
log.config.vdebug("Setting {} -> {} to {!r}".format(
sectname, optname, value))
mapping.set(value)
objreg.get('config').changed.connect(update_settings)
示例2: __init__
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def __init__(self):
super(WebRender, self).__init__()
vbox = QVBoxLayout(self)
#Web Frame
self.webFrame = QWebView()
QWebSettings.globalSettings().setAttribute(
QWebSettings.DeveloperExtrasEnabled, True)
vbox.addWidget(self.webFrame)
示例3: _shutdown
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def _shutdown(self, status, restart):
"""Second stage of shutdown."""
log.destroy.debug("Stage 2 of shutting down...")
if qApp is None:
# No QApplication exists yet, so quit hard.
sys.exit(status)
# Remove eventfilter
try:
log.destroy.debug("Removing eventfilter...")
qApp.removeEventFilter(objreg.get('event-filter'))
except AttributeError:
pass
# Close all windows
QApplication.closeAllWindows()
# Shut down IPC
try:
objreg.get('ipc-server').shutdown()
except KeyError:
pass
# Save everything
try:
save_manager = objreg.get('save-manager')
except KeyError:
log.destroy.debug("Save manager not initialized yet, so not "
"saving anything.")
else:
for key in save_manager.saveables:
try:
save_manager.save(key, is_exit=True)
except OSError as e:
error.handle_fatal_exc(
e, self._args, "Error while saving!",
pre_text="Error while saving {}".format(key))
# Disable storage so removing tempdir will work
QWebSettings.setIconDatabasePath('')
QWebSettings.setOfflineWebApplicationCachePath('')
QWebSettings.globalSettings().setLocalStoragePath('')
# Re-enable faulthandler to stdout, then remove crash log
log.destroy.debug("Deactivating crash log...")
objreg.get('crash-handler').destroy_crashlogfile()
# Delete temp basedir
if ((self._args.temp_basedir or self._args.temp_basedir_restarted) and
not restart):
atexit.register(shutil.rmtree, self._args.basedir,
ignore_errors=True)
# Delete temp download dir
objreg.get('temporary-downloads').cleanup()
# If we don't kill our custom handler here we might get segfaults
log.destroy.debug("Deactivating message handler...")
qInstallMessageHandler(None)
# Now we can hopefully quit without segfaults
log.destroy.debug("Deferring QApplication::exit...")
objreg.get('signal-handler').deactivate()
# We use a singleshot timer to exit here to minimize the likelihood of
# segfaults.
QTimer.singleShot(0, functools.partial(qApp.exit, status))
示例4: init
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def init(_args):
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
QWebSettings.setIconDatabasePath(standarddir.cache())
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cache_path, 'application-cache'))
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(data_path, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(data_path, 'offline-storage'))
websettings.init_mappings(MAPPINGS)
_set_user_stylesheet()
config.instance.changed.connect(_update_settings)
示例5: enable_caret_browsing
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def enable_caret_browsing(qapp):
"""Fixture to enable caret browsing globally."""
settings = QWebSettings.globalSettings()
old_value = settings.testAttribute(QWebSettings.CaretBrowsingEnabled)
settings.setAttribute(QWebSettings.CaretBrowsingEnabled, True)
yield
settings.setAttribute(QWebSettings.CaretBrowsingEnabled, old_value)
示例6: _check_prerequisites
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def _check_prerequisites(self, win_id):
"""Check if the command is permitted to run currently.
Args:
win_id: The window ID the command is run in.
"""
mode_manager = objreg.get('mode-manager', scope='window',
window=win_id)
curmode = mode_manager.mode
if self._modes is not None and curmode not in self._modes:
mode_names = '/'.join(mode.name for mode in self._modes)
raise cmdexc.PrerequisitesError(
"{}: This command is only allowed in {} mode.".format(
self.name, mode_names))
elif self._not_modes is not None and curmode in self._not_modes:
mode_names = '/'.join(mode.name for mode in self._not_modes)
raise cmdexc.PrerequisitesError(
"{}: This command is not allowed in {} mode.".format(
self.name, mode_names))
if self._needs_js and not QWebSettings.globalSettings().testAttribute(
QWebSettings.JavascriptEnabled):
raise cmdexc.PrerequisitesError(
"{}: This command needs javascript enabled.".format(self.name))
if self.deprecated:
message.warning(win_id, '{} is deprecated - {}'.format(
self.name, self.deprecated))
示例7: follow_selected
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def follow_selected(self, *, tab=False):
if not self.has_selection():
return
if QWebSettings.globalSettings().testAttribute(
QWebSettings.JavascriptEnabled):
if tab:
self._tab.data.override_target = usertypes.ClickTarget.tab
self._tab.run_js_async(
'window.getSelection().anchorNode.parentNode.click()')
else:
selection = self.selection(html=True)
try:
selected_element = xml.etree.ElementTree.fromstring(
'<html>{}</html>'.format(selection)).find('a')
except xml.etree.ElementTree.ParseError:
raise browsertab.WebTabError('Could not parse selected '
'element!')
if selected_element is not None:
try:
url = selected_element.attrib['href']
except KeyError:
raise browsertab.WebTabError('Anchor element without '
'href!')
url = self._tab.url().resolved(QUrl(url))
if tab:
self._tab.new_tab_requested.emit(url)
else:
self._tab.openurl(url)
示例8: __init__
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def __init__(self, url):
QMainWindow.__init__(self)
self.setupUi(self)
# Enable plugins
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
# UI: connect signals to slots
self.pushButton_Back.clicked.connect(self.on_pushButton_Back_clicked)
self.pushButton_Forward.clicked.connect(self.on_pushButton_Forward_clicked)
self.pushButton_Go.clicked.connect(self.on_pushButton_Go_clicked)
self.lineEdit_AddressBar.returnPressed.connect(self.on_pushButton_Go_clicked)
self.webView.titleChanged.connect(self.onTitleChanged)
self.webView.loadFinished.connect(self.onLoadingNewPage)
self.webView.load(url)
示例9: init
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def init():
"""Initialize the global QWebSettings."""
cachedir = standarddir.get(QStandardPaths.CacheLocation)
QWebSettings.setIconDatabasePath(cachedir)
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cachedir, 'application-cache'))
datadir = standarddir.get(QStandardPaths.DataLocation)
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(datadir, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(datadir, 'offline-storage'))
global settings
settings = QWebSettings.globalSettings()
for sectname, section in MAPPINGS.items():
for optname, (typ, arg) in section.items():
value = config.get(sectname, optname)
_set_setting(typ, arg, value)
objreg.get('config').changed.connect(update_settings)
示例10: init
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def init():
"""Initialize the global QWebSettings."""
cache_path = standarddir.cache()
data_path = standarddir.data()
if config.get('general', 'private-browsing') or cache_path is None:
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(cache_path)
if cache_path is not None:
QWebSettings.setOfflineWebApplicationCachePath(
os.path.join(cache_path, 'application-cache'))
if data_path is not None:
QWebSettings.globalSettings().setLocalStoragePath(
os.path.join(data_path, 'local-storage'))
QWebSettings.setOfflineStoragePath(
os.path.join(data_path, 'offline-storage'))
websettings.init_mappings(MAPPINGS)
objreg.get('config').changed.connect(update_settings)
示例11: _click_js
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def _click_js(self, click_target):
settings = QWebSettings.globalSettings()
attribute = QWebSettings.JavascriptCanOpenWindows
could_open_windows = settings.testAttribute(attribute)
settings.setAttribute(attribute, True)
ok = self._elem.evaluateJavaScript('this.click(); true;')
settings.setAttribute(attribute, could_open_windows)
if not ok:
log.webelem.debug("Failed to click via JS, falling back to event")
self._click_fake_event(click_target)
示例12: _update_settings
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def _update_settings(option):
"""Update global settings when qwebsettings changed."""
global_settings.update_setting(option)
settings = QWebSettings.globalSettings()
if option in ['scrollbar.hide', 'content.user_stylesheets']:
_set_user_stylesheet(settings)
elif option == 'content.cookies.accept':
_set_cookie_accept_policy(settings)
elif option == 'content.cache.maximum_pages':
_set_cache_maximum_pages(settings)
示例13: _get_qws
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def _get_qws(self, qws):
"""Get the QWebSettings object to use.
Args:
qws: The QWebSettings instance to use, or None to use the global
instance.
"""
if qws is None:
return QWebSettings.globalSettings()
else:
return qws
示例14: prepare
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def prepare(self, metaData):
"""
Public method to prepare the disk cache file.
@param metaData meta data for a URL (QNetworkCacheMetaData)
@return reference to the IO device (QIODevice)
"""
if QWebSettings.globalSettings().testAttribute(
QWebSettings.PrivateBrowsingEnabled):
return None
return QNetworkDiskCache.prepare(self, metaData)
示例15: __init__
# 需要导入模块: from PyQt5.QtWebKit import QWebSettings [as 别名]
# 或者: from PyQt5.QtWebKit.QWebSettings import globalSettings [as 别名]
def __init__(self):
# Explaining super is out of the scope of this article
# So please google it if you're not familar with it
# Simple reason why we use it here is that it allows us to
# access variables, methods etc in the design.py file
super(self.__class__, self).__init__()
self.setupUi(self) # This is defined in ui file automatically
self.fillPassword()
self.conn = sqlite3.connect("nooto.db")
self.conn.row_factory = sqlite3.Row
self.curs = self.conn.cursor()
self.curs.execute("SELECT id,title,parent FROM Note")
titles = self.curs.fetchall()
self.id2objmap = {}
# sort by parent value
titles = sorted(titles, key=lambda parent: parent["parent"])
for row in titles:
if row["parent"] == None:
title = self.decrypt(row["title"])
item = QTreeWidgetItem(self.treeWidget)
item.setText(0, title)
item.setText(1, str(row["id"]))
self.id2objmap[row["id"]] = {"title": title, "parent": None, "object": item}
else:
title = self.decrypt(row["title"])
parent = row["parent"]
item = QTreeWidgetItem(self.id2objmap[parent]["object"])
item.setText(0, title)
item.setText(1, str(row["id"]))
item.setText(2, str(parent))
self.id2objmap[row["id"]] = {"title": title, "parent": parent, "object": item}
self.treeWidget.setContextMenuPolicy(Qt.CustomContextMenu)
self.treeWidget.customContextMenuRequested.connect(self.openContextMenu)
self.treeWidget.setHeaderLabel("Note Title")
self.treeWidget.setColumnCount(1)
self.treeWidget.expandAll()
settings = QWebSettings.globalSettings()
settings.setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
settings.setAttribute(QWebSettings.PluginsEnabled, True)
url = QUrl("file://" + os.getcwd() + "/index.html")
# url = QUrl('http://www.tinymce.com/tryit/full.php')
self.webView.setUrl(url)
# self.webView.page().setContentEditable(True)
self.webView.page().mainFrame().addToJavaScriptWindowObject("pyObj", self)
self.treeWidget.itemClicked.connect(self.getTreeItemText)