deadpickle has asked for the wisdom of the Perl Monks concerning the following question:
#just some simple code, not tested my $window = Gtk2::Window->new( 'toplevel'); my $button = Gtk2::Button->new( 'NEW'); $window->add( $button); Gtk2->main;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Gtk2: changing Button Color
by zentara (Cardinal) on Aug 21, 2007 at 11:39 UTC | |
Basically, a gtk2 app will check the theme settings in ~.gtk2rc-2.0 and holds onto them for dear life. Some you can override, but you generally need to override the theme settings explicitly, before you can change them. The following script tries to demonstrate it. My rc parsing dosn't seem to work for Buttons(for me anyways), but will work on window widgets. Anyways, I try to override the existing theme, then make new settings,but the override dosn't work. As proof of this, rename your .gtkrc-2.0 to .gtkrc-2.0zzz and run the script, and you will see the button color change. So...... what you probably need to do, is setup a custom .gtkrc-2.0 for your app, and at the very start of your script, parse your custom rc settings. I would guess that you would have to setup a resource directory for your script, and put your custom .gtkrc-2.0 in there. Like I said, try this after renaming your .gtkrc-2.0 and see the difference. I've included a second sample below, to show how to override a background pixmap. Read more... (5 kB)
I'm not really a human, but I play one on earth. Cogito ergo sum a bum | [reply] [d/l] |
|
Re: Gtk2: changing Button Color
by Anonymous Monk on Aug 21, 2007 at 06:18 UTC | |
http://gtk2-perl.sourceforge.net/doc/examples/colorbutton-full.pl.html http://gtk2-perl.sourceforge.net/doc/subclassing_widgets_in_perl.html http://mail.gnome.org/archives/gtk-perl-list/2004-April/msg00021.html | [reply] |
by deadpickle (Pilgrim) on Aug 21, 2007 at 07:01 UTC | |
| [reply] [d/l] |
by Anonymous Monk on Aug 21, 2007 at 10:04 UTC | |
| [reply] |
|
Re: Gtk2: changing Button Color
by zentara (Cardinal) on Aug 22, 2007 at 12:32 UTC | |
I'm not really a human, but I play one on earth. Cogito ergo sum a bum | [reply] [d/l] |
by zentara (Cardinal) on Aug 24, 2007 at 16:41 UTC | |
Anyways, you can use a BEGIN block, or set the ENV and require Gtk2 instead of use to load it. What this script does, is load an empty gtkrc file (in the cwd), and it overrides the theme in the /home/user/.gtkrc-2.0 file. Thus making button color changes possible.
I'm not really a human, but I play one on earth. Cogito ergo sum a bum | [reply] [d/l] |