Kandankarunai has asked for the wisdom of the Perl Monks concerning the following question:

How to add the image files(jpeg,png) in full surface of Tk NoteBook pages?

Replies are listed 'Best First'.
Re: Tk Notebook page Image
by vkon (Curate) on Apr 08, 2011 at 06:20 UTC
    are you asking on how to place image in notebook pages as decorations, so other widgets will be placed on that notebook above this image?
    or you're asking on how just to place image in notebook area?
      Dear Vkon, Yes.I am asking about how to place the image in notebook pages as decorationss so other widgets will be placed on that notebook above this image?
        What does that mean? Tk::NoteBook says
        -bitmap

        Specifies a bitmap to display on the tab of this page. The bitmap is displayed only if none of the -label or -image options are specified.

        -image

        Specifies an image to display on the tab of this page. The image is displayed only if the -label option is not specified.

        in my opinion - this is not possible.

        why do you want it, anyway?

Re: Tk Notebook page Image
by zentara (Cardinal) on Apr 08, 2011 at 16:44 UTC
    I don't know if I understand your problem correctly, but you will probably have to get the size of frame you want to display in, then resize your photo to fit exactly. Otherwise you would have to go to some vector graphics format, like .svg, which Tk dosn't handle, but Gtk2 does. Here is an example. See as you resize the app, the graphic will stay centered, and if you bind to the resize event, you can call a routine to resize your graphics, but the results may be jittery and slow.
    #!/usr/bin/perl use warnings; use strict; use Tk; use Tk::NoteBook; use Tk::JPEG; use MIME::Base64; my $mw = MainWindow->new; my $image = $mw->Photo(-data => get_photo() ); my $nb = $mw->NoteBook( -ipadx => 10, -ipady => 10, )->pack( -side => 'top', -expand => '1', -fill => 'both' ); for my $tab (qw/page1 page2 page3 page4 page5 page6/){ my $frame = $nb->add($tab, -label => $tab, ); $frame->Label(-text => $tab)->pack; $frame->Label(-text => 'a Label in '.$tab)->pack; $frame->Label(-image => $image) -> pack(-expand => 1, -fill =>'bo +th'); } MainLoop; #this method works as easy as it does, because #Tk needs it's images to be base64 encoded anyways, #use this to encode #my $file = shift; #open (FH,"< $file") or die $!; #my $photo = do {local $/; <FH>}; #my $content = encode_base64($photo) or die $!; #print $content; #don't forget to '' quote sub get_photo{ my $photo = '/9j/4AAQSkZJRgABAQIASABIAAD/2wBDAAgGBg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GDGkpse49VPP3Cnaxct6ar8WNUELW+HEkT5bUSK0t191QQ22gXKiTY +ACtFWR 0LQ0vqnh/qtayG3Sg2uEq9NW/wDugLEyX0XzHBw0KxDM8jDC4NRiRPj0+VXtfwD5rxHVLp +PiOUo/ 64nE14nDccCHXHEkONqPGrc3B7966qqMzBgcPMuAy8HnhRjSkaVaDYixBBHuCAfxWFTgpO +SW7K5N rBxFAaGlTvJ48U7Tmasrzsi5qfwmbct31NPWsHWz8qh/33BFJ1shaLs7qHiTpmwoOMRoz/ +8AUbai IfDQB3ukEnY882322tRUE9nTMDjzjjeKS46VqKvSYkOIQm+5skKsB7DaigPF0vMVpjH32p +ik8Q/b R5oCPrq3ofktnL+UGsYebviOJoDhUoboa+1I87KPe47VyvHSFyWkngrAP+a71jR24kVmMy +nS0yhL aE9kgWAoDbRRRQFc9ZsnR8zZJkzUpAn4W2qSy59SgC60n2IF/IHvXLkVZcjpJ5GxrrzqfN +dgdM8f fZ06zFLXxC+yyEH+FGuQIP7Fve9AW9Iw+JIfU7h+TJaoqrFsuy1sqO290FSrb3+p7+1FQK +HXEoAW UuqAtrW2gqPnaivld3BPGGcmkz//2Q=='; return $photo; }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh