My bad, I was using: Tkx::ttk__button()
whereas your code used: Tkx::button()
Sigh. BTW: I am writing my very 1st Tkinter code, so your help is greatly appreciated.

The latter surely supports "-background".
However, I still cannot get the color to change.
So, I reduced your example to 2 buttons, code at bottom.

One confusion is "what replaces the 'i' in: Tkx::i:..."
as noted in your "I FIGURED IT OUT" response:

  Tkx::i::call(".b", "configure", "-background", "blue");
Your response says:
  "You just have to change the letter [I presume ::i::] to match the button."
The other confusion: where is the syntax to spec what gets "call"'ed...
  "Undefined subroutine &Tkx::button::call...:
Complete runtime error is below.

For ref, the following 2-command example works fine:
  -command => sub { print "18L\n"; print "18L #2\n"; },
So I tried the following (yep, some desperation flailing...):
  -command => sub { print "18L\n"; Tkx::.b::call(".b", "configure", "-background", "blue"); },
  -command => sub { print "18L\n"; Tkx::button::call(".b", "configure", "-background", "blue"); },
  -command => sub { print "18L\n"; Tkx::".b"::call(".b", "configure", "-background", "blue"); },
#3 = syntax error (obviously)
#1 and #2 = the following runtime (Application) error, after clicking the "18-Letters" button:

Undefined subroutine &Tkx::button::call called at H:\NotPhotos\Computer\Raspberry_Pi\Perl\test2.pl line 15.
Undefined subroutine &Tkx::button::call called at H:\NotPhotos\Computer\Raspberry_Pi\Perl\test2.pl line 15.
    while executing
"::perl::CODE(0x4de7f0)"
    invoked from within
".b invoke"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 list $w invoke"
    (procedure "tk::ButtonUp" line 24)
    invoked from within
"tk::ButtonUp .b"
    (command bound to event)

use strict; use warnings; use Tkx; my $mw = Tkx::widget->new("."); $mw->g_wm_title("Jobs Not Forecasted"); Tkx::button(".b", -text => "18-Letters", -background => "red", -width => 11, -command => sub { print "18L\n"; print "18L #2\n"; }, # OK # -command => sub { print "18L\n"; Tkx::.b::call(".b", "configure", " +-background", "blue"); }, # BAD, runtime error # -command => sub { print "18L\n"; Tkx::button::call(".b", "configure +", "-background", "blue"); },# BAD, runtime error # -command => sub { print "18L\n"; Tkx::".b"::call(".b", "configure", + "-background", "blue"); }, # BAD, syntax error ); Tkx::pack(".b"); Tkx::button(".s", -text => "EXIT", -width => 11, -command => sub { Tkx::destroy("."); }, ); Tkx::pack(".s"); Tkx::MainLoop();

In reply to Re^4: How to change colour of a Tkx button when pressed by Anonymous Monk
in thread How to change colour of a Tkx button when pressed by PerlCowboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.