summaryrefslogtreecommitdiffstats
path: root/examples/option.py
blob: 345517e6f0a5dd0c4b44d8a0cd9d76e5c70501e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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