diff options
author | Johannes Hölzl <johannes.hoelzl@gmx.de> | 2006-04-29 18:58:20 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2006-04-29 18:58:20 +0000 |
commit | 6896d50402332dcac8d079d48d22e30c3e0f7231 (patch) | |
tree | 626e46020f2134d9254a7f190ff7fba59310cad3 /examples/option.py | |
parent | cd01d8f09504748a17e1e7ae68ada9d4edaf23fe (diff) | |
download | pygobject-6896d50402332dcac8d079d48d22e30c3e0f7231.tar.gz |
reviewed by: Johan Dahlin <jdahlin@async.com.br>
2006-04-29 Johannes Hölzl <johannes.hoelzl@gmx.de>
reviewed by: Johan Dahlin <jdahlin@async.com.br>
* examples/Makefile.am:
* examples/option.py:
* gobject/Makefile.am:
* gobject/gobjectmodule.c: (init_gobject):
* gobject/option.py:
* gobject/pygobject-private.h:
* gobject/pygoptioncontext.c: (pyg_option_context_init),
(pyg_option_context_dealloc), (pyg_option_context_parse),
(pyg_option_context_set_help_enabled),
(pyg_option_context_get_help_enabled),
(pyg_option_context_set_ignore_unknown_options),
(pyg_option_context_get_ignore_unknown_options),
(pyg_option_context_set_main_group),
(pyg_option_context_get_main_group),
(pyg_option_context_add_group), (pyg_option_context_compare),
(pyg_option_context_new):
* gobject/pygoptiongroup.c: (check_if_owned), (destroy_g_group),
(pyg_option_group_init), (pyg_option_group_dealloc), (arg_func),
(pyg_option_group_add_entries),
(pyg_option_group_set_translation_domain),
(pyg_option_group_compare), (pyg_option_group_transfer_group),
(pyg_option_group_new):
* tests/test_option.py:
Add support for GOption, fixes #163645
Diffstat (limited to 'examples/option.py')
-rw-r--r-- | examples/option.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/examples/option.py b/examples/option.py new file mode 100644 index 00000000..d4ff8760 --- /dev/null +++ b/examples/option.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# gnome-python/pygobject/examples/option.py + +from gobject.option import OptionGroup, OptionParser, make_option + +group = OptionGroup("example", "OptionGroup Example", "Shows all example options", + option_list = [ + make_option("--example", + action="store_true", + dest="example", + help="An example option."), + ]) + +parser = OptionParser("NAMES ...", + description="A simple gobject.option example.", + option_list = [ + make_option("--file", "-f", + type="filename", + action="store", + dest="file", + help="A filename option"), + # ... + ]) + +parser.add_option_group(group) + +parser.parse_args() + +print "group: example ", group.values.example +print "parser: file", parser.values.file |