I am trying to load my .ui file in python and i want to use uic.loadUI()
function but I have problem with importing it, I get an error:
*Cannot find reference 'uic' in '__init__.pyi'*
My code:
from PyQt5.QtWidgets import QApplication, QWidget
from PyQt5 import uic
import sys
class UI(QWidget):
def __init__(self):
super().__init__()
uic.loadUi("mybutton.ui", self)
app = QApplication([])
window = UI()
window.show()
app.exec_()
I am using python 3.9.7. Installed PyQt5 with pip. Checked the PyQt5 folder and it looks like this: https://i.stack.imgur.com/bTlXs.png
Can You please help?
I had a simular problem when using PyCharm. The following Code fixed the issue:
from PyQt5.uic import loadUiType
from os import path
FORM_CLASS, _ = loadUiType(path.join(path.dirname(__file__), "mybutton.ui"))
I Think its a Bug from PyCharm
Filip 在哪里放置 FORM_CLASS, _ = loadUiType(path.join(path.dirname( file ), "mybutton.ui"))
loadUi(path.join(path.dirname( file ), "w.ui"),self)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.