0
votes

I'm trying to figure out how to insert a pyqt5 button into a python script and pause the script so it waits for the button press before it continues.

class MainWindow(QtWidgets.QMainWindow):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
                
        self.ui.button.clicked.connect(pyfile.dothething)
        self.ui.button2.clicked.connect(pyfile.dotheotherthing)

def do_the_stuff():
    do some stuff
    wait for button press
    do_the_stuff()
    

the do_the_stuff() is going to ignore the button since normal python is not event based. How do I insert an event based wait function in the normal python script so it waits until the pyqt button is pressed?

Using a QMessageBox as a popup window is a good way to wait for user interaction, would that meet your needs? - 101
Unfortunately not. The buttons are inside a vstack box in the mainwindow. I'm trying to make it so the buttons appear/disappear when needed and the python script will pause and wait for them. - thatoneguy