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

Perl Tk macOS segmentation fault 11

by Anonymous Monk
on Feb 25, 2018 at 08:22 UTC ( [id://1209921]=perlquestion: print w/replies, xml ) Need Help??

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

Dear monks

Running the following simple Tk script on macOS (High Sierra), Perl 5.26.1 I get a "Segmentation fault 11". It must have to do with the loading of the png. Any idea? A bug?

use strict; use warnings; use Tk; use Tk::PNG; my $png_image_file = 'annotate.png'; my $mw = Tk::MainWindow->new(); my $pic = $mw->Photo(-file => $png_image_file); my $btn = $mw->Button( -text => "Button mit PNG-Datei als Bild", -compound => 'top', -image => $pic, ); $btn->pack(-padx => 10, -pady => 10,); $mw->MainLoop(); exit(0);

On top of this, I have a strange behavior of Tk entry widgets. If I change the layout of my keyboard, this change does NOT affect the Tk widgets! All other applications accepts the input of the new keyboard layout (I change it from Russian - my standard - to English or others) but Perl Tk seems not to see this. How can this be?

PS: Perl Tk looks really bad on macOS (compared for example to Windows)... really '90s!

Replies are listed 'Best First'.
Re: Perl Tk macOS segmentation fault 11
by kevbot (Vicar) on Feb 26, 2018 at 00:37 UTC
    Your code works fine for me on macOS High Sierra (v10.13.3), perl v5.26.1 (installed with perlbrew) and Tk v804.034 (installed with cpanm). Did you test your code with different png files? Perhaps a corrupted png file could be causing the problem.
Re: Perl Tk macOS segmentation fault 11
by Anonymous Monk on Feb 26, 2018 at 00:34 UTC
    First, did you compile Tk yourself ( which is quite easy ) or are you using what is provided by the Mac? Try compiling it yourself and report any errors. Don't worry about the test suite failing.

    As far as Tk looking really bad, really 90's, it is really 90's. :-) You have to understand the simplicity of the Tk toolkit in order to fully appreciate it. It requires nothing more the basic X system libs to compile and run. It itself, is quite a small codebase, which in this age of security concerns has many advantages. With Tk, you can make your widgets as fancy as you want, and even make make your own custom subclassed widgets simply out the Canvas widget. See Tk-CanvasDirTree for a simple example. True you have to put alot extra color statements to get the effect you desire, and Tk dosn't conform to any theme standards, like Gtk2 or Gtk3. Then again, Gtk2 and Gtk3 will load an enormous amount of libraries .... which do your prefer? Theme conforming modern looking GUI's which come a load of dependencies, or the basic simplicity of Tk? Your choice.

    If you want to make something really special with Tk, including semi-transparency, and matrice geometry control, like zooming and rotations, see Tk::Zinc

      Thank you for your thoughts. However, I disagree that Tk must look so bad. In fact, even Perl/Tk on Windows looks pretty decent and with some work I can create quite appalling GUIs. The problem on macOS is that it rely on Xquartz and here, yes, it looks OLD. However, this has nothing to do with Tk. Using the Tcl::pTk module I discovred a few days ago, my Perl/Tk scripts suddenly looks pretty modern (no Xquartz needed). just try for yourself using the integrated widget examples (run widgetTclpTk). And it looks pretty Mac-ish too

        with some work I can create quite appalling GUIs

        I hope you meant "appealing", not "appalling" ;-)

        Nah perl/Tk is tcl/Tk fork from 1994. Tcl/tk moved on since then. Perl/tk aka Tk.pm aka Tk is stuck with the looks it has, that you can tk::style

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2024-04-23 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found