To start with, you're better off using the gtk2-perl list for
gtk2-perl-related questions.
On Mon, 2007-12-03 at 10:57 -0800, robertospara wrote:
> Hi.I found problem in Gtk2::Perl with module Gtk2::SimpleList.
> I want to have selection bar in different colors.Not only orange but
> red blue and others. Sample code produce SimpleList and with moving up
> and down keys
> I move with this "orange bar" which I call "select-bar" up and down.
> How to change this color?Please for help or any advices.
The colour of the selected row is defined in your Gtk2 theme. Your code
has absolutely no mention of colours. You can specify colours for each
cell's background & foreground colours if you like.
For a simple example, you can do something like:
---
#!/usr/bin/perl -w
use Data::Dumper;
use Gtk2 '-init';
use Gtk2::SimpleList;
$window = Gtk2::Window->new;
$window->set_title ('SimpleList examples');
$window->signal_connect (delete_event => sub {Gtk2->main_quit; TRUE});
$hbox = Gtk2::HBox->new;
$window->add ($hbox);
$categories = Gtk2::SimpleList->new ('Categories' => 'text');
# Grab the 1st column
my $column = $categories->get_column( 0 );
# Get a list of renderes in the 1st column
my @renderers = $column->get_cell_renderers;
# In our case, we only have 1 renderer. Get it
my $renderer = $renderers[0];
# Set the background to red ...
$renderer->set( background => "blue" );
# ... and the foreground to yellow
$renderer->set( foreground => "yellow" );
@{$categories->{data}} = qw/Meat Beer Pizza Pasta Soda Juice
Rabbitfood/;
$hbox->pack_start ($categories, FALSE, FALSE, 0);
$window->show_all;
Gtk2->main;
---
Sorry about the text wrapping ...
For more control over the colouring / formatting / etc, you should set a
custom cell data function, as in:
http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/TreeViewColumn.html#_tree_column_set_cel
This allows you to set things based on the data in your row / column.
Note that your Gtk2 theme will STILL override this for the currently
selected row, which is a pain, but I haven't found a way around it
yet ...
--
Daniel Kasak
IT Developer
NUS Consulting Group
Level 5, 77 Pacific Highway
North Sydney, NSW, Australia 2060
T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989
email: [EMAIL PROTECTED]
website: http://www.nusconsulting.com.au
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/