]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/demo/ColourSelect.py
cd9a4cfda043afbd18d7f3f73e7092c8240596f7
2 #----------------------------------------------------------------------------
3 # Name: ColourSelect.py
4 # Purpose: Colour Selection control display testing on panel for wxPython demo
6 # Author: Lorne White (email: lorne.white@telusplanet.net)
10 # Licence: wxWindows license
11 #----------------------------------------------------------------------------
13 from wxPython
. wx
import *
14 from wxPython
. lib
. colourselect
import *
17 #---------------------------------------------------------------------------
19 class TestColourSelect ( wxPanel
):
20 def __init__ ( self
, parent
, log
):
22 wxPanel
.__ init
__ ( self
, parent
, - 1 )
24 wxStaticText ( self
, - 1 , "This example uses a colour selection control based on the wxButton and wxColourDialog Classes. Click Button to get Colour Values" ,
25 wxPoint ( 10 , 20 ), wxSize ( 400 , 60 ))
32 wxButton ( self
, mID
, "Get All Colours" , wxPoint ( self
. x_pos
, self
. y_pos
))
33 EVT_BUTTON ( self
, mID
, self
. OnClick
)
34 self
. y_pos
= self
. y_pos
+ delta
36 wxStaticText ( self
, - 1 , "Default" , wxPoint ( self
. x_pos
, self
. y_pos
), wxSize (- 1 , - 1 )) # name
37 self
. colour_def
= ColourSelect ( self
, - 1 , pos
= wxPoint ( self
. x_pos
+ 100 , self
. y_pos
)) # default colour selection control
39 self
. y_pos
= self
. y_pos
+ delta
40 colours
= [[ 255 , 255 , 0 ], [ 255 , 0 , 255 ], [ 0 , 255 , 0 ], [ 0 , 0 , 255 ]] # list of initial colours for display
41 self
. names
= names
= [ "Default Size" , "Another Size" , "Another Colour" , "Larger" ] # display names
42 sizes
= [ wxDefaultSize
, wxSize ( 60 , 20 ), wxDefaultSize
, wxSize ( 60 , 60 )] # button sizes
45 for i
in range ( len ( colours
)):
46 wxStaticText ( self
, - 1 , names
[ i
], wxPoint ( self
. x_pos
, self
. y_pos
), wxSize (- 1 , - 1 )) # name
48 val
= ColourSelect ( self
, - 1 , colours
[ i
], wxPoint ( self
. x_pos
+ 100 , self
. y_pos
), sizes
[ i
]) # colour selection button
49 self
. set_val
. append ( val
) # store control for reference
50 self
. y_pos
= self
. y_pos
+ delta
53 def OnClick ( self
, event
):
55 colour
= self
. colour_def
. GetColour () # default control value
56 result
. append ( "Default: " + str ( colour
))
58 for i
in range ( len ( self
. set_val
)):
60 colour
= val
. GetColour () # get the colour selection button result
62 result
. append ( name
+ ": " + str ( colour
)) # create string list for easy viewing of results
63 out_result
= string
. joinfields ( result
, ', ' )
64 self
. log
. WriteText ( "Colour Results :" + out_result
)
66 #---------------------------------------------------------------------------
68 def runTest ( frame
, nb
, log
):
69 win
= TestColourSelect ( nb
, log
)
72 #---------------------------------------------------------------------------
89 A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark).