diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/Makefile.am | 3 | ||||
-rw-r--r-- | examples/option.py | 30 |
2 files changed, 32 insertions, 1 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am index 0db7128..41cefea 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1 +1,2 @@ -EXTRA_DIST = properties.py signal.py +EXTRA_DIST = properties.py signal.py option.py + diff --git a/examples/option.py b/examples/option.py new file mode 100644 index 0000000..d4ff876 --- /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 |