Re: Tk 9: image -format svg -scaletowidth not working?

Liste des GroupesRevenir à cl tcl 
Sujet : Re: Tk 9: image -format svg -scaletowidth not working?
De : mark (at) *nospam* qtrac.eu (Mark Summerfield)
Groupes : comp.lang.tcl
Date : 09. Jul 2024, 08:26:58
Autres entêtes
Message-ID : <16ucnaYr1PPfexH7nZ2dnZfqnPSdnZ2d@brightview.co.uk>
References : 1 2
User-Agent : Pan/0.154 (Izium; 517acf4)
On Mon, 08 Jul 2024 14:16:45 +0200, Ralf Fassel wrote:

* Mark Summerfield <mark@qtrac.eu>
[snip]
| Can someone tell me what I'm doing wrong?
>
| I'm using Tcl/Tk 9.0b2 on Debian Linux.
 
The manpage says:
 
  Image formats may support sub-options, which are specified using
  additional words in the value to the -format option.
 
This sounds to me as if you need to specify the additional options like
-scaletowidth *with* the -format option, like so:
 
  -format [list svg -scaletowidth 24]
 
instead of
 
  -format svg -scaletowidth 24

Thank you, I'm now using:

proc util::icon {svg {width 0}} {
    set opt [expr {$width ? [list -format [list svg -scaletowidth $width]]
\
        : ""}]
    image create photo -file $::PATH/images/$svg {*}$opt
}

And when I call this for menu items I use:

set width [expr {int(16 * [tk scaling])}]
...
    -image [util::icon new.svg $width]

The 'int' is *essential* since -scaletowidth won't accept a real.

I think adding support for SVG images is a real plus for Tk.

Date Sujet#  Auteur
8 Jul 24 * Tk 9: image -format svg -scaletowidth not working?9Mark Summerfield
8 Jul 24 `* Re: Tk 9: image -format svg -scaletowidth not working?8Ralf Fassel
8 Jul 24  +- Re: Tk 9: image -format svg -scaletowidth not working?1Harald Oehlmann
9 Jul 24  `* Re: Tk 9: image -format svg -scaletowidth not working?6Mark Summerfield
9 Jul 24   +- Re: Tk 9: image -format svg -scaletowidth not working?1Harald Oehlmann
9 Jul 24   `* Re: Tk 9: image -format svg -scaletowidth not working?4nemethi
9 Jul 24    `* Re: Tk 9: image -format svg -scaletowidth not working?3Mark Summerfield
9 Jul 24     `* Re: Tk 9: image -format svg -scaletowidth not working?2nemethi
10 Jul 24      `- Re: Tk 9: image -format svg -scaletowidth not working?1Mark Summerfield

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal