How to set push-button to keyboard interrupt in PyQt

后端 未结 2 1884
傲寒
傲寒 2021-01-27 08:48

While running program through the terminal we can stop the program by pressing \'Ctrl+c\' and it will show the message as \'KeyboardInterrupt\' . So, is there any way to do the

2条回答
  •  悲哀的现实
    2021-01-27 09:10

    If your program is running a loop, you can call processEvents periodically to allow the gui time to update (which should allow you to click a button to close the application):

        count = 0
        while True:
             count += 1
             if not count % 50:
                 QtGui.qApp.processEvents()
             # do stuff...
    

提交回复
热议问题