Can't call another class

Florian Bruhin me at the-compiler.org
Mon Sep 6 07:23:33 BST 2021


Hi,

On Sat, Sep 04, 2021 at 04:45:54PM +0200, paparucino wrote:
> Traceback (most recent call last):
>    File "/root/PycharmProjects/ForTestOnly/index.py", line 763, in
> Data_Strip
>      Ui_MainWindow.setupUi (self, self.Strip_Table, anno, month, cursor)
>    File "/root/PycharmProjects/ForTestOnly/strips.py", line 37, in setupUi
>      MainWindow.resize (900, 650) # 1700
> AttributeError: 'QObject' object has no attribute 'resize'

So this means your "MainWindow" object is a QObject, and not a QWidget.
Thus, there's no way to resize it.

> #
> #Script One
> #
> from strips import *
>     # other stuffs

That part would've been very relevant. But I'm guessing self.Strip_Table
is not a QWidget.

>     def Data_Strip(self,limit):
>         mese = self.Strip_Month_sel.currentText()
>         anno = self.Strip_Year_sel.currentText()
>         month = Functions.convert_month_number[mese]
> 
>         self.Strip_Table = QObject(self.Strip_tab)
>         self.alphamese = mese
>         conn = x
>         cursor = conn.cursor(buffered=True, dictionary=True)
>         #Ui_MainWindow.setupUi(self, self.Strip_Table, anno, month, cursor)
>         Ui_MainWindow.setupUi(self, self.Strip_Table)

Here you're passing self.Strip_Table into Ui_MainWindow.setupUi. Why?

> #
> #Script Two
> #
> 
> [...]
>
> class Ui_MainWindow(QMainWindow):
>     def __init__(self):
>         super().__init__()
>         self.setupUi(self)
> 
>     def setupUi(self, MainWindow, anno, month, cursor):
> 
>         MainWindow.setObjectName("MainWindow")
>         MainWindow.resize(900, 650)

And here it crashes, because you passed "self.Strip_Table" as
"MainWindow", but it's not something you can call .resize() on.

Florian

-- 
            me at the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210906/b1dc273e/attachment.sig>


More information about the PyQt mailing list