+ Reply to Thread
Results 1 to 8 of 8

Thread: Perl Tk::Photo help

  1. #1
    cerbere is offline x10Hosting Member cerbere is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    51

    Perl Tk::Photo help

    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... :>)

    Thanks for any help !

  2. #2
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: Perl Tk::Photo help

    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/cod...l_tk_tutorial/


    This link is probably the most helpful to you:
    http://search.cpan.org/src/MARKOV/PP...e/tkphoto.html
    Last edited by vol7ron; 12-11-2008 at 03:55 PM.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  3. #3
    cerbere is offline x10Hosting Member cerbere is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    51

    Re: Perl Tk::Photo help

    Thanks for the feedback, vol7ron, but I couldn't find any
    help in the references you cited :>(

  4. #4
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: Perl Tk::Photo help

    are you sure you went through all the pages of the third link? make sure you click the "next" button until the tutorial begins.

    http://www.geocities.com/binnyva/cod...l_tk_tutorial/
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  5. #5
    cerbere is offline x10Hosting Member cerbere is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    51

    Re: Perl Tk::Photo help

    Vol7ron, I am not looking for a Tk tutorial,
    but for specific information (with examples if possible)
    about the Tk::Photo object.

  6. #6
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: Perl Tk::Photo help

    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 by vol7ron; 12-16-2008 at 09:42 PM.
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


  7. #7
    cerbere is offline x10Hosting Member cerbere is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    51

    Re: Perl Tk::Photo help

    After a lot of Googling, I think I'll manage.

    Please close this thread.

  8. #8
    vol7ron's Avatar
    vol7ron is offline x10 Lieutenant vol7ron is an unknown quantity at this point
    Join Date
    Mar 2008
    Location
    DC
    Posts
    434

    Re: Perl Tk::Photo help

    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.



    Quote Originally Posted by cerbere View Post
    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?

    Quote Originally Posted by cerbere View Post
    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

    Quote Originally Posted by cerbere View Post
    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 by vol7ron; 12-19-2008 at 11:03 AM. Reason: Automerged Doublepost
    If you find my post useful please add to my reputation by clicking the +Rep button
    You may also use the Donate link to donate credits - this is appreciated too Thanks to those whom have donated so far!


+ Reply to Thread

Similar Threads

  1. Some very usfull links for php & perl.
    By DefecTalisman in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 12-11-2008, 07:49 PM
  2. Internal Server Error FOR Perl script
    By radofeya in forum Free Hosting
    Replies: 0
    Last Post: 04-14-2008, 01:06 PM
  3. Help with PERL code
    By oiwio in forum Programming Help
    Replies: 8
    Last Post: 12-12-2007, 07:38 AM
  4. To all those using Perl and CGI
    By DefecTalisman in forum Free Hosting
    Replies: 0
    Last Post: 09-16-2007, 03:56 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers