WxColourDialog-WxBasic
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
frame = new wxFrame( Null, -1, "", wxPoint(10, 10),
wxSize(320, 200), wxCAPTION | wxSYSTEM_MENU )
panel = new wxPanel( frame, -1 )
sel = new wxButton( panel, -1, "Select Colour", wxPoint(120, 20) )
check = new wxCheckBox( panel, -1, "Custom Colour", wxPoint(210, 25) )
rlabel = new wxStaticText( panel, -1, "Red:", wxPoint(20, 60) )
r = new wxTextCtrl( panel, -1, "", wxPoint(50, 60), wxSize(40, 20) )
glabel = new wxStaticText( panel, -1, "Green:", wxPoint(100, 60) )
g = new wxTextCtrl( panel, -1, "", wxPoint(140, 60), wxSize(40, 20) )
blabel = new wxStaticText( panel, -1, "Blue:", wxPoint(190, 60) )
b = new wxTextCtrl( panel, -1, "", wxPoint(220, 60), wxSize(40, 20) )
frame.Show(True)
' Colours to be shown in the Colour Dialog.
colour_data = wxColourData()
sub Set(event)
if check.GetValue() then
colour_data.SetChooseFull(True) ' Show custom colours.
else
colour_data.SetChooseFull(False) ' Don't show custom colours.
end if
' This colour will be de deafult selected in the dialog.
colour_data.SetColour(wxColour(0, 128, 255))
' Create the Colour Dialog.
colour_dialog = wxColourDialog(frame, colour_data)
colour_dialog.ShowModal() ' Show the Colour Dialog.
' After closing the Colour dialog, colour_data will contain
' data about selected colour, and any custom colours.
colour_data = colour_dialog.GetColourData()
' Colour selected for use from the Colour Dialog.
colour = colour_data.GetColour()
r.SetLabel(colour.red())
g.SetLabel(colour.green())
b.SetLabel(colour.blue())
end sub
connect( sel, wxEVT_COMMAND_BUTTON_CLICKED, "Set" )
Back to WxBasic Tutorial