PyQt: app.exec_ () stops running all the following code

I have a code that looks like this:

app = QApplication(sys.argv)
self.interface = Interface()

# The figure
self.fig = self.interface.fig
self.ax = self.fig.add_subplot(111)

self.interface.show()
app.exec_()

print 'this is not printed'

The problem is that after execution app.exec_()nothing happens until I close the window that pops up.

How can I continue code execution?

+4
source share
3 answers

It is intended. You will need to use signals / slots, code inside your Qt classes, or discard threads before you call app.exec ().

- Qt. "" "", " ". , - , , - , . , ( )! python.

Qt , . , , , .

, , . , Qt , , . SO.

+5

app.exec_() , GUI, () . , ; , exec() , ( ). , exec(). .

, exec(), , QThread, ( , , "Go!", "" , ).

exec(), : - , , , , , , GUI (.. pythonw.exe python.exe), exec() , , ok, app.exec() .

+3

In addition to the previous answer, not every time all windows are closed, the GUI event loop executed app.exec_()is stopped. If you want to finish it manually, you can use it app.quit()inside any of the event handlers. It stops the GUI event loop and runs your code after app.exec_().

The first answer is a lot of words about nothing.

+3
source

Source: https://habr.com/ru/post/1537012/


All Articles