Python wx.ColourData() Examples

The following are 5 code examples of wx.ColourData(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: core.py    From wafer_map with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, id=-1, colour=wx.BLACK,
                         pos=wx.DefaultPosition, size=wx.DefaultSize,
                         style = CLRP_DEFAULT_STYLE,
                         validator = wx.DefaultValidator,
                         name = "colourpickerwidget"):
                
                wx.BitmapButton.__init__(self, parent, id, wx.Bitmap(1,1), 
                                         pos, size, style, validator, name)
                self.SetColour(colour)
                self.InvalidateBestSize()
                self.SetInitialSize(size)
                self.Bind(wx.EVT_BUTTON, self.OnButtonClick)
                
                global _colourData
                if _colourData is None:
                    _colourData = wx.ColourData()
                    _colourData.SetChooseFull(True)
                    grey = 0
                    for i in range(16):
                        c = wx.Colour(grey, grey, grey)
                        _colourData.SetCustomColour(i, c)
                        grey += 16 
Example #2
Source File: ColourSelectButton.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def OnButton(self, event):
        colourData = wx.ColourData()
        colourData.SetChooseFull(True)
        colourData.SetColour(self.value)
        for i, colour in enumerate(eg.config.colourPickerCustomColours):
            colourData.SetCustomColour(i, colour)
        dialog = wx.ColourDialog(self.GetParent(), colourData)
        dialog.SetTitle(self.title)
        if dialog.ShowModal() == wx.ID_OK:
            colourData = dialog.GetColourData()
            self.SetValue(colourData.GetColour().Get())
            event.Skip()
        eg.config.colourPickerCustomColours = [
            colourData.GetCustomColour(i).Get() for i in range(16)
        ]
        dialog.Destroy()
        evt = eg.ValueChangedEvent(self.GetId(), value = self.value)
        wx.PostEvent(self, evt) 
Example #3
Source File: panel_monitor.py    From RF-Monitor with GNU General Public License v2.0 5 votes vote down vote up
def __on_colour(self, _event):
        colourData = wx.ColourData()
        colourData.SetChooseFull(True)
        colourData.SetColour([level * 255 for level in self._colour])
        for i in range(len(self._colours)):
            colour = [level * 255 for level in self._colours[i]]
            colourData.SetCustomColour(i, colour)

        dlg = CubeColourDialog(self, colourData)
        if dlg.ShowModal() == wx.ID_OK:
            colour = dlg.GetColourData().GetColour()
            colour = [level / 255. for level in colour]
            self.set_colour(colour)
            event = Event(Events.CHANGED)
            post_event(self._eventHandler, event) 
Example #4
Source File: cfgdlg.py    From trelby with GNU General Public License v2.0 5 votes vote down vote up
def OnChangeColor(self, event):
        cd = wx.ColourData()
        cd.SetColour(getattr(self.cfg, self.color).toWx())
        dlg = wx.ColourDialog(self, cd)
        dlg.SetTitle(self.colorsLb.GetStringSelection())
        if dlg.ShowModal() == wx.ID_OK:
            setattr(self.cfg, self.color,
                    util.MyColor.fromWx(dlg.GetColourData().GetColour()))
        dlg.Destroy()

        self.cfg2gui() 
Example #5
Source File: params.py    From admin4 with Apache License 2.0 5 votes vote down vote up
def OnLeftDown(self, evt):
        data = wx.ColourData()
        data.SetColour(self.GetValue())
        dlg = wx.ColourDialog(self, data)
        if dlg.ShowModal() == wx.ID_OK:
            self.SetValue('#%02X%02X%02X' % dlg.GetColourData().GetColour().Get())
            self.SetModified()
        dlg.Destroy()

################################################################################

# Mapping from wx constants to XML strings