Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

tcl::pTk GUI icons

by Anonymous Monk
on Apr 19, 2018 at 23:00 UTC ( [id://1213200]=perlquestion: print w/replies, xml ) Need Help??

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

Dear monks,

This may be a quite stupid question, but how can I use icons in a tcl GUI created with the tcl::pTk module (used to have a Tk syntax which I am familiar with). My tcl (8.5) is not the lates, and this version does not support png, as the following script demonstrates:

use strict; use warnings; use Tcl::pTk; my $mw = MainWindow->new(); foreach (1..10){ my $btn = $mw->Button( -text => "My command", -compound => 'top', -image => $mw->Photo(-file => 'start.png'), ); $btn->pack(-padx => 10, -pady => 10,); } MainLoop; exit(0);

I could use gif images, but I do not think it is common practice (and I can not make them look nice). What would be standard practice here? Unfortunately I couldn't find any practical advice around that fits my case. Any suggestion is welcome. I am on macOS.

Replies are listed 'Best First'.
Re: tcl::pTk GUI icons
by Anonymous Monk on Apr 19, 2018 at 23:11 UTC

    My tcl (8.5) is not the lates, and this version does not support png, as the following script demonstrates: I could use gif images, but I do not think it is common practice (and I can not make them look nice). What would be standard practice here? Unfortunately I couldn't find any practical advice around that fits my case. Any suggestion is welcome. I am on macOS.

    Use bitmaps (bmp)? Use jpegs? Upgrade to Tcl that supports png?

      It sounds like PNG support is added/improved in Tk 8.6.x (cf. https://wiki.tcl.tk/6150), so if it's possible to upgrade, I'd give that a try.

      The other approach out there for older Tcl/Tk might be to have either the Img, Pixane(no longer available?), or tkPng extension installed.

Re: tcl::pTk GUI icons
by Anonymous Monk on Apr 19, 2018 at 23:02 UTC

    I forgot the error message:

    couldn't recognize data in image file "start.png" at /Users/aa/perl5/p +erlbrew/perls/perl-5.18.3/lib/site_perl/5.16.3/Tcl/pTk/Widget.pm line + 332.

Log In?
Username:
Password:

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

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

    No recent polls found