]>
Commit | Line | Data |
---|---|---|
49875c53 RD |
1 | |
2 | #---------------------------------------------------------------------------- | |
3 | # Name: ColourSelect.py | |
4 | # Purpose: Colour Selection control display testing on panel for wxPython demo | |
5 | # | |
6 | # Author: Lorne White (email: lorne.white@telusplanet.net) | |
7 | # | |
e189b070 | 8 | # Version 0.5 |
49875c53 RD |
9 | # Date: Feb 26, 2001 |
10 | # Licence: wxWindows license | |
11 | #---------------------------------------------------------------------------- | |
12 | ||
13 | from wxPython.wx import * | |
14 | from wxPython.lib.colourselect import * | |
15 | import string | |
16 | ||
17 | #--------------------------------------------------------------------------- | |
18 | ||
19 | class TestColourSelect(wxPanel): | |
20 | def __init__(self, parent, log): | |
21 | self.log = log | |
22 | wxPanel.__init__(self, parent, -1) | |
23 | ||
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)) | |
26 | ||
27 | self.x_pos = 30 | |
28 | self.y_pos = 100 | |
29 | delta = 40 | |
e189b070 | 30 | |
49875c53 | 31 | mID = NewId() |
e189b070 | 32 | wxButton(self, mID, "Get All Colours", wxPoint(self.x_pos, self.y_pos)) |
49875c53 RD |
33 | EVT_BUTTON(self, mID, self.OnClick) |
34 | self.y_pos = self.y_pos + delta | |
35 | ||
36 | wxStaticText(self, -1, "Default", wxPoint(self.x_pos, self.y_pos), wxSize(-1, -1)) # name | |
37 | self.colour_def = ColourSelect(self, wxPoint(self.x_pos+100, self.y_pos)) # default colour selection control | |
38 | ||
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 = [ None, wxSize(60, 20), None, wxSize(60, 60)] # button sizes | |
43 | self.set_val = [] | |
44 | ||
45 | for i in range(len(colours)): | |
46 | wxStaticText(self, -1, names[i], wxPoint(self.x_pos, self.y_pos), wxSize(-1, -1)) # name | |
47 | ||
48 | val = ColourSelect(self, wxPoint(self.x_pos+100, self.y_pos), colours[i], sizes[i]) # colour selection button | |
49 | self.set_val.append(val) # store control for reference | |
50 | self.y_pos = self.y_pos + delta | |
51 | ||
52 | def OnClick(self, event): | |
53 | result = [] | |
54 | colour = self.colour_def.GetColour() # default control value | |
55 | result.append("Default: " + str(colour)) | |
e189b070 | 56 | |
49875c53 RD |
57 | for i in range(len(self.set_val)): |
58 | val = self.set_val[i] | |
59 | colour = val.GetColour() # get the colour selection button result | |
60 | name = self.names[i] | |
61 | result.append(name + ": " + str(colour)) # create string list for easy viewing of results | |
62 | out_result = string.joinfields(result, ', ') | |
63 | self.log.WriteText("Colour Results :" + out_result) | |
e189b070 | 64 | |
49875c53 RD |
65 | #--------------------------------------------------------------------------- |
66 | ||
67 | def runTest(frame, nb, log): | |
68 | win = TestColourSelect(nb, log) | |
69 | return win | |
70 | ||
71 | #--------------------------------------------------------------------------- | |
72 | ||
73 | ||
74 | ||
75 | ||
76 | ||
77 | ||
78 | ||
79 | ||
80 | ||
81 | ||
82 | ||
83 | ||
84 | ||
85 | ||
86 | ||
87 | overview = """\ | |
88 | A checkbox is a labelled box which is either on (checkmark is visible) or off (no checkmark). | |
89 | ||
90 | wxCheckBox() | |
91 | ----------------------- | |
92 | ||
93 | Default constructor. | |
94 | ||
95 | wxCheckBox(wxWindow* parent, wxWindowID id, const wxString& label, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& val, const wxString& name = "checkBox") | |
96 | ||
97 | Constructor, creating and showing a checkbox. | |
98 | ||
99 | Parameters | |
100 | ------------------- | |
101 | ||
102 | parent = Parent window. Must not be NULL. | |
103 | ||
104 | id = Checkbox identifier. A value of -1 indicates a default value. | |
105 | ||
106 | label = Text to be displayed next to the checkbox. | |
107 | ||
108 | pos = Checkbox position. If the position (-1, -1) is specified then a default position is chosen. | |
109 | ||
110 | size = Checkbox size. If the default size (-1, -1) is specified then a default size is chosen. | |
111 | ||
112 | style = Window style. See wxCheckBox. | |
113 | ||
114 | validator = Window validator. | |
115 | ||
116 | name = Window name. | |
117 | """ |