This is another post in the series about making desktop applications using Python. If you are new here please check the previous posts on our site. Today we will learn how to convert any website to a desktop application with 20 lines of python code. Let us create a youtube application today. Let us dive into the code
import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtWebEngineWidgets import QWebEngineView from PyQt5.QtCore import QUrl, QSize from PyQt5 import QtGui def main(): app = QApplication(sys.argv) window = QWebEngineView() window.setUrl(QUrl('https://www.youtube.com')) window.showMaximized() window.setWindowTitle("Youtube") window.show() app_icon = QtGui.QIcon() app_icon.addFile('youtubelogo.png', QSize(256,256)) app.setWindowIcon(app_icon) sys.exit(app.exec_()) if __name__ == '__main__': main()
We are using QWebEngineView to load the youtube and add the logo to the app. Please check our last part of the series if you need a detailed explanation.
By just changing the URL and logo you can create any desktop application for any web app.
Hope you have learned a cool idea using Python. Please subscribe to get notifications also please share your valuable suggestions with email@example.com