keyboard interrupt with with python gtk?

后端 未结 3 1710
孤城傲影
孤城傲影 2020-12-28 15:54

So just like the question says, I\'m trying to let keyboard interrupts happens while Gtk.main() is in progress, however, it just doesn\'t seem to notice that the keyboard in

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-28 16:39

    I also ran into trouble when using the signal module to override the SIGINT handler (100% CPU on the python thread); an alternative for me was the following:

    def main():
        self.mainloop = GObject.MainLoop()
        try:
            self.mainloop.run()
        except KeyboardInterrupt:
            logger.info('Ctrl+C hit, quitting')
            self.exit()
    
    def exit():
        self.mainloop.quit()
    

提交回复
热议问题