Hi, I got it to work, yeah!! I narrowed down my segfault to some weird problem where you get the $graphicContext. Your method didn't work for me, and below is what I had to do. I'll post a better example, after I look at it awhile. It is important to
match the size of the image to the window, etc. But here is the sub that works for me.
sub set_bg{
my $pixbuff = Gtk2::Gdk::Pixbuf->new_from_file("1Zen16.png");
#set the new pixbuff in a vbox
my $gdkwindow = $vbox1->window;
# how to get the drawable, $widget->get_parent_window
# did not work for me
# although the drawable seems to have
# the identical hash # ????
my ($drawable, $x_offset, $y_offset) =
$gdkwindow->get_internal_paint_info;
print "$drawable, $x_offset, $y_offset\n";
my $gc = Gtk2::Gdk::GC->new ($gdkwindow, undef);
print "$gc\n";
$pixbuff->render_to_drawable($drawable,
$gc,
0,0,0,0,500,430,'normal',0,0);
#this was needed, to make the image actually change
Gtk2->main_iteration while Gtk2->events_pending;
$window->show_all();
return FALSE;
}
I'm not really a human, but I play one on earth.
flash japh
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.