本文整理汇总了Python中PyQt5.QtWebKit.QWebSettings类的典型用法代码示例。如果您正苦于以下问题:Python QWebSettings类的具体用法?Python QWebSettings怎么用?Python QWebSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWebSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: showDateNoWaitDetails
def showDateNoWaitDetails(self, data):
QWebSettings.clearMemoryCaches()
QWebSettings.clearIconDatabase()
ViewGenerator.generate_css(data, self.app)
ViewGenerator.generate_html(data)
self.reload()
示例2: __init__
def __init__(self):
self.debug = 1
self.app = QApplication([])
self.desktop = QApplication.desktop()
self.web = QWebView()
self.icon = QIcon(ICON)
QWebSettings.setIconDatabasePath(DATA_DIR)
示例3: init
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)
示例4: update_settings
def update_settings(section, option):
"""Update global settings when qwebsettings changed."""
cache_path = standarddir.cache()
if (section, option) == ('general', 'private-browsing'):
if config.get('general', 'private-browsing') or cache_path is None:
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(cache_path)
websettings.update_mappings(MAPPINGS, section, option)
示例5: showData
def showData(self, data):
QWebSettings.clearMemoryCaches()
QWebSettings.clearIconDatabase()
ViewGenerator.generate_document_view(data, self.app)
time.sleep(2)
self.load(QtCore.QUrl('file:///'+os.getcwd()+"/generated_html/document_view.html"))
示例6: __init__
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)
示例7: showDataNoGeneration
def showDataNoGeneration(self, data):
QWebSettings.clearMemoryCaches()
QWebSettings.clearIconDatabase()
ViewGenerator.generate_css(data, self.app)
ViewGenerator.generate_html(data)
time.sleep(2)
self.load(QtCore.QUrl('file:///'+os.getcwd()+"/generated_html/index.html"))
示例8: initUI
def initUI(self):
self.setMinimumSize(300, 300)
# self.TextEdit = QtWidgets.QTextEdit(self)
# self.TextEdit.setMinimumSize(300, 300)
# self.TextEdit.setReadOnly(True)
# self.load(QtCore.QUrl('file:///'+os.getcwd()+"/generated_html/index.html"))
QWebSettings.setMaximumPagesInCache(0)
QWebSettings.setObjectCacheCapacities(0, 0, 0)
示例9: __init__
def __init__(self):
self.debug=1
self.app = QApplication(sys.argv)
self.desktop= QApplication.desktop()
self.web = QWebView()
self.icon = QIcon(ICON)
QWebSettings.setIconDatabasePath(DATA_DIR)
self.web.setWindowIcon(self.icon)
self.web.titleChanged.connect(self.title_changed)
self.web.iconChanged.connect(self.icon_changed)
self.web.page().windowCloseRequested.connect(self.close_window)
self.web.page().geometryChangeRequested.connect(self.set_geometry)
示例10: update_settings
def update_settings(section, option):
"""Update global settings when qwebsettings changed."""
if (section, option) == ('general', 'private-browsing'):
cache_path = standarddir.cache()
if config.get('general', 'private-browsing') or cache_path is None:
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(cache_path)
elif section == 'ui' and option in ['hide-scrollbar', 'user-stylesheet']:
_set_user_stylesheet()
websettings.update_mappings(MAPPINGS, section, option)
示例11: update_settings
def update_settings(section, option):
"""Update global settings when qwebsettings changed."""
if (section, option) == ('general', 'private-browsing'):
if config.get('general', 'private-browsing'):
QWebSettings.setIconDatabasePath('')
else:
QWebSettings.setIconDatabasePath(standarddir.cache())
else:
try:
mapping = MAPPINGS[section][option]
except KeyError:
return
value = config.get(section, option)
mapping.set(value)
示例12: _shutdown
def _shutdown(self, status):
"""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 favicons so removing tempdir will work
QWebSettings.setIconDatabasePath("")
# 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:
atexit.register(shutil.rmtree, self._args.basedir)
# 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))
示例13: addFeed
def addFeed(self, urlString, title, icon):
"""
Public method to add a feed.
@param urlString URL of the feed (string)
@param title title of the feed (string)
@param icon icon for the feed (QIcon)
@return flag indicating a successful addition of the feed (boolean)
"""
if urlString == "":
return False
if not self.__loaded:
self.__load()
# step 1: check, if feed was already added
for feed in self.__feeds:
if feed[0] == urlString:
return False
# step 2: add the feed
if icon.isNull() or \
icon == QIcon(QWebSettings.webGraphic(
QWebSettings.DefaultFrameIconGraphic)):
icon = UI.PixmapCache.getIcon("rss16.png")
feed = (urlString, title, icon)
self.__feeds.append(feed)
self.__addFeedItem(feed)
self.__save()
return True
示例14: enable_caret_browsing
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)
示例15: follow_selected
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)