How can I set window background?

hi, I have problem when I want to set window background
I use this

@window = Window.new
@window.set_icon($icon)
@window.resizable=false
@window.set_title("XXX")

and if I want to set background color I will use

@window.modify_bg(STATE_NORMAL,Gdk::Color.new(254*254, 253*253,

236*236))

It work in color but I want image for background how can I do it??

On Sun, May 18, 2008 at 7:12 PM, Pat K.
[email protected] wrote:

@window.modify_bg(STATE_NORMAL,Gdk::Color.new(254254, 253253,
236*236))

It work in color but I want image for background how can I do it??

You might try an approach similar to:

http://www.perlmonks.org/?node_id=530173


Guillaume C. - http://zarb.org/~gc/

sub set_bg{

my $values;
my ($widget, $context, @other_params) = @_;
my $colormap = $window->get_default_colormap;
my $pixbuff = Gtk2::Gdk::Pixbuf->new_from_file(“figure.png”);
my $graphicContext = Gtk2::GC->get(Gtk2::Gdk::Visual->get_best_depth,
$colormap,
$values);
$pixbuff->render_to_drawable($widget->get_parent_window,
$graphicContext,
0,0,0,0,500,500,‘normal’,0,0);
}

what is “my ($widget, $context, @other_params) = @_”???
I don’t understand all above- -"
can you convert set_bg fuction to ruby language for me please :’(

with ‘my’ you initialize a variable

I hate perl syntax. :wink:

Ruby is a lot cleaner.

Define a function (def)

sub set_bg{

initialize values (variables)

my $values;

convert parameters to vars
usage is set_bg($widget,$context,@other_params) in perl

my ($widget, $context, @other_params) = @_;

with ‘my’ you initialize a variable (in object window are using a method
get_default_colormap

my $colormap = $window->get_default_colormap;

my $pixbuff = Gtk2::Gdk::Pixbuf->new_from_file(“figure.png”);
my $graphicContext = Gtk2::GC->get(Gtk2::Gdk::Visual->get_best_depth,
$colormap,
$values);
$pixbuff->render_to_drawable($widget->get_parent_window,
$graphicContext,
0,0,0,0,500,500,‘normal’,0,0);
}

what is “my ($widget, $context, @other_params) = @_”???
I don’t understand all above- -"
can you convert set_bg fuction to ruby language for me please :’(

Greets from Argentina!
By ToCaDo157

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs