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

This is a Tkx editor (mentioned in a previous post Tkx: "invalid command error" OS X).

The code below works fine on XP but no menus are displaying on OS X (I don't have a Mac but I have couple of testers working with me on this).

The testers are getting no errors, the window pops up. The output from the Tkx::TRACE flag seems to indicate the commands are executing.

I've googled on this and couldn't find anything. And I'm (almost) certain I have the syntax correct.

I'm working with Perl 10/Tk 8.5.5. The Mackers are stuck with 8.4 Tk installed via CPAN (at least until I get them to upgrade ;)

Output from tk_windowingsystem() is aqua on OS X

I've also had them run the demo editor tkx-ed from the module with same results.

Thanks

use warnings; use strict; use Tkx; $Tkx::TRACE = 1; our $VERSION = "1.0.0"; my ($mw, $tw); $mw = Tkx::widget->new("."); $mw->configure(-menu => mk_menu($mw)); Tkx::wm_title($mw, "GutThing-$VERSION"); my ($height, $width, $wrap) = (20, 80, "none"); $tw = $mw->new_text( -height => $height, -width => $width, -wrap => $wrap, ); $tw->g_pack( -anchor => "center", -expand => 1, -fill => "both", ); $tw->g_focus; $tw->insert("end", "If you can read this it worked"); $tw->insert("end", " but I don't do much at the moment."); $tw->insert("end", " This is a long line that doesn't wrap."); $tw->insert("end", " We don't wrap our lines in this editor for PPing. +\n"); $tw->insert("end", "If you type here the line should scroll if you go +longer than window width.\n"); Tkx::MainLoop(); exit; sub mk_menu { my $mw = shift; my $menu = $mw->new_menu; my $file = $menu->new_menu( -tearoff => 0, ); $menu->add_cascade( -label => "File", -underline => 0, -menu => $file, ); return $menu; }

Replies are listed 'Best First'.
Re: Tkx: Tkx editor doesn't display menus on OS X
by ikegami (Patriarch) on Nov 25, 2008 at 01:36 UTC

    The scratchpad is volatile. Someone coming in later having a similar problem won't be able to benefit from the answers given here if you decided to remove the code from your scratchpad. For posterity, here's the code in question:

    use warnings; use strict; use Tkx; $Tkx::TRACE = 1; our $VERSION = "1.0.0"; my ($mw, $tw); $mw = Tkx::widget->new("."); $mw->configure(-menu => mk_menu($mw)); Tkx::wm_title($mw, "GutThing-$VERSION"); my ($height, $width, $wrap) = (20, 80, "none"); $tw = $mw->new_text( -height => $height, -width => $width, -wrap => $wrap, ); $tw->g_pack( -anchor => "center", -expand => 1, -fill => "both", ); $tw->g_focus; $tw->insert("end", "If you can read this it worked"); $tw->insert("end", " but I don't do much at the moment."); $tw->insert("end", " This is a long line that doesn't wrap."); $tw->insert("end", " We don't wrap our lines in this editor for PPing. +\n"); $tw->insert("end", "If you type here the line should scroll if you go +longer than window width.\n"); Tkx::MainLoop(); exit; sub mk_menu { my $mw = shift; my $menu = $mw->new_menu; my $file = $menu->new_menu( -tearoff => 0, ); $menu->add_cascade( -label => "File", -underline => 0, -menu => $file, ); return $menu; }

    Sorry that I can't help you, though.

      Good point. Thanks.
Re: Tkx: Tkx editor doesn't display menus on OS X
by jand (Friar) on Nov 25, 2008 at 22:41 UTC
    It does display the menu for me. Of course you first have to activate the window to get to see the menu; if you just type perl myscript.pl into Terminal, then the focus will stay with your Terminal window.