impossible to change colour of button

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon

impossible to change colour of button

Postby scoint on Fri Aug 15, 2014 9:45 pm

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
Attachments
ButtonPython.JPG
hardcopy
ButtonPython.JPG (9.9 KiB) Viewed 316 times
scoint
Level 1
Level 1
 
Posts: 8
Joined: Tue Aug 05, 2014 4:07 am

Linux Mint is funded by ads and donations.
 

Re: impossible to change colour of button

Postby scoint on Sun Aug 24, 2014 3:37 am

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
Level 1
Level 1
 
Posts: 8
Joined: Tue Aug 05, 2014 4:07 am

Re: impossible to change colour of button

Postby scoint on Sun Aug 24, 2014 4:51 am

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
scoint
Level 1
Level 1
 
Posts: 8
Joined: Tue Aug 05, 2014 4:07 am

Re: impossible to change colour of button

Postby LesStrater on Tue Aug 26, 2014 9:28 pm

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.
Using Google Chrome is equivalent to buying your food at a grocery store owned by Monsanto.
LesStrater
Level 1
Level 1
 
Posts: 29
Joined: Wed Aug 20, 2014 12:39 am

Re: impossible to change colour of button

Postby scoint on Tue Sep 02, 2014 7:35 am

Hi,

Thanks for your answer.

Regards

Stephan
scoint
Level 1
Level 1
 
Posts: 8
Joined: Tue Aug 05, 2014 4:07 am


Return to Cinnamon

Who is online

Users browsing this forum: 1212094, gsagostinho and 11 guests