Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Limitations with Tkx configure options?

by murrayn (Acolyte)
on Sep 10, 2012 at 07:58 UTC ( #992699=perlquestion: print w/ replies, xml ) Need Help??
murrayn has asked for the wisdom of the Perl Monks concerning the following question:

I wrote a gui using Tk and changed button colours successfully. I upgraded my ActiveState perl and found that Tk no longer builds correctly so I changed to Tkx. Now I can't configure a button's background colour despite finding various examples showing me that I should do as follows:
use Tkx; my $mw = Tkx::widget->new("."); my $calc = $mw->new_ttk__button(-text=>"Calculate", -command=>sub {cal +culate();}); $calc->g_grid(-column=>1,-row=>3,-columnspan=>2,-sticky=>"ew"); $calc->g_bind("<Enter>", sub {$calc->configure(-background=>'red');}); Tkx::MainLoop();
I get the following error which is fairly self-explanatory except that I understood, from what doc (mainly Tk, NOT Tkx) that it should work.
unknown option "-background" at /TestCode/configtest.pl line 5. unknown option "-background" while executing ".b configure -background red" invoked from within "::perl::CODE(0x4af0d4)" (command bound to event)
Am I attempting the impossible or do I need some other module to discover these attributes?

Comment on Limitations with Tkx configure options?
Select or Download Code
Re: Limitations with Tkx configure options?
by Anonymous Monk on Sep 10, 2012 at 09:00 UTC
Re: Limitations with Tkx configure options?
by Anonymous Monk on Sep 10, 2012 at 09:10 UTC

    Here are the available configure options

    #!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ pp /; $Tkx::TRACE = 64; use Tkx; my $mw = Tkx::widget->new("."); my $calc = $mw->new_ttk__button( -text => "Calculate", -command => \&calculate +); $calc->g_grid( -column => 1, -row => 3, -columnspan => 2, -sticky => " +ew" ); sub calculate { pp [ $calc->configure ]; $calc->configure( -background => 'red' ); } Tkx::MainLoop(); __END__ $ perl tkx-configure.pl Tkx-1-0.0s-tkx-configure.pl-8: winfo children . Tkx-2-0.0s-tkx-configure.pl-8: ttk::button .b -text Calculate -command + perl::callback Tkx-3-0.0s-tkx-configure.pl-10: grid .b -column 1 -row 3 -columnspan 2 + -sticky ew Tkx-4-2.9s-tkx-configure.pl-13: .b configure [ bless([ bless([ "-takefocus", "takeFocus", "TakeFocus", "ttk::takefocus", "ttk::takefocus", ], "Tcl::List"), bless(["-command", "command", "Command", "", "::perl::CODE(0xa84ec +c)"], "Tcl::List"), bless(["-default", "default", "Default", "normal", "normal"], "Tcl +::List"), bless(["-text", "text", "Text", "", "Calculate"], "Tcl::List"), bless(["-textvariable", "textVariable", "Variable", "", ""], "Tcl: +:List"), bless(["-underline", "underline", "Underline", -1, -1], "Tcl::List +"), bless(["-width", "width", "Width", "", ""], "Tcl::List"), bless(["-image", "image", "Image", "", ""], "Tcl::List"), bless(["-compound", "compound", "Compound", "none", "none"], "Tcl: +:List"), bless(["-padding", "padding", "Pad", "", ""], "Tcl::List"), bless(["-state", "state", "State", "normal", "normal"], "Tcl::List +"), bless(["-takefocus", "takeFocus", "TakeFocus", "", "ttk::takefocus +"], "Tcl::List"), bless(["-cursor", "cursor", "Cursor", "", ""], "Tcl::List"), bless(["-style", "style", "Style", "", ""], "Tcl::List"), bless(["-class", "", "", "", ""], "Tcl::List"), ], "Tcl::List"), ] Tkx-5-2.9s-tkx-configure.pl-14: .b configure -background red
Re: Limitations with Tkx configure options?
by zentara (Archbishop) on Sep 10, 2012 at 10:24 UTC
    This is just a guess from my Tk experience, but some widgets use -bg instead of -background.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
        Thank you. I would seem to be constrained by the settings of the style sheet associated with the widget (and I'm not so desperate for specific colours that I'm going to go revising the style sheet just for fun - there's a job to be done behind all this :) ).
        Those links were very helpful and led to an interesting discovery which appears to differ between ttk and Tk:
        A widget state of active != !disabled. At least not when the Tbutton style applies. I wanted to disable and enable a button during various processes but setting the button's state to "active" did not re-enable it.
        $w->state('!disabled') reverses the effect of $w->state('disabled')
        $w->state('active disabled') is not an oxymoron but it makes the button rather difficult to press while both states exist.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-12-25 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (162 votes), past polls