本文整理汇总了Python中PyQt4.QtWebKit.QWebSettings类的典型用法代码示例。如果您正苦于以下问题:Python QWebSettings类的具体用法?Python QWebSettings怎么用?Python QWebSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWebSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(
self,
log,
confirm_callback=None,
prompt_callback=None,
user_agent=USER_AGENT,
enable_developer_tools=False,
parent=None,
):
QWebPage.__init__(self, parent)
self.log = log
self.user_agent = user_agent if user_agent else USER_AGENT
self.confirm_callback = confirm_callback
self.prompt_callback = prompt_callback
self.setForwardUnsupportedContent(True)
self.unsupportedContent.connect(self.on_unsupported_content)
settings = self.settings()
if enable_developer_tools:
settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
QWebSettings.enablePersistentStorage(os.path.join(cache_dir(), "webkit-persistence"))
QWebSettings.setMaximumPagesInCache(0)
self.bridge_name = "b" + uuid.uuid4().get_hex()
self.mainFrame().javaScriptWindowObjectCleared.connect(self.add_window_objects)
self.dom_loaded = False
示例2: __init__
def __init__(self, URL, process=None, main=None):
QWidget.__init__(self)
BaseCentralWidget.__init__(self)
self.path = URL
self.process = process
v_box = QVBoxLayout(self)
#Web Frame
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
self.webFrame = QWebView()
self.webFrame.setAcceptDrops(False)
factory = WebPluginFactory(self, main)
self.webFrame.page().setPluginFactory(factory)
self.webFrame.load(QUrl(URL))
v_box.addWidget(self.webFrame)
if process is not None:
time.sleep(0.5)
self.webFrame.reload()
if self.path.endswith('startPage.html') and sys.platform.find('win') != -1:
content = manage_files.read_file_content(self.path)
pathCss = os.path.join(resources.PRJ_PATH, 'doc', 'styles', 'ninja.css')
pathJs = os.path.join(resources.PRJ_PATH, 'doc', 'rsc')
content = content.replace('styles/ninja.css', pathCss).replace('src="rsc', 'src="' + pathJs)
self.webFrame.setHtml(content)
示例3: __init__
def __init__(self):
QWidget.__init__(self)
vbox = QVBoxLayout(self)
# Web Frame
self.webFrame = QWebView()
QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
vbox.addWidget(self.webFrame)
示例4: __init__
def __init__(self, view: Amendment('view/', lambda v: hasattr(v, 'mode') and (v.mode.name == 'web') and (v.widget is None))): #, orig_editor=None):
self.view = view
QWebView.__init__(self)
view.widget = self
self.load(QUrl(view.filebuf.file_name))
self.page().setContentEditable(True)
QNetworkProxyFactory.setUseSystemConfiguration(True);
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True);
QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, True);
示例5: main
def main():
app = QtGui.QApplication(sys.argv)
QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True);
myObj = QtJsBridge()
webView = QtWebKit.QWebView()
# Make myObj exposed as JavaScript object named 'pyObj'
webView.page().mainFrame().addToJavaScriptWindowObject("pyObj", myObj)
myObj.mainframe=webView.page().mainFrame()
webView.setHtml(html)
window = QtGui.QMainWindow()
window.setCentralWidget(webView)
window.show()
cf = json.load(open('config.json'))
client = xmpp.Client(cf['login2'])
client.connect(server=(cf['server'],int(cf['port'])))
client.auth(cf['username'], cf['passwd'], 'botty')
client.RegisterHandler('message', myObj.gotmsg)
#client.RegisterHandler('chat', self.gotmsg)
client.sendInitPresence()
#need to call this later on too.
roster = client.getRoster()
myObj.rkeys = [str(r) for r in roster.keys()]
#give js obj access to send. could wrap in another method if paranoid :P
myObj.send = client.send
myObj.mainframe.evaluateJavaScript("getRoster();")
#this get messages section could be improved, or replaced!
global cancheckmsgs
cancheckmsgs = True
def checkmsgs():
global cancheckmsgs
if not cancheckmsgs: return
cancheckmsgs = False
socketlist = {client.Connection._sock:'xmpp',sys.stdin:'stdio'}
(i , o, e) = select.select(socketlist.keys(),[],[],.01)
for each in i:
print each
if socketlist[each] == 'xmpp':
client.Process(.01)
cancheckmsgs = True
timer = QTimer()
timer.timeout.connect(checkmsgs)
timer.start(100)
sys.exit(app.exec_())
示例6: show_graph
def show_graph(self):
GeosismaWebForm = 'GeosismaSchedaAgibilita.html'
template_path = os.path.dirname(os.path.realpath(__file__))+'/template/'+GeosismaWebForm
# create webview clearing cache
# js-python connector is insude WebView Class
self.dlg = GeosismaOfflineDlg()
#self.web = WebPage()
# load content
QWebSettings.clearMemoryCaches()
self.dlg.ui.webView.load(QUrl(template_path))
self.dlg.show()
示例7: show_help
def show_help(self):
html = resource_string("emzed.core.explorers", "help_peakmapexplorer.html")
QWebSettings.globalSettings().setFontFamily(QWebSettings.StandardFont, 'Courier')
QWebSettings.globalSettings().setFontSize(QWebSettings.DefaultFontSize, 12)
v = QWebView(self)
v.setHtml(html)
dlg = QDialog(self, Qt.Window)
dlg.setMinimumSize(300, 300)
l = QVBoxLayout(dlg)
l.addWidget(v)
dlg.setLayout(l)
dlg.show()
示例8: __init__
def __init__(self, *args, **kwargs):
logging.debug('Starting __init__')
self.url = kwargs['url']
self.ghost = ghost.Ghost(wait_timeout=60)
logging.debug('Created Ghost object')
QWebSettings.globalSettings().setAttribute(QWebSettings.AutoLoadImages, False)
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, False)
self.page, self.resources = self.ghost.open(self.url)
self.frame = self.ghost.main_frame
self.body = self.ghost.main_frame.findFirstElement('body')
logging.debug('Fetched the page')
示例9: webSettings
def webSettings(self):
self.cookiesjar = PersistentCookieJar(self)
self.zoom = self.readZoom()
# Required by Youtube videos (HTML5 video support only on Qt5)
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, self.plugins)
# We don't want Java
QWebSettings.globalSettings().setAttribute(QWebSettings.JavaEnabled, False)
# We don't need History
QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
# Required for copy and paste clipboard integration
QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
# Enabling Inspeclet only when --debug=True (requires more CPU usage)
QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.debug)
示例10: __init__
def __init__(self, parent = None):
QWebView.__init__(self, parent)
self.setMinimumSize(320, 480)
self.settings().setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
self.page().setForwardUnsupportedContent(True)
self.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
QWebSettings.setWebGraphic(QWebSettings.MissingImageGraphic, QPixmap("data/media/missing.png"))
self.siteServer = SiteServer(self)
self.previewTooltip = None
self.connect(self.page(), SIGNAL("linkClicked(const QUrl&)"), self.slotLinkClicked)
self.connect(self.page(), SIGNAL("unsupportedContent(QNetworkReply*)"), self.slotHandleReply)
self.connect(self.page(), SIGNAL("frameCreated(QWebFrame*)"), self.setupFrame)
# NOTE: This simplified mechanism depends on the application NEVER using framesets!
self.connect(self.page().mainFrame(), SIGNAL("javaScriptWindowObjectCleared()"), self.setupFrame)
self.connect(self.page(), SIGNAL("linkHovered(const QString&, const QString&, const QString&)"), self.linkHovered)
示例11: __init__
def __init__(self, url, process=None, parent=None):
QWidget.__init__(self, parent)
itab_item.ITabItem.__init__(self)
self._id = url
self._process = process
vbox = QVBoxLayout(self)
#Web Frame
QWebSettings.globalSettings().setAttribute(
QWebSettings.PluginsEnabled, True)
self.webFrame = QWebView(self)
self.webFrame.setAcceptDrops(False)
factory = WebPluginFactory(self)
self.webFrame.page().setPluginFactory(factory)
self.webFrame.load(QUrl(url))
vbox.addWidget(self.webFrame)
if process is not None:
time.sleep(0.5)
self.webFrame.load(QUrl(url))
if url == resources.START_PAGE_URL:
self.webFrame.page().setLinkDelegationPolicy(
QWebPage.DelegateAllLinks)
self.connect(self.webFrame, SIGNAL("linkClicked(QUrl)"),
self.start_page_operations)
if sys.platform == "win32":
content = file_manager.read_file_content(self.ID)
pathCss = os.path.join(
resources.PRJ_PATH, 'doc', 'css', 'style.css')
pathJs = os.path.join(resources.PRJ_PATH, 'doc', 'js', 'libs')
pathImg = os.path.join(resources.PRJ_PATH, 'doc', 'img')
content = content.replace('css/style.css',
pathCss).replace(
'src="js/libs/', 'src="%s\\' % pathJs).replace(
'src="img/', 'src="%s\\' % pathImg)
self.webFrame.setHtml(content)
self._id = 'Start Page'
policy = Qt.ScrollBarAlwaysOff
else:
policy = Qt.ScrollBarAsNeeded
self.webFrame.page().currentFrame().setScrollBarPolicy(
Qt.Vertical, policy)
self.webFrame.page().currentFrame().setScrollBarPolicy(
Qt.Horizontal, policy)
示例12: __init__
def __init__(self, log,
confirm_callback=None,
prompt_callback=None,
user_agent=USER_AGENT,
enable_developer_tools=False,
parent=None):
QWebPage.__init__(self, parent)
self.log = log
self.user_agent = user_agent if user_agent else USER_AGENT
self.confirm_callback = confirm_callback
self.prompt_callback = prompt_callback
self.setForwardUnsupportedContent(True)
self.unsupportedContent.connect(self.on_unsupported_content)
settings = self.settings()
if enable_developer_tools:
settings.setAttribute(QWebSettings.DeveloperExtrasEnabled, True)
QWebSettings.enablePersistentStorage(os.path.join(cache_dir(),
'webkit-persistence'))
QWebSettings.setMaximumPagesInCache(0)
示例13: __init__
def __init__(self, window):
QWebView.__init__(self)
self.window = window
with open(get_resource_path("scudcloud.js"), "r") as f:
self.js = f.read()
# Required by Youtube videos (HTML5 video support only on Qt5)
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled, True)
# We don't want Java
QWebSettings.globalSettings().setAttribute(QWebSettings.JavaEnabled, False);
# We don't need History
QWebSettings.globalSettings().setAttribute(QWebSettings.PrivateBrowsingEnabled, True);
# Required for copy and paste clipboard integration
QWebSettings.globalSettings().setAttribute(QWebSettings.JavascriptCanAccessClipboard, True)
# Enabling Inspeclet only when --debug=True (requires more CPU usage)
QWebSettings.globalSettings().setAttribute(QWebSettings.DeveloperExtrasEnabled, self.window.debug)
self.setZoomFactor(self.window.zoom)
self.page().setLinkDelegationPolicy(QtWebKit.QWebPage.DelegateAllLinks)
self.connect(self, SIGNAL("urlChanged(const QUrl&)"), self.urlChanged)
self.connect(self, SIGNAL("linkClicked(const QUrl&)"), self.linkClicked)
self.addActions()
示例14: _set_global_render_settings
def _set_global_render_settings(js_disable_cross_domain_access, private_mode):
from PyQt4.QtWebKit import QWebSecurityOrigin, QWebSettings
if js_disable_cross_domain_access is False:
# In order to enable cross domain requests it is necessary to add
# the http and https to the local scheme, this way all the urls are
# seen as inside the same security origin.
for scheme in ['http', 'https']:
QWebSecurityOrigin.addLocalScheme(scheme)
settings = QWebSettings.globalSettings()
settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, private_mode)
settings.setAttribute(QWebSettings.LocalStorageEnabled, not private_mode)
示例15: __init__
def __init__(self):
self.debug=1
self.app = QApplication(sys.argv)
self.desktop= QApplication.desktop()
self.web = QWebView()
self.icon = QIcon(QString(ICON))
QWebSettings.setIconDatabasePath(DATA_DIR)
#self.web.page().setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
QObject.connect(self.web,
SIGNAL("titleChanged ( const QString &)"),
self.title_changed)
QObject.connect(self.web,
SIGNAL("iconChanged ()"),
self.icon_changed)
QObject.connect(self.web.page(),
SIGNAL("windowCloseRequested ()"),
self.close_window)
QObject.connect(self.web.page(),
SIGNAL("geometryChangeRequested ( const QRect)"),
self.set_geometry)