class iFrame(wx.Frame):
def __init__(blah blah blah):
wx.Frame.__init.__(blah blah blah)
self.panel = wx.Panel(self, -1)
self.panel.SetBackgroundColour((I put a random RGB here for test purposes))
c_color = wx.Button(self.panel, -1, 'Press To Change Color')
c_color.Bind(wx.EVT_BUTTON, self.OnCC)
def OnCC(self, evt):
dlg = wx.ColourDialog().SetChooseFull(1)
if dlg.ShowModal() == wx.ID_OK:
data = dlg.GetColourData()
color = data.Colour
print (color) # I did this just to test it was returning a RGB
self.panel.SetBackgroundColour(color)
dlg.Destroy()
What I’ve tried to do was link a button to a color dialog, store the RGB in a variable and use it to set the panel’s background color…I’ve tested almost all of this, I’ve inserted the returned RGB directly into the self.panel itself and it works, so why doesn’t it work when I use it within this method
The line
dlg = wx.ColourDialog().SetChooseFull(1)seems like a bug — isn’tSetChooseFulla method onwx.ColourData?I made a few changes to get it working and commented the code to illustrate:
The
data.SetCustomColor(index, color)populates theNcustom colors in the dialog. I’ve circled the one at index0below: