Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- # you can test it with local web server
- #
- # python -m http.server
- #
- # and it should have url http://localhost:8000
- #
- import sys
- import PyQt5.Qt
- def download(item): # QWebEngineDownloadItem
- print('downloading to', item.path())
- item.accept() # accept file and it will download it (without any messages)
- app = PyQt5.Qt.QApplication(sys.argv)
- win = PyQt5.Qt.QWebEngineView()
- # show page title as window title
- win.loadFinished.connect(lambda:win.setWindowTitle(win.title()))
- # assign function which will download clicked files
- #profile = PyQt5.Qt.QWebEngineProfile.defaultProfile()
- #profile.downloadRequested.connect(download)
- win.page().profile().downloadRequested.connect(download)
- #url = PyQt5.Qt.QUrl('https://google.com')
- url = PyQt5.Qt.QUrl('http://localhost:8000')
- win.load(url)
- win.show()
- app.exec_()
Add Comment
Please, Sign In to add comment