]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ColourDialog.py
   4 #--------------------------------------------------------------------------- 
   6 def runTest(frame
, nb
, log
): 
   7     dlg 
= wx
.ColourDialog(frame
) 
   9     # Ensure the full colour dialog is displayed,  
  10     # not the abbreviated version. 
  11     dlg
.GetColourData().SetChooseFull(True) 
  13     if dlg
.ShowModal() == wx
.ID_OK
: 
  15         # If the user selected OK, then the dialog's wx.ColourData will 
  16         # contain valid information. Fetch the data ... 
  17         data 
= dlg
.GetColourData() 
  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. 
  21         log
.WriteText('You selected: %s\n' % str(data
.GetColour().Get())) 
  23     # Once the dialog is destroyed, Mr. wx.ColourData is no longer your 
  24     # friend. Don't use it again! 
  27 #--------------------------------------------------------------------------- 
  31 This class represents the colour chooser dialog. 
  33 Use of this dialog is a multi-stage process.  
  35 The actual information about how to display the dialog and the colors in the  
  36 dialog's 'registers' are contained in a wx.ColourData instance that is created by  
  37 the dialog at init time. Before displaying the dialog, you may alter these settings  
  38 to suit your needs. In the example, we set the dialog up to show the extended colour  
  39 data selection pane. Otherwise, only the more compact and less extensive colour  
  40 dialog is shown.  You may also preset the colour as well as other items.  
  42 If the user selects something and selects OK, then the wx.ColourData instance contains 
  43 the 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 
  45 after the dialog is destroyed. 
  47 Along with he wx.ColourDialog documentation, see also the wx.ColourData documentation  
  51 if __name__ 
== '__main__': 
  54     run
.main(['', os
.path
.basename(sys
.argv
[0])])