Tk Source Code

Artifact [5a7419dd]
Login

Artifact 5a7419dd0ff5f692bc099380b201687ce1cc19602f3ce8fe9eb3a3c4b41e40c4:

Attachment "pbar-test.tcl" to ticket [8bee4b20] added by bll 2021-06-18 16:58:43.
#!/usr/bin/tclsh

package require Tk

catch {package require tksvg}

set ::xyzzy 40
set imgdata {
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->

<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   width="30"
   height="14"
   viewBox="0 0 30 14"
   version="1.1"
   id="svg8"
   sodipodi:docname="slider-hn.svg"
   inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
   style="shape-rendering:crispEdges">
  <defs
     id="defs2" />
  <sodipodi:namedview
     id="base"
     pagecolor="#ffffff"
     bordercolor="#666666"
     borderopacity="1.0"
     inkscape:pageopacity="0.0"
     inkscape:pageshadow="2"
     inkscape:zoom="24.766586"
     inkscape:cx="15.000049"
     inkscape:cy="7.0000477"
     inkscape:document-units="px"
     inkscape:current-layer="layer1"
     showgrid="false"
     inkscape:window-width="1315"
     inkscape:window-height="617"
     inkscape:window-x="155"
     inkscape:window-y="185"
     inkscape:window-maximized="0"
     fit-margin-top="0"
     fit-margin-left="0"
     fit-margin-right="0"
     fit-margin-bottom="0"
     units="px"
     showguides="false"
     showborder="false"
     inkscape:pagecheckerboard="true" />
  <metadata
     id="metadata5">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
        <dc:title></dc:title>
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <g
     inkscape:label="Layer 1"
     inkscape:groupmode="layer"
     id="layer1"
     transform="translate(-97.353746,-141.48839)">
    <rect
       style="opacity:1;fill:#0044ff;fill-opacity:1;stroke:#222222;stroke-width:0.7;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
       id="rect815"
       width="13.3"
       height="29.3"
       x="141.98839"
       y="-126.85384"
       ry="0"
       transform="rotate(90)" />
  </g>
</svg>
}

set imga [image create photo -data $imgdata -format {svg -scale 0.8}]
set iheight [image height $imga]
puts "A: $iheight"
::ttk::style element create Horizontal.Progressbar.pbar image \
    [list $imga \
    disabled $imga] \
    -border {2 0} \
    -padding {0 0}

::ttk::progressbar .pb -orient horizontal -length 200 -mode determinate \
    -variable ::xyzzy
pack .pb
set ::x 0
after 1000 [list set ::x 1]
vwait ::x

set rc 1
puts "B: [winfo reqheight .pb] "
if { [winfo reqheight .pb] == $iheight + 2} {
  puts "OK"
  set rc 0
} else {
  puts "FAIL"
}
exit $rc