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:
JavaScript
x
5
1
def connect_modbus(self):
2
# connect with modbus
3
self.connect_modbus = ConnectModbusWindow()
4
self.connect_modbus.show()
5
The ConnectModbusWindow Class looks like this:
JavaScript
1
5
1
class ConnectModbusWindow(QWidget, Ui_ModbusConfig):
2
def __init__(self):
3
super().__init__()
4
self.setupUi(self)
5
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.
JavaScript
1
5
1
def connect_modbus(self):
2
# connect with modbus
3
self.connect_modbus = ConnectModbusWindow()
4
self.connect_modbus.show()
5