GUI window

Heres my script.

How do I put a picture in it?#util to show picture in window
#version 1.0
#-colinok

#make window with box for picture

use Tk;

my $mw = new MainWindow;

$scrollbar = $mw -> Scrollbar();
$text = $mw -> Text(-height => 20, -width => 50, -yscrollcommand => ['set' => $scrollbar]);
$scrollbar -> configure(-command => ['yview' => $text]);

$scrollbar -> pack(-side => 'right', -fill => 'y');
$text -> pack(-side => 'left', -fill => 'both');

MainLoop;

Perleo,

Again I pulled out my "Mastering Perl/Tk - O'Reilly" and found the quickest solution - place the image in a button:

$image = $mw->Photo(-file => "bigredbutton.gif");
$mw->Button(-text => 'Exit', -command => sub { exit },
                   -image => $image)->pack;

Obviously you need to change the "bigredbutton.gif" to the image file you wish to use; not to mention that I haven't included the usual "MainLoop" bits, etc.

Hope this helps - and I still recommend the book mentioned above!

:slight_smile: :smiley:

Yea, I ran out of money on my holidays so I couldnt buy it, but I should have it by June.

Anyway,

Is this right?
When I run it the perl window pops up and disappers and thats it.use Tk;

my $mw = new MainWindow;

$scrollbar = $mw -> Scrollbar();
$text = $mw -> Text(-height => 20, -width => 50, -yscrollcommand => ['set' => $scrollbar]);
$scrollbar -> configure(-command => ['yview' => $text]);

$scrollbar -> pack(-side => 'right', -fill => 'y');
$text -> pack(-side => 'left', -fill => 'both');

$image = $mw->Photo(-file => "refinery.jpg");
$mw->Button(-text => 'Exit', -command => sub { exit },
-image => $image)->pack;

MainLoop;

perleo,

Sorry you're having trouble, but your code worked PERFECTLY on both my Unix and Windows machines!

Are you getting any error messages?

Are you waiting long enough for the TK window to appear?

How are you starting the program?

I got it, so how do i put text in the white box.

e,g i hit a button and text appears in the white box.

How do I do that ?