title: PyQt5 QWebView: Load .html file that loads .js file
body: <p>I am trying to show a leaflet map with <code>QWebView</code> (inspired from <a href="https://snorfalorpagus.net/blog/2014/09/13/embedding-a-leaflet-map-in-a-qt-application/" rel="nofollow noreferrer">here</a>). The structure of my folder looks as follows:</p>
  
  <pre><code>webkit_leaflet/
  ├── map.html
  ├── map.js
  └── map.py
  </code></pre>
  
  <p>When I run <code>map.py</code> with all the content from <code>map.html</code> and <code>map.js</code> included, then the code works.</p>
  
  <pre><code>from PyQt5 import QtWidgets, QtWebKitWidgets
  import sys
  
  
  # Create application
  app = QtWidgets.QApplication(sys.argv)
  
  # Add window
  win = QtWidgets.QWidget()
  win.setWindowTitle('QWebView Map Test')
  
  # Add layout
  layout = QtWidgets.QVBoxLayout()
  win.setLayout(layout)
  
  # Create QWebView
  view = QtWebKitWidgets.QWebView()
  
  # include code from map.html and map.js
  
  view.setHtml('''
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /&gt;
      &lt;script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"&gt;&lt;/script&gt;
      &lt;style&gt;
          body { padding: 0; margin: 0; }
          html, body, #map { height: 100%; }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="map"&gt;&lt;/div&gt;
      &lt;script&gt;
          var map = L.map('map').setView([42.35, -71.08], 13);
          L.tileLayer('http://tiles.mapc.org/basemap/{z}/{x}/{y}.png',
          {
              maxZoom: 18,
              attribution: 'Map data &amp;copy; &lt;a href="http://openstreetmap.org"&gt;OpenStreetMap&lt;/a&gt; contributors, ' +
                  '&lt;a href="http://creativecommons.org/licenses/by-sa/2.0/"&gt;CC-BY-SA&lt;/a&gt;, ' +
                  'Imagery &amp;copy; &lt;a href="http://mapbox.com"&gt;Mapbox&lt;/a&gt;',
              id: 'examples.map-i86nkdio',
          }).addTo(map);
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  
  ''')
  
  # Add QWebView to the layout
  layout.addWidget(view)
  
  # Show window, run app
  win.show()
  app.exec_()
  </code></pre>
  
  <p>However, If I try to load <code>map.html</code> with <code>QtCore.QUrl()</code> nothing happens.</p>
  
  <pre><code>from PyQt5 import QtCore, QtWidgets, QtWebKitWidgets
  import sys
  
  
  # Create application
  app = QtWidgets.QApplication(sys.argv)
  
  # Add window
  win = QtWidgets.QWidget()
  win.setWindowTitle('QWebView Map Test')
  
  # Add layout
  layout = QtWidgets.QVBoxLayout()
  win.setLayout(layout)
  
  # Create QWebView
  view = QtWebKitWidgets.QWebView()
  
  # load .html file
  view.load(QtCore.QUrl('map.html'))
  
  layout.addWidget(view)
  
  win.show()
  app.exec_()
  </code></pre>
  
  <p>Could anybody please tell me how to show the content of the .html file in PyQt5 when I load a JavaScript file from within the external .html file?</p>
  
  <p>Here is the code for <code>map.html</code>:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /&gt;
      &lt;script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"&gt;&lt;/script&gt;
      &lt;style&gt;
          body { padding: 0; margin: 0; }
          html, body, #map { height: 100%; }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="map"&gt;&lt;/div&gt;
      &lt;script src="map.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And also the code for <code>map.js</code></p>
  
  <pre><code>var map = L.map('map').setView([42.35, -71.08], 13);
  L.tileLayer('http://tiles.mapc.org/basemap/{z}/{x}/{y}.png',
  {
      maxZoom: 18,
      attribution: 'Map data &amp;copy; &lt;a href="http://openstreetmap.org"&gt;OpenStreetMap&lt;/a&gt; contributors, ' +
          '&lt;a href="http://creativecommons.org/licenses/by-sa/2.0/"&gt;CC-BY-SA&lt;/a&gt;, ' +
          'Imagery &amp;copy; &lt;a href="http://mapbox.com"&gt;Mapbox&lt;/a&gt;',
      id: 'examples.map-i86nkdio',
  }).addTo(map);
  </code></pre>