I have two classes in PySide6. One is the main window and the second one is a widgetWindow. The main window is opening the widgetWindow with this function:
def connect_modbus(self): # connect with modbus self.connect_modbus = ConnectModbusWindow() self.connect_modbus.show()
The ConnectModbusWindow Class looks like this:
class ConnectModbusWindow(QWidget, Ui_ModbusConfig): def __init__(self): super().__init__() self.setupUi(self)
I have no problem opening the ConnectModbusWindow for the first time. But when I try it for the second time i get the following error:
TypeError: ‘ConnectModbusWindow’ object is not callable
It doesn’t matter if I am closing the window, with the red close button or with
self.close()
.
I created the Ui_ModbusConfig class which gets inherited by ConnectModbusWindow in the pyside6-designer.
Advertisement
Answer
I gave my variable self.connect_modbus the same name as the function itself.
def connect_modbus(self): # connect with modbus self.connect_modbus = ConnectModbusWindow() self.connect_modbus.show()