def on_button_press(self, event):
dialog = wx.ColourDialog(self.panel)
if dialog.ShowModal() == wx.ID_OK:
colour = dialog.GetColourData()
hex_colour = colour.Colour.GetAsString(flags=wx.C2S_HTML_SYNTAX)
self.panel.SetBackgroundColour(colour.Colour)
self.panel.Refresh()
self.text.SetLabel(hex_colour)
self.panel.Layout()
col = colour.Colour
if (col.red * 0.299 + col.green * 0.587 + col.blue * 0.114) > 186:
self.text.SetForegroundColour('black')
else:
self.text.SetForegroundColour('white')
self.event({'colour': colour.Colour, 'hex': hex_colour, 'key': self.key})
评论列表
文章目录