GNOME Bugzilla – Bug 157422
gtk_init_check() is called automatically on import gtk
Last modified: 2005-01-22 21:18:34 UTC
gtk_init_check() is called automatically in pygtk. This is wrong because of the following: 1) C gtk_init_check() function is called with argc and argv parameters which are not necessarily arguments of main() function. In pygtk one needs to modify program's real argv array, instead of providing gtk_init() with custom argv, if he wants to. 2) new GTK 2.6 provides function gtk_init_with_args(), which can't be available in pygtk if gtk_init_check() is called automatically. 3) gtk_disable_set_locale() function is not available. 4) gtk_parse_arguments(), gdk_parse_arguments() functions are not available. In other words, one may want to use custom gtk initialization instead of default gtk_init(). Currently one needs to play with real argv of program. Say, is one wants to use custom display, he needs to do: import sys find_and_replace_display_option(sys.argv) import gtk instead of import gtk gtk.init(["--display=somehost:243"]) Or, in c one could call gtk_parse_args() and call gdk_dispay_open() manually. Everything from above (except gtk_init_with_args()) is doable in pygtk, but needs some extra work instead of plain using functions provided by GTK. In most cases automatic calling gtk_init_check() is ok, and it saves some typing ("gtk.init()"). But one extra line of code can't hurt. And I'm sure someone will find another cases where automatic calling gtk_init() reduces pygtk's functionality comparing to functionality provided by C GTK api.
I don't think this is a good idea. We can't force everyone to call gtk.init() because: 1. people will forget and become frustraded because the program will crash at next gtk API call; 2. we have to preserve API compatibility, we are _forbidden_. So, I'm marking this as WONTFIX.