]> git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/StandardPaths.py
First pass at integrating a code generator in XRCed. Initial patch
[wxWidgets.git] / wxPython / demo / StandardPaths.py
1
2 import wx
3
4 #----------------------------------------------------------------------
5
6 class TestPanel(wx.Panel):
7 def __init__(self, parent, log):
8 self.log = log
9 wx.Panel.__init__(self, parent, -1)
10
11 sizer = wx.FlexGridSizer(0, 3, 4, 4)
12 box = wx.BoxSizer(wx.VERTICAL)
13 fs = self.GetFont().GetPointSize()
14 bf = wx.Font(fs+4, wx.SWISS, wx.NORMAL, wx.BOLD)
15
16 t = wx.StaticText(self, -1, "StandardPaths")
17 t.SetFont(bf)
18 box.Add(t, 0, wx.CENTER|wx.ALL, 5)
19 box.Add(wx.StaticLine(self, -1), 0, wx.EXPAND)
20
21 # get the global (singleton) instance of wx.StandardPaths
22 sp = wx.StandardPaths.Get()
23
24 # StandardPaths will use the value of wx.App().GetAppName()
25 # for some of the stnadard path components. Let's set it to
26 # something that makes that obvious for the demo. In your own
27 # apps you'll set it in to something more meaningfull for your
28 # app in your OnInit, (or just let it default.)
29 wx.GetApp().SetAppName("AppName")
30
31 self.help = {}
32
33 # Loop through all of the getters in wx.StandardPaths and make
34 # a set of items in the sizer for each.
35 def makeitem(name, *args):
36 func = getattr(sp, name)
37 sizer.Add(wx.StaticText(self, -1, "%s%s:" %(name, repr(args))),
38 0, wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
39 sizer.Add(wx.TextCtrl(self, -1, func(*args),
40 size=(275,-1), style=wx.TE_READONLY))
41
42 btn = wx.Button(self, wx.ID_HELP)
43 sizer.Add(btn)
44 self.help[btn] = func.__doc__
45
46 for x in ['GetConfigDir',
47 'GetUserConfigDir',
48 'GetDataDir',
49 'GetLocalDataDir',
50 'GetUserDataDir',
51 'GetUserLocalDataDir',
52 'GetPluginsDir',
53 'GetInstallPrefix',
54 'GetResourcesDir',
55 ]:
56 makeitem(x)
57
58 # this one needs parameters
59 makeitem('GetLocalizedResourcesDir', 'en',
60 wx.StandardPaths.ResourceCat_Messages )
61
62 self.Bind(wx.EVT_BUTTON, self.OnShowDoc, id=wx.ID_HELP)
63 box.Add(sizer, 0, wx.CENTER|wx.ALL, 20)
64 self.SetSizer(box)
65
66
67 def OnShowDoc(self, evt):
68 doc = self.help[evt.GetEventObject()]
69
70 # trim the whitespace from each line
71 lines = []
72 for line in doc.split('\n'):
73 lines.append(line.strip())
74 doc = '\n'.join(lines)
75 wx.TipWindow(self, doc, 500)
76
77
78 #----------------------------------------------------------------------
79
80 def runTest(frame, nb, log):
81 win = TestPanel(nb, log)
82 return win
83
84 #----------------------------------------------------------------------
85
86
87
88 overview = """<html><body>
89 <h2><center>StandardPaths</center></h2>
90
91 wxWidgets provides this class to simply determine where to locate
92 certain types of files in a platform specific manner. This includes
93 things like configuration files, general data files writeable by the
94 user, and application files that are shared by all user.
95
96 </body></html>
97 """
98
99
100
101 if __name__ == '__main__':
102 import sys,os
103 import run
104 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
105