I've been programming in python three for about a week now, and I'm trying to insert some of these imports below. Where it's marked is where I'm having errors that will state
from PyQt5 import QtSql, uic <=== Right here
from PyQt5.uic import loadUi <=== Right here
from PyQt5.QtWidgets import *
from PyQt5.QtSql import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import pyrebase
import sqlite3
Where it's marked is where I'm having errors that will state
Cannot find reference 'uic' in '__init__pyi'
Related
I had a PyQT Project which was working very well 1-2 months ago. I made some changes (not in the PyQT Project, but in other python files in same directory) and then ran the same PyQT Project again, but now it is giving me error.
The error is as follows,
PySide2/__init__.py: Unable to import shiboken2 from e:\Programming\PyQT\Second_Project,
At the end of the error, I found this ImportError,
ImportError: DLL load failed: The specified procedure could not be found.
I have tried lots of things but still I could not find any solution to this. I tried to re-install the PySide2 but to no use. I tried to change my Python Interpreter from 3.6.0 to 3.8.6 and also 3.9.2 but again, I got the same error. I also tried other different things answered in various Stackoverflow posts but nothing has seemed to work for me.
Can anyone help me how do I resolve this? I am 100% sure that the changes I made in other python files have absolutely nothing to do with this PyQT Project and this problem did not occur because of those changes.
The lines on which I got errors are,
from PySide2 import shiboken2 # Added this line later because shiboken2 wasn't being imported, but still it did not work
import iconify as ico
from iconify.qt import QtGui as IconQtGui, QtWidgets as IconQtWidgets
import PySide2
All the imports that I am making in my main.py file,
import sys
import os
from PyQt5.sip import delete
from PySide2 import shiboken2
# import iconify as ico
from iconify.qt import QtGui as IconQtGui, QtWidgets as IconQtWidgets
import PySide2
import mysql.connector as mc
from qt_material import *
# from PyQt5 import QtWidgets, uic, QtGui
from functools import partial
# from PyQt5.QtCore import Qt
from registered_courses import reg_data
from add_section_page import Ui_Add_Section_Window
from edit_section_page import Ui_Edit_Section_Window
from add_course_page import Ui_Add_Course_Window
from edit_course_page import Ui_Edit_Course_Window
from add_room_page import Ui_Add_Room_Window
from edit_room_page import Ui_Edit_Room_Window
from add_teacher_page import Ui_Add_Teacher_Window
from edit_teacher_page import Ui_Edit_Teacher_Window
from add_registered_course import Ui_Add_Registered_Course_Window
from edit_registered_course import Ui_Edit_Registered_Course_Window
from registered_section_student_details import Ui_Registered_Section_Students_Window
from add_section_student_page import Ui_Add_Section_Student_Window
from add_room_preferences import Ui_Add_Room_Preferences_Teacher_Window
from add_slot_preferences import Ui_Add_Slot_PReferences_Teacher_Window
import sections_timetable
import rooms_timetable
import teachers_timetable
from time_table import *
from student_clashes import *
from teacher_clashes import *
from room_clashes import *
from stylesheet import *
from util import *
#####################################
# Import GUI File
from ui_interface import *
Also, these are all the imports that are being made in my ui_interface file (the python file that is being generated by the Qt Designer)
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'interfaceGufDiZ.ui'
##
## Created by: Qt User Interface Compiler version 5.14.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
QRect, QSize, QUrl, Qt)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont,
QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap,
QRadialGradient)
from PySide2.QtWidgets import *
import icons_rc
I don't know what happen my code.
I can't rebuild some error.
import os
from PyQt5.QtWidgets import QWidget, QApplication, QToolTip, QPushButton, QMainWindow
from time import strftime
Unused import ospylint(unused-import)
Undefined variable: 'QtWidgets'Python(undefined-variable)
How Can I embed youtube video using PyQt5? I tried doing the following,but it gave me an unresolved error:
DirectShowService:doRender unresolved error code
from PyQt5 import QtWidgets,QtCore,QtGui
import sys, time
from PyQt5.QtCore import Qt,QUrl
from PyQt5 import QtWebKit
from PyQt5 import QtWebKitWidgets
from PyQt5.QtWebKit import QWebSettings
#from PyQt5 import QtWebEngineWidgets #import QWebEngineView,QWebEngineSettings
class window(QtWidgets.QMainWindow):
def __init__(self):
QWebSettings.globalSettings().setAttribute(QWebSettings.PluginsEnabled,True)
super(window,self).__init__()
self.centralwid=QtWidgets.QWidget(self)
self.vlayout=QtWidgets.QVBoxLayout()
self.webview=QtWebKitWidgets.QWebView()
self.webview.setUrl(QUrl("https://www.youtube.com/watch?v=Mq4AbdNsFVw"))
self.vlayout.addWidget(self.webview)
self.centralwid.setLayout(self.vlayout)
self.setCentralWidget(self.centralwid)
self.show()
app=QtWidgets.QApplication([])
ex=window()
sys.exit(app.exec_())
You are importing some deprecated modules from PyQt5 (QtWebKit, and QtWebKitWidgets). It seems you have the right paths commented out at the bottom of your imports.
If you resolve these issues and use the proper modules (QtWebEngineCore, QtWebEngineWidgets) it works on my system.
from PyQt5 import QtWidgets,QtCore,QtGui
import sys, time
from PyQt5.QtCore import Qt,QUrl
from PyQt5 import QtWebEngineWidgets
from PyQt5 import QtWebEngineCore
from PyQt5.QtWebEngineWidgets import QWebEngineSettings
class window(QtWidgets.QMainWindow):
def __init__(self):
QWebEngineSettings.globalSettings().setAttribute(QWebEngineSettings.PluginsEnabled,True)
super(window,self).__init__()
self.centralwid=QtWidgets.QWidget(self)
self.vlayout=QtWidgets.QVBoxLayout()
self.webview=QtWebEngineWidgets.QWebEngineView()
self.webview.setUrl(QUrl("https://www.youtube.com/watch?v=Mq4AbdNsFVw"))
self.vlayout.addWidget(self.webview)
self.centralwid.setLayout(self.vlayout)
self.setCentralWidget(self.centralwid)
self.show()
app=QtWidgets.QApplication([])
ex=window()
sys.exit(app.exec_())
The output I get looks like the following (which seems correct):
I have added PyQt5 Browser to my project but when show() method is executed, it blocks the codes following it. Is there a way, not show it as modal, or have it run on another thread?
This is the code I have taken from Python Tutorials site, which works perfect, but just blocks the code on show():
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebKit import *
from PyQt5.QtWebKitWidgets import *
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow
app = QApplication(sys.argv)
web = QWebView()
web.load(QUrl("https://pythonspot.com"))
web.show()
# the code in here won't run while the form web.show() opened, is not closed
sys.exit(app.exec_())
In the version of PySide2 that ships with Maya2017, the winId method on the QWindow class seems to be missing:
w.winId()
Error: AttributeError: file <maya console> line 1: 'PySide2.QtGui.QWindow' object has no attribute 'winId' #
Is there a way to get this value from an existing instance of QWindow?
I used Maya 2018 for macOS 10.11.6. Try this code. It works.
from maya import OpenMayaUI as omui
try:
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
from PySide2 import __version__
from shiboken2 import wrapInstance
except ImportError:
from PySide.QtCore import *
from PySide.QtGui import *
from PySide import __version__
from shiboken import wrapInstance
mayaMainWindowPtr = omui.MQtUtil.mainWindow()
mayaMainWindow= wrapInstance(long(mayaMainWindowPtr), QWidget)
w = QLabel("Hello, Window", parent=mayaMainWindow)
w.setObjectName('Label1')
w.setWindowFlags(Qt.Window)
w.show()
And after typing:
w.winId()
you'll get something like this:
# Result: 140640756092816 #
Andy's example works for me in both Maya2018 and the latest release of Maya2017, but throws an exception in at least the initial release of Maya 2017.
I expect the problem was caused by a bug in PySide2 that got fixed along the way.