[pygtk] PyGTK equivalent of gtk_get_option_group support

Raúl Núñez de Arenas Coronado raul at dervishd.net
Mon Nov 3 04:26:45 WST 2008


Hi all :)

I'm new to the list and as usual my introduction comes with a question
;) I've been writing in Python for some time, and now I want to play a
bit with PyGTK. I've written a couple of applications to practice
without problems. The docs are good and PyGTK is easy to use (specially
if you have already used GTK+ in C). But I've found my first problem...

I'm having a problem with option handling in a PyGTK program I'm
writing, because PyGTK doesn't seem to provide the equivalent of
"gtk_get_option_group()".

At first I've tried to use gobject.option, because I thought it would
provide a mean of adding the default GTK+ option group. I had a hard
time finding the documentation for gobject.option and finally resorted
to read "option.py", the source code. That code mentions
"gtk_get_option_group()", by the way, as returning an
gobject.OptionGroup object...

The thing is that I don't know how to be able to automatically provide
support for "--help-gtk" option except by running a GTK+ program written
in C, copying the output and adding it by hand to a gobject.OptionParser
object (or an optparse.OptionParser object). I would like to know how to
achieve with PyGTK the same effect that with this C code:

g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_group_set_translation_domain(gtk_get_option_group(TRUE), GETTEXT_PACKAGE);
g_option_context_add_group (context, gtk_get_option_group(TRUE));
g_option_context_parse (context, &argc, &argv, &error);     

That is: being able to add the option group returned by
"gtk_get_option_group()" and have it translated automatically (although
this is secondary...).

Thanks a lot in advance :)

Raúl "DervishD" Núñez de Arenas Coronado
-- 
Linux Registered User 88736 | http://www.dervishd.net
It's my PC and I'll cry if I want to... RAmen!
We are waiting for 13 Feb 2009 23:31:30 +0000 ...


More information about the pygtk mailing list