]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/StandardPaths.py
Little tweaks to match recent wxWidgets updates
[wxWidgets.git] / wxPython / demo / StandardPaths.py
CommitLineData
62038e59
RD
1
2import wx
3
4#----------------------------------------------------------------------
5
6class 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, 5, 5)
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 for x in ['GetConfigDir',
36 'GetUserConfigDir',
37 'GetDataDir',
38 'GetLocalDataDir',
39 'GetUserDataDir',
40 'GetUserLocalDataDir',
41 'GetPluginsDir',
42 'GetInstallPrefix',
43 ]:
44 func = getattr(sp, x)
45 sizer.Add(wx.StaticText(self, -1, x+'():'), 0,
46 wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL)
47 sizer.Add(wx.TextCtrl(self, -1, func(), size=(275,-1), style=wx.TE_READONLY))
48
49 btn = wx.Button(self, wx.ID_HELP)
50 sizer.Add(btn)
51 self.help[btn] = func.__doc__
52
53 self.Bind(wx.EVT_BUTTON, self.OnShowDoc, id=wx.ID_HELP)
54
55 box.Add(sizer, 0, wx.CENTER|wx.ALL, 25)
56 self.SetSizer(box)
57
58
59 def OnShowDoc(self, evt):
60 doc = self.help[evt.GetEventObject()]
61
62 # trim the whitespace from each line
63 lines = []
64 for line in doc.split('\n'):
65 lines.append(line.strip())
66 doc = '\n'.join(lines)
67 wx.TipWindow(self, doc, 500)
68
69
70#----------------------------------------------------------------------
71
72def runTest(frame, nb, log):
73 win = TestPanel(nb, log)
74 return win
75
76#----------------------------------------------------------------------
77
78
79
80overview = """<html><body>
81<h2><center>StandardPaths</center></h2>
82
83wxWidgets provides this class to simply determine where to locate
84certain types of files in a platform specific manner. This includes
85things like configuration files, general data files writeable by the
86user, and application files that are shared by all user.
87
88</body></html>
89"""
90
91
92
93if __name__ == '__main__':
94 import sys,os
95 import run
96 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
97