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