title: How to call javascript function from PyQT
body: <p>I'm trying to interact with a google map using python.  I've built an application in PyQT with a QWebView.  The QWebView loads a local html page as shown here:</p>
  
  <pre><code>browser = QwebView()
  browser.load(QUrl("file:///c:/main.html"))
  frame = browser.page().currentFrame()
  frame.evaluateJavaScript(QString("addMarker(-33.89, 151.275)"))
  </code></pre>
  
  <p>The html page is as follows:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" /&gt;
  &lt;style type="text/css"&gt;
    html { height: 100% }
    body { height: 100%; margin: 0px; padding: 0px }
    #map_canvas { height: 100% }
  &lt;/style&gt;
  &lt;script type="text/javascript"
    src="http://maps.google.com/maps/api/js?sensor=false"&gt;
  &lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  var map;
  function initialize() {
      var latlng = new google.maps.LatLng(-34.397, 150.644);
      var myOptions = {
                      zoom: 8,
                      center: latlng,
                      mapTypeId: google.maps.MapTypeId.ROADMAP
                      };
       map = new google.maps.Map(document.getElementById("map_canvas"),
                                 myOptions);
   }
  
   function addMarker(lat, lng) {
    var myLatLng = new google.maps.LatLng(lat, lng);
        var beachMarker = new google.maps.Marker({position: myLatLng,
                                                  map: map
                                                 });
   }
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="initialize();"&gt;
      &lt;div id="map_canvas" style="width:100%; height:100%"&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How can I call <code>addMarker</code> from Python?</p>
  
  <p>I have tried calling addMarker from the HTML (added the call to the <code>onload</code> call) and I tried using a simple javascript expression from the python (<code>frame.evaluateJavaScript("alert(5)")</code>).  Both of those worked, so I know that <code>addMarker</code> and <code>evaluateJavaScript</code> can work, I just don't know how.  </p>
  
  <p>I also tried calling <code>evaluateJavaScript("addMarker(-33.89,151.275)")</code> on the <code>frame.documentElement()</code> object and that didn't work either.</p>