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