Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Can we apply a background Image to widget in perl tk

by vr786 (Sexton)
on Dec 16, 2010 at 10:44 UTC ( [id://877468]=perlquestion: print w/replies, xml ) Need Help??

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

Hi Monks, I have tried to apply a background image to a Embedded Frame , but it is not visible and there is any other ways is there to apply the same.

#!/usr/bin/perl -w use Tk; use strict; use warnings; use Tk::LabFrame; use Tk::JPEG; use Tk::PNG; my $mw = MainWindow->new; $mw -> geometry ("400x400+100+120") ; $mw -> CmdLine; my $chk = 0; my @GUI_List; my $var; my $f1 = $mw -> LabFrame(-label=> "Select one Test",-font=> 'ukai',-la +belside => "acrosstop")->pack(); my $s300 = $f1->Radiobutton(-text=>"TEST1",-value=>"do_1",-indicator=> +1,-variable=>\$chk,-font=>'ukai 11',-command=>\&do_1)->pack(); $s300->configure(-state); my $s310 = $f1->Radiobutton(-text=>"TEST2",-value=>"do_2",-indicator=> +1,-variable=>\$chk,-font=>'ukai',-command=>\&do_2)->pack(); $s310->configure(-state); $f1 -> place ( -x => 40 , -y => 50, -width=>"140", -height => "100" ); my $f2 = $mw -> LabFrame(-label => "Selet One",-font=> 'ukai',-labelsi +de => "acrosstop")->pack(); my @INP_List = (qw/TES0 TES1 TES2 TES3 TES4 TES5 TES6 TES7 TES8 TES9/) +; my $lb = $f2 -> Scrolled("Listbox", -scrollbars => "e",-selectmode => +"extended",-font=> 'ukai',-activestyle => "dotbox")->pack(); $lb -> bind('<Double-1>'=> sub { my $temp = $_[0]->get($_[0]->curselection),; print "$temp\n" }, ); $lb->bind('<Up>',sub {move_cursor_up();}); $lb->bind('<Down>',sub {move_cursor_down();}); $lb->bind('<Return>',sub {enter_press();}); $f2 -> place ( -x => 220 , -y => 50, -width =>"160", -height => "80"); if ( -e "bgclo.jpg") { #if bgimage graphic exists , use it $f1->update(); my $canvas2 = $f1->Canvas->pack(-expand=>1,-fill=>'both'); my $bg_img2 = $f1 -> Photo(-file=>'bgclo.jpg'); $canvas2->createImage(0,0, -image => $bg_img2, -anchor => 'nw', -tags => ['img'], ); } MainLoop; sub do_1 { if ($chk eq "do_1" ) { $lb->delete(0,'end'); @GUI_List = @INP_List[0,1,2,3,4]; $lb->insert('end',@GUI_List); print "@GUI_List\n"; } } sub do_2 { if ($chk eq "do_2") { $lb->delete(0,'end'); @GUI_List = @INP_List[5,6,7,8,9]; $lb -> insert('end', @GUI_List); print "@GUI_List\n"; } }

Replies are listed 'Best First'.
Re: Can we apply a background Image to widget in perl tk
by Khen1950fx (Canon) on Dec 16, 2010 at 11:41 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://877468]
Approved by rovf
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found