<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META content="text/html; charset=ISO-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16430">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff text=#000000>
<BLOCKQUOTE
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B>
<A title=vincent.vandevyvre@swing.be
href="mailto:vincent.vandevyvre@swing.be">Vincent Vande Vyvre</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=pyqt@riverbankcomputing.com
href="mailto:pyqt@riverbankcomputing.com">pyqt@riverbankcomputing.com</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Saturday, July 23, 2011 12:12
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [PyQt] Are theer limits to
the ability of QWebView to process javascript?</DIV>
<DIV><BR></DIV>Le 23/07/11 03:12, Phlip a écrit :
<BLOCKQUOTE
cite=mid:CADC6JdSGTJbaZ9wboD2xC5AN6KkNNGX_ZhZz6ZD-PE1Q2-pd6w@mail.gmail.com
type="cite"><PRE wrap="">On Fri, Jul 22, 2011 at 1:14 PM, BJ <A class=moz-txt-link-rfc2396E href="mailto:bjtexas@swbell.net>"><bjtexas@swbell.net></A> wrote:
</PRE>
<BLOCKQUOTE type="cite"><PRE wrap="">I have a webpage containing quite a bit of javascript to display Google
Maps.
It seems to run well on IE and Firefox browsers but is unable to run in a
QWebView.
</PRE></BLOCKQUOTE><PRE wrap="">Can you report any error messages, or logging? Can you survey other
Ajax sites & see if any do or don't work?
Does any of the maps page show at all?
And recall that Google Maps depends on your cache to hold each
regional image tile. So does QWebView have, for example, a different
cache than real web browsers that use webkit?
</PRE></BLOCKQUOTE>This code is
working:<BR><BR>-------%<-----------------<BR># -*- coding: utf-8
-*-<BR><BR>import sys<BR><BR>from PyQt4 import QtCore, QtGui<BR>from PyQt4
import QtWebKit<BR><BR>class WebDialog(object):<BR> def
setupUi(self, WebDlg):<BR>
WebDlg.resize(671, 588)<BR>
WebDlg.setWindowTitle("GeoTag")<BR>
self.gridLayout =
QtGui.QGridLayout(WebDlg)<BR>
self.verticalLayout =
QtGui.QVBoxLayout()<BR> self.webView
= QtWebKit.QWebView(WebDlg)<BR>
self.verticalLayout.addWidget(self.webView)<BR>
self.horizontalLayout_2 =
QtGui.QHBoxLayout()<BR>
self.horizontalLayout =
QtGui.QHBoxLayout()<BR>
self.link_led =
QtGui.QLineEdit(WebDlg)<BR>
self.link_led.setMinimumSize(QtCore.QSize(400,
0))<BR>
self.horizontalLayout.addWidget(self.link_led)<BR>
self.get_coord_btn =
QtGui.QToolButton(WebDlg)<BR>
self.get_coord_btn.setText("Get
coord.")<BR>
self.horizontalLayout.addWidget(self.get_coord_btn)<BR>
self.progressBar =
QtGui.QProgressBar(WebDlg)<BR>
self.progressBar.setProperty("value",
0)<BR>
self.progressBar.setTextVisible(False)<BR>
self.horizontalLayout.addWidget(self.progressBar)<BR>
self.close_btn =
QtGui.QPushButton(WebDlg)<BR>
self.close_btn.setText("Close")<BR>
self.horizontalLayout.addWidget(self.close_btn)<BR>
self.verticalLayout.addLayout(self.horizontalLayout)<BR>
self.gridLayout.addLayout(self.verticalLayout, 0, 0, 1,
1)<BR> self.webPage =
QtWebKit.QWebPage()<BR>
self.webView.setPage(self.webPage)
<BR>
self.webView.settings().setAttribute(QtWebKit.QWebSettings.PluginsEnabled,
True)<BR>
self.webView.loadProgress.connect(self.progress)<BR>
self.webView.urlChanged.connect(self.set_link)<BR>
self.webPage.contentsChanged.connect(self.pos_changed)<BR>
frame = self.webPage.mainFrame()<BR>
self.get_coord_btn.clicked.connect(self.pos_changed)<BR>
self.close_btn.clicked.connect(WebDlg.accept)<BR>
QtCore.QMetaObject.connectSlotsByName(WebDlg)<BR><BR>
self.set_link("mapViewer.html")<BR>
self.load_page()<BR><BR> def set_link(self,
url):<BR> if not isinstance(url,
str):<BR>
url = url.toString()<BR>
self.link_led.setText(url)<BR><BR> def
load_page(self):<BR> url =
str(self.link_led.text())<BR>
self.webView.setUrl(QtCore.QUrl(url))<BR><BR> def
progress(self, val):<BR>
self.progressBar.setValue(val)<BR><BR> def
resize_event(self, event):<BR> print
"Geometry %s" %
self.webView.geometry()<BR>
QtWebKit.QWebView.resizeEvent(self.webView, event)<BR><BR>
def pos_changed(self, event):<BR>
frame = self.webPage.mainFrame()<BR>
document =
frame.documentElement()<BR> datas =
document.findAll("div")<BR> print
"found %s 'div'" % datas.count()<BR>
dat =
frame.findFirstElement("div#latlon")<BR>
print dat, dat.toPlainText()<BR>
dat.setFocus()<BR><BR>if __name__ == "__main__":<BR> import
sys<BR> app =
QtGui.QApplication(sys.argv)<BR> WebDlg =
QtGui.QDialog()<BR> ui = WebDialog()<BR>
ui.setupUi(WebDlg)<BR> WebDlg.show()<BR>
sys.exit(app.exec_())<BR><BR>----%<-------------------------<BR>and the
javascript<BR><BR>mapViewer.html<BR>-----%<-------------------------<BR><BR><!DOCTYPE
html><BR><html><BR><head><BR><meta name="viewport"
content="initial-scale=1.0, user-scalable=no" /><BR><style
type="text/css"><BR> html { height: 100% }<BR> body { height:
100%; margin: 0px; padding: 0px }<BR> #map_canvas { height: 100%
}<BR></style><BR><script type="text/javascript"<BR>
src=<A class=moz-txt-link-rfc2396E
href="http://maps.google.com/maps/api/js?sensor=false">"http://maps.google.com/maps/api/js?sensor=false"</A>><BR></script><BR><script
type="text/javascript"><BR><BR><BR> function updateLatLonFields(lat,
lon) {<BR> document.getElementById("latlon").innerHTML = lat
+ ', ' + lon;<BR> }<BR><BR> function initialize()
{<BR> var latlng = new google.maps.LatLng(-34.397,
150.644);<BR> var myOptions =
{<BR> zoom: 8,<BR>
center: latlng,<BR> mapTypeId:
google.maps.MapTypeId.ROADMAP<BR> };<BR>
var map = new
google.maps.Map(document.getElementById("map_canvas"),<BR>
myOptions);<BR><BR>
document.getElementById("latlon").innerHTML = latlng.lat() + ", " +
latlng.lng();<BR><BR> google.maps.event.addListener(map,
'bounds_changed', function() {<BR>
var center = map.getCenter();<BR>
updateLatLonFields(center.lat(),
center.lng());<BR> });<BR><BR>
}<BR><BR></script><BR></head><BR><body
onload="initialize()"><BR> <div id="map_canvas" style="width:100%;
height:100%"></div><BR> <div
id="latlon"></div><BR></body><BR></html><BR><BR>--------%<--------------------------------<BR><BR>Same
results with OpenStreetMap<BR><BR>Regards<BR><BR><BR>
<DIV class=moz-signature>-- <BR>Vincent V.V.<BR><A
href="https://launchpad.net/oqapy">Oqapy</A> . <A
href="https://launchpad.net/qarte+7">Qarte+7</A> . <A
href="https://launchpad.net/paqager">PaQager</A></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>PyQt mailing
list
PyQt@riverbankcomputing.com<BR>http://www.riverbankcomputing.com/mailman/listinfo/pyqt</BLOCKQUOTE>
<DIV><FONT size=2 face=Arial>Thanks for the example Vincent, I found my problem
after looking at your</FONT></DIV>
<DIV><FONT size=2 face=Arial>example. However there seems to be some
functionality issues. I can't</FONT></DIV>
<DIV><FONT size=2 face=Arial>pan with the cursor or get my infowindows to
work.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Thanks for your response.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Bob</FONT></DIV>
<DIV> </DIV></BODY></HTML>