Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Tk programmatically monitor change in Listbox

by Anonymous Monk
on Jan 07, 2020 at 04:21 UTC ( [id://11111102]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Tk programmatically monitor change in Listbox
in thread Tk (Tcl::Tk) programmatically monitor change in Listbox

The original code posted in this thread is in Tk because I want(ed) to find a solution to my proposed approach - which is indipendent to Tcl.

Here is a rule of thumb, whenever you're 100% sure the boundary you're crossing isn't relevant, but you can't write the solution -- the boundary is critical.

Tcl::Tk needs to be in your title to attract Courage/VKON

  • Comment on Re^3: Tk programmatically monitor change in Listbox

Replies are listed 'Best First'.
Re^4: Tk programmatically monitor change in Listbox
by IB2017 (Pilgrim) on Jan 07, 2020 at 11:22 UTC

    Thanks for the comment. The colleague originally working on this function already posted a question regarding the possibility to call a Perl subroutine from $int->Eval(); on the tcltk@perl.org group. It seems it is possible to run Perl code from within $int->Eval(); with the Tcl command ::perl::Eval, however not a Perl subroutine that lives outside the $int->Eval();. Since I have 0 knowledge of Tcl and no experience in "language bridging", I was hoping to solve the issue simply by monitoring the change in the Listbox state/values. There are a couple of suggestion in other answers here that I am now examining.

        Some addition to the relation Tk/Perl/Tcl:

        • Perl/Tk is a ported version of Tk which is independent from Tcl. In fact, you simply install it from cpan, with no need of a Tcl installation.
        • On the contrary, Tcl::Tk and Tcl::pTk use a real installation of Tcl/Tk present on the machine. The bridge Perl to Tcl (and vice versa) is done by the Tcl module which is a required dependency of both modules mentioned before. Both modules are similar, being Tcl::pTk more focused on using a syntax which is 1=1 to Perl/Tk (in fact you can run Perl/Tk applications with no or minimal adaptation)

        On a side note: if Perl/Tk is a fantastic module for out-of-the-box UI projects, the advantages of using Tcl::Tk or Tcl::pTk are:

        • You use with Perl the real Tcl/Tk. This allows to use the latest release, which is continuously updated (for example to accommodate the latest macOS features).
        • It allows deployment on macOS (Catalina too) with native widgets and macOS look&feel (Tk on macOS requires X11 installed, and looks "very old"). UI looks modern both on Windows and on macOS. I guess the same applies to Linux too.

        I 've started to write an extensive guide on how to deploy modern Perl+Tcl/Tk application for Windows and macOS (setup/coding/packaging/code signing/etc.). I will post here a link when I am finished (in some weeks time). Maybe somebody will find it useful.

        What a joy! This solves our problem at the root(not the topic of the thread) in a much better way than I hoped. To call a Perl subroutine from within the Tcl code is very simple (the Tcl is really great indeed!):

        use Tcl::Tk; my $mw = MainWindow; my $int = $mw->interp; $int->CreateCommand("MySubroutine", \&MySubroutine); $int->Eval(); sub MySubroutine{ ... } Mainloop;
        TK runs under TCL, there is nothing you do in TK that is independent from TCL.

        While the questioner turns out to be using Tcl, there is also a Tk module on CPAN that bundles a modified Tk (called "pTk") that is not dependent on Tcl. There was some confusion here because the questioner did not mention that he was using Tcl::Tk and I assumed that he was using Tk.

Log In?
Username:
Password:

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

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

    No recent polls found