How to remove 'current' widget so that def can be used as a Global Variable

21 views Asked by At

Using PyQt5 I would like to create a global definition that I can use for pushbuttons on multiple widgets.

For example I have the below code within a class,


        self.menupb.clicked.connect(self.gotomenu)

    def gotomenu(self):
        widget.addWidget(menu)
        widget.removeWidget(formpage)

This will simply remove the Form Page QDialog I am currently on and take me back to the Menu Page QDialog.

However - I have multiple QDialog's with this same pushbutton, so I am wondering how I can make the 'gotomenu' definition Global so that it would close the current Qdialog rather than have to specify which widget to close.

This would allow me to use the same definition globally rather than have to add it locally to every class.

I hope this makes sense and the answer is not too obvious - I appreciate any assistance.

0

There are 0 answers