]> git.saurik.com Git - wxWidgets.git/blame - wxPython/demo/ColourDialog.py
GetFirstChild does't need the cookie anymore
[wxWidgets.git] / wxPython / demo / ColourDialog.py
CommitLineData
cf694132 1
8fa876ca 2import wx
cf694132
RD
3
4#---------------------------------------------------------------------------
5
6def runTest(frame, nb, log):
8fa876ca
RD
7 dlg = wx.ColourDialog(frame)
8
9 # Ensure the full colour dialog is displayed,
10 # not the abbreviated version.
1e4a197e 11 dlg.GetColourData().SetChooseFull(True)
8fa876ca
RD
12
13 if dlg.ShowModal() == wx.ID_OK:
14
15 # If the user selected OK, then the dialog's wx.ColourData will
16 # contain valid information. Fetch the data ...
cf694132 17 data = dlg.GetColourData()
8fa876ca
RD
18
19 # ... then do something with it. The actual colour data will be
20 # returned as a three-tuple (r, g, b) in this particular case.
cf694132 21 log.WriteText('You selected: %s\n' % str(data.GetColour().Get()))
8fa876ca
RD
22
23 # Once the dialog is destroyed, Mr. wx.ColourData is no longer your
24 # friend. Don't use it again!
cf694132
RD
25 dlg.Destroy()
26
27#---------------------------------------------------------------------------
28
29
cf694132
RD
30overview = """\
31This class represents the colour chooser dialog.
32
8fa876ca 33Use of this dialog is a multi-stage process.
cf694132 34
8fa876ca
RD
35The actual information about how to display the dialog and the colors in the
36dialog's 'registers' are contained in a wx.ColourData instance that is created by
37the dialog at init time. Before displaying the dialog, you may alter these settings
38to suit your needs. In the example, we set the dialog up to show the extended colour
39data selection pane. Otherwise, only the more compact and less extensive colour
40dialog is shown. You may also preset the colour as well as other items.
1fded56b 41
95bfd958 42If the user selects something and selects OK, then the wx.ColourData instance contains
8fa876ca
RD
43the colour data that the user selected. Before destroying the dialog, retrieve the data.
44<b>Do not try to retain the wx.ColourData instance.</b> It will probably not be valid
45after the dialog is destroyed.
1fded56b 46
95bfd958 47Along with he wx.ColourDialog documentation, see also the wx.ColourData documentation
8fa876ca
RD
48for details.
49"""
1fded56b
RD
50
51if __name__ == '__main__':
52 import sys,os
53 import run
8eca4fef 54 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
1fded56b 55