Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Tkx Optionmenu

by shortyfw06 (Beadle)
on Sep 13, 2012 at 18:14 UTC ( #993551=perlquestion: print w/ replies, xml ) Need Help??
shortyfw06 has asked for the wisdom of the Perl Monks concerning the following question:

I've written some code using Tk but am now using Tkx. I've tried to make the necessary changes but am getting errors with new_optionmenu. Is the syntax below correct? If so, I might have some issues with my .pm files?... I'd appreciate any suggestions. Thanks!

#!usr/bin/perl use Tkx; use strict; use warnings; my $crit; my $mw = Tkx::widget->new("."); my @fail_crit = ( '1. Maximum Strain', '2. Maximum Stress', '3. Tsai-Hill', '4. Modified Tsai-Wu', '5. Hoffman', ); my $fail_crit_optmen = $mw -> new_optionmenu(-options=>\@fail_crit, -variable=> \$crit)->g_pack(-side=>'right'); Tkx::MainLoop();

Comment on Tkx Optionmenu
Download Code
Replies are listed 'Best First'.
Re: Tkx Optionmenu
by Anonymous Monk on Sep 14, 2012 at 02:25 UTC

    Is the syntax below correct?

    :) the code compiles so its correct syntax, but as the runtime error says, there is no command optionmenu

    What is this optionmenu widget you're trying to create? Where is it documented?

    I'd appreciate any suggestions.

    You can always stick , there is no reason to pickup Tkx

      Thanks for the reply. optionmenu is a Tk widget.

      I found that for Tkx, combobox is basically the same as optionmenu so I was able to use that.

      I am continuing to have difficulties with the conversion. You suggested sticking with Tk, however, I don't have Tk included in the installation of Active Perl that I am now using. Is there a download you can point me to? Would it be a simple download of Tk to use my current script or is there more to it? Thank you again!

        use PPM::Repositories to find a repository with Tk, like


        You're looking at the wrong documentation, Tkx/Tkx::Tutorial says read the following -> ->

        #!usr/bin/perl -- use strict; use warnings; $Tkx::TRACE = 64; use Tkx; my $mw = Tkx::widget->new("."); { my @fail_crit = ( '1. Maximum Strain', '2. Maximum Stress', '3. Tsai-Hill', '4. Modified Tsai-Wu', '5. Hoffman', ); my $chosen = ""; my $frame = $mw->new_ttk__frame(); $frame->g_pack(qw/ -expand 1 -fill both /); $frame->new_ttk__label( -text => "CHOSEN:", )->g_grid( -column => 0, -row => 0, ); $frame->new_ttk__label( -textvariable => \$chosen, )->g_grid( -column => 1, -row => 0, ); #~ tk_optionMenu pathName varName value ?value value ...? Tkx::tk___optionMenu( "$frame.crit", \$chosen, @fail_crit ); #~ Tkx::widget->new( "$frame.crit" )->g_grid(-column => 2, -row => + 0); Tkx::grid( "$frame.crit", -column => 2, -row => 0 ); } Tkx::i->interp->Eval(q{ttk::label .l2 -textvariable myVar; pack .l2}); Tkx::i->interp->Eval(q{tk_optionMenu .foo myVar Foo Bar Boo Spong Wibb +le}); Tkx::i->interp->Eval(q{pack .foo}); Tkx::MainLoop(); __END__ winfo children . ttk::frame .f pack .f -expand 1 -fill both winfo children .f ttk::label .f.l -text CHOSEN: grid .f.l -column 0 -row 0 winfo children .f ttk::label .f.l2 -textvariable SCALAR +(0x99ae24) grid .f.l2 -column 1 -row 0 tk_optionMenu .f.crit SCALAR(0x99ae2 +4) {1. Maximum Strain} {2. Maximum Stress} {3. Tsai-Hill} {4. Modifie +d Tsai-Wu} {5. Hoffman} grid .f.crit -column 2 -row 0

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2015-11-29 05:15 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (747 votes), past polls