]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/demo/ColourDialog.py
Automatically disable wxDialupManager for wxMac and wxCocoa,
[wxWidgets.git] / wxPython / demo / ColourDialog.py
... / ...
CommitLineData
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
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)
21
22 if dlg.ShowModal() == wx.ID_OK:
23
24 # If the user selected OK, then the dialog's wx.ColourData will
25 # contain valid information. Fetch the data ...
26 data = dlg.GetColourData()
27
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
42
43
44#---------------------------------------------------------------------------
45
46
47overview = """\
48This class represents the colour chooser dialog.
49
50Use of this dialog is a multi-stage process.
51
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.
58
59If the user selects something and selects OK, then the wx.ColourData instance contains
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.
63
64Along with he wx.ColourDialog documentation, see also the wx.ColourData documentation
65for details.
66"""
67
68if __name__ == '__main__':
69 import sys,os
70 import run
71 run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
72