Perl Tk::Photo help

cerbere

New Member
Messages
51
Reaction score
1
Points
0
Hi everyone,

I'm trying to use the Tk::photo class, but the documentation
is very scarse. All I can find is

http://search.cpan.org/dist/Tk/pod/Photo.pod

with it's strange syntax like

$widget->Photo(?name??, options?)

and no examples of use at all.
The following code works, but I have no idea why I must
put the Photo into a Label :

Code:
use Tk;
use Tk::JPEG;
my $MW = new MainWindow;

$MW ->Label(-text => 'Tk Photo')->pack;
$image_tk = $MW->Photo('img', -format=>'jpeg', 
                   -file => "c:/someimage.JPG");
$MW->Label(-image => $image_tk)->pack(-side=>'left');

$MW->Button(-text => 'exit',
            -command => sub{exit} )
   ->pack(-side => 'bottom');
MainLoop;

Anyone knows a friendlier intro to Tk::photo ?
A cookbook maybe ?

As the Perl doc often reminds me, I'm a poor loser
forced to program on a Win32 box... :pigeon:)

Thanks for any help !
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
Basically, you ad whatever you add stuff to a label or other class (see second link), and then pack/display it. The second link is probably my favorite for reference of the ones I've found. The third has some okay sample code.

http://www.lehigh.edu/~sol0/ptk/perlmonth01/pm1.html
http://www.ida.liu.se/~tompe/perltk/index.html
http://www.geocities.com/binnyva/code/perl/perl_tk_tutorial/


This link is probably the most helpful to you:
http://search.cpan.org/src/MARKOV/PPresenter-1.17/doc_html/image/tkphoto.html
 
Last edited:

cerbere

New Member
Messages
51
Reaction score
1
Points
0
Thanks for the feedback, vol7ron, but I couldn't find any
help in the references you cited :pigeon:(
 

cerbere

New Member
Messages
51
Reaction score
1
Points
0
Vol7ron, I am not looking for a Tk tutorial,
but for specific information (with examples if possible)
about the Tk::photo object.
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
Well I don't know how simpler you can get than what you've already posted/said.

Photos
The perl/Tk Photo() function achieves an effect similar to the Bitmap() function. Namely, it returns a file descriptor to be used in a later -image configuration option to a widget.

As an example consider the Label widget that uses the 'imggif' descriptor in the following:
Code:
   #!/usr/bin/perl -w
   use strict;
   use Tk;
   my $main = new MainWindow;
   $main->Photo(
      'imggif'
      , -file  => "$Tk::tk_library/demos/images/earthris.gif"
   );

   my $c = $main->Label( '-image'=>'imggif' )->pack;

   $main->Button(
      -text    => 'exit',
      -command => sub{destroy $main}
   )->pack(-anchor => 'e');

   MainLoop;

img/photo_earthris.gif
 
Last edited:

cerbere

New Member
Messages
51
Reaction score
1
Points
0
After a lot of Googling, I think I'll manage.

Please close this thread.
 

vol7ron

New Member
Messages
434
Reaction score
0
Points
0
at least post what you found. i'm thinking your problem is understanding Perl and not the Tk module.

the link you gave from cpan gives all the properties of handling an image and all the links i gave you are examples of how to create and add one to a page. forgive me for trying to help and not seeming to answer your concern, but i don't know how else to help.

if you don't need a tutorial, i take it that you know how to create a photo/image.



I'm trying to use the Tk::photo class, but the documentation is very scarse. All I can find is http://search.cpan.org/dist/Tk/pod/Photo.pod
Besides providing more code, this describes everything about the module, I'm not sure what other documentation you could want?

with it's strange syntax like $widget->Photo(?name??, options?) and no examples of use at all.
That's a really small example. So I have you a bunch of sites with examples and tutorials that explain them and then you say you don't need tutorials... that makes no sense

The following code works, but I have no idea why I must
put the Photo into a Label: <code was here> ...
Anyone knows a friendlier intro to Tk::photo ?
A cookbook maybe ?
Again, you asked in different words for a detailed tutorial,which I gave you. Granted, it was on the tk module as a whole, but you weren't understanding that you had to add the image to a widget, so I showed you a tutorial on widgets. how can you do square roots if you don't understand multiplication; meaning, you're not grasping the module and you need to know the other stuff before working with that. i still gave an example of adding the photo to the label widget and in one of my links i showed you the different widgets you can add a photo to.


please tell me what you found on Google so we can hopefully use it (for ourselves) or to educate people in the future
 
Last edited:
Top