Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Tk vs Tcl::pTk speed image

by Anonymous Monk
on Apr 06, 2018 at 03:33 UTC ( #1212398=perlquestion: print w/replies, xml ) Need Help??

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

Dear Monks

I am trying to adapt my Tk program using Tcl::pTk which I find a very interesting module to revamp the use of Tk in Perl (modern interface, etc.). I could port most of my old UI and it works fine. What I am struggling with are speed issues with my icons. In standard Tk everything is quick, loading the same set of icons (png) with Tcl::pTk takes ages. As both module should be a layer on Tk, I do not quite understand the big difference (10x time in pTk). You can almost take a coffee in the time the GUI is ready.

My exosystem: Windows 10 and Activeperl 5.16 (I wasn't able to make Tcl::pTk work with Strawberryperl....).

Here a small script to make the point

use Tcl::pTk; #use Tk;#using this instead of Tcl::pTk it is 10x/20x quicker #use Tk::PNG; my $mw = MainWindow->new(); my $lab = $mw->Label(-text => "Hello world")->pack; foreach (1..30){ my $PngSettings = $mw->Photo( -file => "settings.png"); $mw->Button(-image => $PngSettings, -command => sub { $lab->configure(-text=>"[". $lab->cget('-text')."]"); }, -borderwidth => '0', )->pack(-side=>'right', -anchor => 'e', -padx=>5, -pady=>5); } MainLoop;

Am I missing something? It is a shame that it seems practically nobody is using this module as there is almost nothing out there about Tcl::pTk (besides the good POD)

Replies are listed 'Best First'.
Re: Tk vs Tcl::pTk speed image
by Anonymous Monk on Apr 06, 2018 at 07:38 UTC


    I find no speed difference between the two

    tcl_version 8.6 tcl_patchLevel 8.6b1.2 tk_version 8.6 tk_patchLevel 8.6b1.2 tk_library C:/Tcl8.6/lib/tk8.6 Tcl::pTk 0.90 Tcl 1.02 Tk 804.033 Perl $^V v5.16.1 Perl $] 5.016001

      Thank you for pointing out how to get info about the Tcl installation (I am a newbee with Tcl!). It turns out I am using an older version (actually I never installed Tcl. My version must come together with Tcl::pTk?!?). With my ecosystem I can create an .exe with PerlApp without problems (beside the speed problem which is not bearable).

      tcl_version 8.5 tcl_patchLevel 8.5.13 tk_version 8.5 tk_patchLevel 8.5.13 tk_library C:/Perl/lib/auto/Tcl/tkkit.dll/lib/P-win32-ix86/tk8.5 Tcl::pTk 0.92 Tcl 1.02 $^V v5.16.3 $] 5.016003

      I'll try to find out how update Tcl (and make it work together with PerlApp which I fear it will not be easy...). How can you tell Tcl::pTk WHERE to look for Tcl? I can not find any mention of this.

      Which Tcl distribution are you using? I cannot replicate your ecosystem no matter how I try...

Re: Tk vs Tcl::pTk speed image
by Anonymous Monk on May 17, 2018 at 17:24 UTC

    I am still fighting with this: if I point to a Tcl installation different to the ActivePerl Tkkit.dll, I get an error message:

    #!/usr/bin/perl BEGIN { #my $frameworkpath = "C:/tkkit.dll";#If I use this, it works my $frameworkpath = "C:/ActiveTcl/bin/tk86t.dll"; print $ENV{'PERL_TCL_DL_PATH'} = $frameworkpath; } use strict; use warnings; use Tcl::pTk; my $int = new Tcl::pTk; $int->Eval(<<'EOS'); # pure-tcl code to create widgets (e.g. generated by some GUI builder) text .e ## .e insert end "tcl_version $tcl_version\n" .e insert end "tcl_patchLevel $tcl_patchLevel\n" .e insert end "tk_version $tk_version\n" .e insert end "tk_patchLevel $tk_patchLevel\n" .e insert end "tk_library $tk_library\n" pack .e EOS my $e = $int->widget('.e'); # get .e entry into play $e->insert( "end", " Tcl::pTk $Tcl::pTk::VERSION Tcl $Tcl::VERSION \$^V $^V \$] $] "); $int->MainLoop;


    NpLoadLibrary: could not find Tcl library at 'C:/ActiveTcl/bin/tk86t.d +ll' at C:/Perl/site/lib/ line 114. Failed to load Tcl dll! at C:/Perl/site/lib/ line 114. Unable to initialize Tcl at C:/Perl/site/lib/ line 114. Compilation failed in require at C:/Perl/site/lib/Tcl/ line 6. BEGIN failed--compilation aborted at C:/Perl/site/lib/Tcl/ line +6. Compilation failed in require at .\ line 10. BEGIN failed--compilation aborted at .\ line 10.

    What am I doing wrong?

      What am I doing wrong?

      You forgot to recompile/reinstall against the 8.6 version of Tcl. You can't simply point at the newer dll when its expecting the old one.

        thank you. I am starting to grasp the "behind the scenes"... However, I stillave problems in operationalizing it: in the module documentation I read:

        Second method Copy installed Tcl/Tk binaries to some location, then install Perl mod +ule Tcl with a special action to make know of this location. This appro +ach makes sure that only chosen Tcl installation is used.

        No mention however how to accomplish it. Google doesn't help too. I am surely not very fit in this kind of things, but a bit more documentation would help. So, I again would very much appreciate any suggestion

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2022-12-01 05:51 GMT
Find Nodes?
    Voting Booth?