]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/StandardPaths.py
4 #----------------------------------------------------------------------
6 class TestPanel(wx
.Panel
):
7 def __init__(self
, parent
, log
):
9 wx
.Panel
.__init
__(self
, parent
, -1)
11 sizer
= wx
.FlexGridSizer(0, 3, 5, 5)
12 sizer
.AddGrowableCol(1)
13 box
= wx
.BoxSizer(wx
.VERTICAL
)
14 fs
= self
.GetFont().GetPointSize()
15 bf
= wx
.Font(fs
+4, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
)
17 t
= wx
.StaticText(self
, -1, "StandardPaths")
19 box
.Add(t
, 0, wx
.CENTER|wx
.ALL
, 4)
20 box
.Add(wx
.StaticLine(self
, -1), 0, wx
.EXPAND
)
22 # get the global (singleton) instance of wx.StandardPaths
23 sp
= wx
.StandardPaths
.Get()
25 # StandardPaths will use the value of wx.App().GetAppName()
26 # for some of the stnadard path components. Let's set it to
27 # something that makes that obvious for the demo. In your own
28 # apps you'll set it in to something more meaningfull for your
29 # app in your OnInit, (or just let it default.)
30 wx
.GetApp().SetAppName("AppName")
34 # Loop through all of the getters in wx.StandardPaths and make
35 # a set of items in the sizer for each.
36 def makeitem(name
, *args
):
37 func
= getattr(sp
, name
)
38 sizer
.Add(wx
.StaticText(self
, -1, "%s%s:" %(name
, repr(args
))),
39 0, wx
.ALIGN_RIGHT|wx
.ALIGN_CENTER_VERTICAL
)
40 sizer
.Add(wx
.TextCtrl(self
, -1, func(*args
),
41 size
=(275,-1), style
=wx
.TE_READONLY
),
42 0, wx
.EXPAND|wx
.ALIGN_CENTER_VERTICAL
)
44 btn
= wx
.Button(self
, wx
.ID_HELP
)
46 self
.help[btn
] = func
.__doc
__
48 for x
in ['GetConfigDir',
53 'GetUserLocalDataDir',
63 # this one needs parameters
64 makeitem('GetLocalizedResourcesDir', 'en',
65 wx
.StandardPaths
.ResourceCat_Messages
)
67 self
.Bind(wx
.EVT_BUTTON
, self
.OnShowDoc
, id=wx
.ID_HELP
)
69 box
.Add(sizer
, 0, wx
.CENTER|wx
.EXPAND|wx
.ALL
, 20)
73 def OnShowDoc(self
, evt
):
74 doc
= self
.help[evt
.GetEventObject()]
76 # trim the whitespace from each line
78 for line
in doc
.split('\n'):
79 lines
.append(line
.strip())
80 doc
= '\n'.join(lines
)
81 wx
.TipWindow(self
, doc
, 500)
84 #----------------------------------------------------------------------
86 def runTest(frame
, nb
, log
):
87 win
= TestPanel(nb
, log
)
90 #----------------------------------------------------------------------
94 overview
= """<html><body>
95 <h2><center>StandardPaths</center></h2>
97 wxWidgets provides this class to simply determine where to locate
98 certain types of files in a platform specific manner. This includes
99 things like configuration files, general data files writeable by the
100 user, and application files that are shared by all user.
107 if __name__
== '__main__':
110 run
.main(['', os
.path
.basename(sys
.argv
[0])] + sys
.argv
[1:])