ImportError: cannot import name QWebEngineView - python-3.x

import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWebEngineView
app = QApplication(sys.argv)
window = QMainWindow()
view = QWebEngineView()
view.load(QUrl("http://www.google.com"))
window.setCentralWidget(view)
window.show()
sys.exit(app.exec_())
This is exactly the error I get in code like this:
Traceback (most recent call last):
File "C:\Users\eymen\Desktop\qtweb.py", line 2, in <module>
from PyQt5.QtWidgets import QApplication, QMainWindow, QWebEngineView
ImportError: cannot import name 'QWebEngineView' from 'PyQt5.QtWidgets' (C:\Users\eymen\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyQt5\QtWidgets.pyd)
But my pyqt5 version is the most up-to-date and I don't see any errors. I thought it was related to the Python version but I couldn't get an idea. Python version: 3.11.1 alternative libraries do not satisfy my request.
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QWebEngineView
app = QApplication(sys.argv)
window = QMainWindow()
view = QWebEngineView()
view.load(QUrl("http://www.google.com"))
window.setCentralWidget(view)
window.show()
sys.exit(app.exec_())
I tried this code but when it should show google.com in python window it gave error and said QWebEngineView library not supported

You need to use
from PyQt5.QtWebEngineWidgets import QWebEngineView
Code:
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl
app = QApplication(sys.argv)
window = QMainWindow()
view = QWebEngineView()
view.load(QUrl("http://www.google.com"))
window.setCentralWidget(view)
window.show()
sys.exit(app.exec_())

Related

QSplashScreen not showing image pyqt5

I am trying to show splashscreen before loading the mainwindow but a transparent window is displayed instead of the intended image. The splashscreen is supposed to be displayed after import and instantiation loading of Dashboard, which takes a few seconds, but the image only shows when the splash screen is about to close. Below is my code:
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt, QThread
from PyQt5.QtGui import QPixmap
from modules.video_opening.map.map import Map
import sys
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
splash_pic = QPixmap('splash.png')
splash = QtWidgets.QSplashScreen(splash_pic, Qt.WindowStaysOnTopHint)
splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
splash.setEnabled(False)
splash.setMask(splash_pic.mask())
splash.showMessage("<h6>Loading...</h6>", Qt.AlignBottom | Qt.AlignRight, Qt.black)
splash.show()
app.processEvents()
from modules.dashboard import Dashboard
dashboard = Dashboard()
splash.finish(dashboard)
dashboard.show()
app.exec_()
Here's what's working for me at the moment: adding a loop of app.processEvents()
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt, QThread
from PyQt5.QtGui import QPixmap
from modules.video_opening.map.map import Map
import sys
if __name__ == "__main__":
app = QtWidgets.QApplication(sys.argv)
splash_pic = QPixmap('splash.png')
splash = QtWidgets.QSplashScreen(splash_pic, Qt.WindowStaysOnTopHint)
splash.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
splash.setEnabled(False)
splash.setMask(splash_pic.mask())
splash.showMessage("<h6>Loading...</h6>", Qt.AlignBottom | Qt.AlignRight, Qt.black)
splash.show()
for i in range(10000):
app.processEvents()
from modules.dashboard import Dashboard
dashboard = Dashboard()
splash.finish(dashboard)
dashboard.show()
app.exec_()

Open dialog ( window) form file PyQt5

( How can i link two file ( two dialog) )
when i click on Open Second i want to go to another page ( window)
Here is the code for two file
Home.py
from PyQt5 import QtGui
import sys
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication, QLabel
class MainWindow(QMainWindow):
def __init__(self):
super(MainWindow, self).__init__()
btn = QPushButton('Open Second', self)
if __name__ == '__main__':
app = QApplication(sys.argv)
MW = MainWindow()
MW.show()
sys.exit(app.exec_())
SecondWindow.py
from PyQt5 import QtGui
import sys
from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication, QLabel
class SecondWindow(QMainWindow):
def __init__(self):
super(SecondWindow, self).__init__()
if __name__ == '__main__':
app = QApplication(sys.argv)
MW = SecondWindow()
MW.show()
sys.exit(app.exec_())

No module named PyQt5

I'm trying to create a simple program using python and PyQt. I cannot run my work because of this error:
Traceback (most recent call last):
File "pyqt_first.py", line 2, in <module>
from PyQt5 import QtCore, QtGui, uic
ModuleNotFoundError: No module name 'PyQt5'
Here is my code:
import sys
from PyQt5 import QtCore, QtGui, uic
qtCreatorFile = "tax_calc.ui"
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)
class MyApp(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
Ui_MainWindow.__init__(self)
self.setupUi(self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = MyApp()
window.show()
sys.exit(app.exec_())

Not getting the WINDOW on using PYQT4 in ubuntu16

Here is my simple code to make a window using pyqt4 , but after running the code gets compiled but not showing any window.
import sys
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *
app = QApplication(sys.argv)
window = QWidget()
window.show()
If there is some error in the code please correct me .

ImportError: No module named ui_imagedialog

I am new to pyQt4. First I installed pyqt4 then installed QTDesigner. And tried to run the given program( From internet). The file is named as main.py
import sys
from PyQt4.QtGui import QApplication, QDialog
from ui_imagedialog import Ui_ImageDialog
app = QApplication(sys.argv)
window = QDialog()
ui = Ui_ImageDialog()
ui.setupUi(window)
window.show()
sys.exit(app.exec_())
run the program using terminal
python main.py
I got the following error
from ui_imagedialog import Ui_ImageDialog
ImportError: No module named ui_imagedialog
How to solve this??
You could try running this instead;
import sys
from PyQt4.QtGui import QApplication, QDialog
app = QApplication(sys.argv)
window = QDialog()
window.show()
sys.exit(app.exec_())
And if you are using PyQt5, use this;
import sys
from PyQt5.QtWidgets import QApplication, QDialog
app = QApplication(sys.argv)
window = QDialog()
window.show()
sys.exit(app.exec_())
This will produce an empty window.
From the documentation, the ui_imagedialog is an imaginary file.

Resources