0

Error:

ValueError: too many values to unpack (expected 1)
in this line
FORM_CLASS, = loadUiType(path.join(path.dirname(__file__), "main.ui"))

Can someone explain why?

from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.uic import loadUiType

import os
from os import path
import sys

FORM_CLASS, = loadUiType(path.join(path.dirname(__file__), "main.ui"))

class MainApp(QMainWindow , FORM_CLASS):
    def __init__(self,parent=None):
        super(MainApp,self).__init__(parent)
        QMainWindow.__init__(self)
        self.setupUi(self)

def main():
    app = QApplication(sys.argv)
    window = MainApp()
    app.exec_()

if __name__ == '__main__':
    main()

deadshot
  • 8,881
  • 4
  • 20
  • 39
  • just print and see the output of this `loadUiType(path.join(path.dirname(__file__), "main.ui"))` you will know why you getting error – deadshot Jul 17 '20 at 20:16
  • `loadUiType()` returns 2 values, you're expecting single. – Olvin Roght Jul 17 '20 at 20:16
  • 3
    If you wish to ignore the second value, the usual idiom is `FORM_CLASS, _ = ....` and forget about the `_` variable. – Max Jul 17 '20 at 20:17
  • Does this answer your question? ["Too many values to unpack" Exception](https://stackoverflow.com/questions/1479776/too-many-values-to-unpack-exception) – Ken Kinder Jul 17 '20 at 20:27

0 Answers0