PyQt app doesn't exit when i close the window

前端 未结 1 1623
天命终不由人
天命终不由人 2021-01-24 04:47

Whenever i execute the code and close the window, it closes,but the python console in the IDE doesn\'t return the exit code,when i try to run it again i get a warning dialog tha

相关标签:
1条回答
  • 2021-01-24 05:37

    If you execute the code in a running (i)python console, you do not need to start a qapplication in the usual way, the two lines

    win = QMainWindow()       
    win.show()
    

    will be enough to get you running. This is because the console already has a (threaded) qapplication prepared for you.

    The error message can be caused when no console has focus (i.e., perhaps the one you were using quit because of sys.exit(), or you clicked away etc). You need to simply click in an (i)python console to get it to be 'selected', and then the run button should work again.

    0 讨论(0)
提交回复
热议问题