gtk.Builder.connect_signals() issues a RuntimeWarning when a signal handler is not present:
__init__.py:16: RuntimeWarning: missing handler 'on_window_destroy'
self.builder.connect_signals(self)
How do I keep it from issuing the warning and handle it myself?
I'd like the warning to not be printed (without requiring the user to pipe it to /dev/null)
Note: I'm not asking what the warning means, rather how to handle the Warning sort of as if it were an exception , at the moment, it seems a message to stderr is the only thing that happens, I can't do much with that in the program.
You could use the warnings
module .
However, in this case I think it would be easier to check the return value of connect_signals
. From the documentation :
Also, if there is at least one such missing handler,
connect_signals
will return a list of their names, else return value is None.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.