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