impossible to change colour of button

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
scoint

impossible to change colour of button

Post by scoint »

Hi,
I have a script that was working perfectly with Mint 16 Cinnamon and no more in Mint 17 Cinnamon.
With Mint 17, I can't change the colour of button but I can change the colour of panel (see attached file). I tried several themes and it's the same in all of them.
The script is in python2.7 and wxpython2.8 :

Code: Select all

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import wx


#constant The colour I want for the panel and the button
NormColor="green"



class MyFrame(wx.Frame):
    """ We simply derive a new class of Frame. """
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, pos=(20,20), size=(100,100))
        self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
        self.NetworkButton=wx.Button(self, -1, "OK")
        self.NetworkButton.SetBackgroundColour(NormColor) #Apply the colour to the button
        self.sizer2.Add(self.NetworkButton, 0)
        self.SetBackgroundColour(NormColor) #Apply the colour to the window
        self.SetSizer(self.sizer2)
        self.Show(True)


app = wx.App(False)
frame = MyFrame(None, 'Alert Window')
app.MainLoop()
My only problem is the button's colour (I'm able to enable/disable button). What settings do I have to change to allow my script to change button's colour.

thanks for your help
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
scoint

Re: impossible to change colour of button

Post by scoint »

Hi,

this script works with Mint 16 so it's a change in behavior between Mint 16 and Mint 17. Is it possible that Mint 17 is more restrictive than Mint 16 and don't allow a button to have a color different from those define in the theme?
scoint

Re: impossible to change colour of button

Post by scoint »

Hi,

I made an interresting test. I'm using the Mint theme so in /usr/share/themes/Mint-X/gtk-2.0/styles I rename the file buttons.rc and when I run my script, I have an error message about the button.rc file missing (which is "normal") but my button got the right color !!!! unfortunately, all the buttons are now flat.
I was try to modify the buttons.rc file to "remove" the fixed colour and keep the other behaviour but uncessfully.

Could someone tell me how to change the styles to allow buttons to change their background?

Regards
LesStrater

Re: impossible to change colour of button

Post by LesStrater »

There is a Images folder in the GTK-2.0 folder which contains button images that are scaled to suit the application. You will have to change the image color with a graphics program to whatever you want. But if you do this, that button color will appear on every button in the Mint-X theme, not just in the program you are writing. So it's best to make a copy of the button image, rename it to something like "button-green.svg", edit its color to what you want, then call the new image in yuur program. Most of those button images are vector graphics so they scale perfectly - so you will have to edit them with Inkscape, not Gimp.
scoint

Re: impossible to change colour of button

Post by scoint »

Hi,

Thanks for your answer.

Regards

Stephan
Locked

Return to “Cinnamon”