From 6896d50402332dcac8d079d48d22e30c3e0f7231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20H=C3=B6lzl?= Date: Sat, 29 Apr 2006 18:58:20 +0000 Subject: reviewed by: Johan Dahlin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2006-04-29 Johannes Hölzl reviewed by: Johan Dahlin * 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 --- examples/option.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/option.py (limited to 'examples/option.py') 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 -- cgit v1.2.1