So, I share the slight skepticism as to whether you should want to be doing what you described. Also, I share that it would be better if you show a bit more code to describe the context.
Having said this, the code below is a stab at what you seem to be describing. Note that this is by no means meant to be production-ready code, but more a crude example to illustrate the principle.
What happens is that I call one function on the press of
Button1 and I keep the event loop spinning inside the
while loop by calling
QCoreApplication.processEvents() which means that the GUI will still accept e.g. mouse events. Now, this is something that you should not typically do. There are, however, certain situations where this can be needed, e.g. if you have a non-modal
QProgressDialog and you want to keep the GUI updating while the dialog counter increases (see e.g. http://doc.qt.io/qt-4.8/qprogressdialog.html#value-prop)
Then the second part is only to modify the global variable in the second function when you press button 2 and the
while loop will exit.
Let me know if this helps
from PyQt4.QtCore import *
from PyQt4.QtGui import *
btn2pushed = False
app = QApplication(sys.argv)
win = QDialog()
b1 = QPushButton(win)
b2 = QPushButton(win)
print "Button 1 clicked"
i = 0
while ( btn2pushed != True ):
# not doing anything
if ( i % 100000 == 0 ):
print "Waiting for user to push button 2"
i += 1;
print "Button 2 has been pushed"
btn2pushed = True
if __name__ == '__main__':