I want to create an image in a wx Python application with the colour of the background.
[EDIT] On Windows this works perfectly:
[/EDIT]
but on linux my code gives a paler colour. What am I doing wrong?
[EDIT: more information]
The colour returned by self.GetBackgroundColour() is (225, 225, 225); the paler colour. The actual background colour is (212, 212, 212)
[\EDIT]
Here is an image taken using a different theme:
So based on Rolf's answer below it looks like an issue with Mate and not the theme
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'Image')
sizer = wx.BoxSizer()
static_bitmap_A = wx.StaticBitmap(self, wx.ID_ANY)
bitmap = wx.Bitmap('any.png')
static_bitmap_A.SetBitmap(bitmap)
sizer.Add(static_bitmap_A, flag=wx.ALL, border=10)
image = wx.Image('any.png')
colour = self.GetBackgroundColour()
red, green, blue = colour[0], colour[1], colour[2]
#red, green, blue = 0, 0, 0
for row in range(image.GetSize()[0]):
for column in range(image.GetSize()[1]):
image.SetRGB(row, column, red, green, blue)
bitmap = wx.Bitmap(image)
static_bitmap_B = wx.StaticBitmap(self, wx.ID_ANY)
static_bitmap_B.SetBitmap(bitmap)
sizer.Add(static_bitmap_B, flag=wx.ALL, border=10)
self.SetSizerAndFit(sizer)
self.Show()
if __name__ == '__main__':
screen_app = wx.App()
main_frame = MainFrame()
screen_app.MainLoop()
Any image can be used in place of any.png