]>
Commit | Line | Data |
---|---|---|
b8b8dda7 RD |
1 | #!/bin/env python |
2 | #---------------------------------------------------------------------------- | |
3 | # Name: test6.py | |
4 | # Purpose: Testing wxConfig | |
5 | # | |
6 | # Author: Robin Dunn | |
7 | # | |
8 | # Created: 26-Nov-1998 | |
9 | # RCS-ID: $Id$ | |
10 | # Copyright: (c) 1998 by Total Control Software | |
11 | # Licence: wxWindows license | |
12 | #---------------------------------------------------------------------------- | |
13 | ||
14 | import sys | |
0699c864 | 15 | from wxPython.utils import wxConfig |
b8b8dda7 RD |
16 | |
17 | ||
18 | #---------------------------------------------------------------------------- | |
19 | ||
20 | def main(): | |
21 | ||
3576334e | 22 | cfg = wxConfig('test6', 'TCS', ".testconfig") |
b8b8dda7 RD |
23 | |
24 | cmd = '' | |
25 | if len(sys.argv) > 1: | |
26 | cmd = sys.argv[1] | |
27 | ||
28 | if cmd == 'add': | |
29 | cfg.SetPath('one/two/three') | |
30 | cfg.Flush() | |
31 | ||
32 | cfg.Write('aaa', 'The quick brown fox jummped over the lazy dog.') | |
33 | cfg.Write('bbb', 'This is a test of the emergency broadcast system') | |
34 | ||
35 | aList = ['one', 'two', 'buckle', 'my', 'shoe', 1966] | |
36 | cfg.Write('ccc', str(aList)) | |
37 | ||
38 | cfg.Write('zzz/yyy', 'foobar') | |
39 | cfg.Write('zzz/xxx', 'spam and eggs') | |
40 | ||
41 | cfg.Flush() | |
42 | ||
43 | elif cmd == 'enum': | |
44 | traverse(cfg, '/') | |
45 | ||
46 | elif cmd == 'del': | |
47 | cfg.DeleteAll() | |
48 | ||
49 | else: | |
50 | print 'Specify command: add, enum, or del.' | |
51 | ||
52 | ||
53 | ||
54 | def traverse(cfg, path): | |
55 | print path | |
56 | cont, val, idx = cfg.GetFirstEntry() | |
57 | while cont: | |
58 | print "%s/%s = %s" % (path, val, cfg.Read(val)) | |
59 | cont, val, idx = cfg.GetNextEntry(idx) | |
60 | ||
61 | cont, val, idx = cfg.GetFirstGroup() | |
62 | while cont: | |
63 | if path == '/': | |
64 | newpath = path+val | |
65 | else: | |
66 | newpath = path+'/'+val | |
67 | ||
68 | cfg.SetPath(newpath) | |
69 | traverse(cfg, newpath) | |
70 | cfg.SetPath(path) | |
71 | cont, val, idx = cfg.GetNextGroup(idx) | |
72 | ||
73 | ||
74 | ||
75 | if __name__ == '__main__': | |
76 | #import pdb | |
77 | #pdb.run('main()') | |
78 | main() | |
79 | ||
80 | ||
81 | #---------------------------------------------------------------------------- |