Can't call another class

paparucino paparucino at
Mon Sep 13 15:30:05 BST 2021

Hi, I'm trying to use your script. I had just given it a look on Friday 
and certainly I was hasty in issuing sentences.
Regardless of everything, which we will eventually talk about later, I 
would like to understand why (running the program in standalone) if I 
leave uic.loadUi ('tables.ui', self) everything works perfectly,
but if I use the ui -> derivative py () Ui_MainWindow.setupUi (self,) 
what I get is setupUi () missing 1 required positional argument: 
'MainWindow', which is making me damn.
According to my logic, 'MainWindow' is declared in both files, ui and 
py, so it should be available to the calling script either way. Why 
isn't it in the second?

Coming to your script. Calling it from another script, of course, does 
not pass by def init ... and therefore all the graphics are not initialized.
class Main_S_Window (QtWidgets.QMainWindow):
'' '
     def __init __ (self, year, month, cursor, tableCount = 10):
         super () .__ init __ ()
uic.loadUi ('tables.ui', self)
         self.addTables (tableCount)
         self.addTableButton.clicked.connect (lambda: self.addTable ())
'' '
     def addTables (self, year, month, cursor, count = 10):
         Ui_MainWindow.setupUi (self,)
         for i in range (1.10):
             self.addTable ()

and I get the Missing MainWindow error
if instead

def addTables (self, year, month, cursor, count = 10):
         self.setupUi (self,)
         for i in range (1.10):
             self.addTable ()

   File "/root/PycharmProjects/ForTestOnly/", line 55, in 
     self.setupUi (self,)
AttributeError: 'str' object has no attribute 'setupUi'

and here the confusion increases again because I can't figure out where 
it gets 'str' from since I'm calling a function
I am literally in mental confusion



On 9/10/21 6:59 AM, Maurizio Berti wrote:

More information about the PyQt mailing list