| [reply] |
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();
| [reply] [d/l] |
Hi, I'm not cowboy :) The Tkx::pack(".s");... syntax cowboy using is very cumbersome , if you're going to do that, might as well just write it in tcl with the "secret" Tkx::eval('tcl source code here'); , its a tiny bit less cumbersome than Tkx::i::call, but you gotta learn Tcl syntax
Yes Tkx::pack... is the first syntax explained in Tkx::Tutorial (a tutorial which must not be skipped),
but don't choose that syntax :)
Also if you insist on Tkx don't skip http://www.tkdocs.com/tutorial/onepage.html
$Tkx::TRACE = 64;
use Tkx;
...
## create button
my $b = $mw->new_ttk__button(
-text => 'Hello, world',
-command => sub { $mw->g_destroy; },
);
$b->g_pack;
## retrieve existing button by name (button created using Tkx::eval())
## my $b = Tkx::widget->new(".b");
## Tkx::i::call(".b", "configure", "-background", "blue");
## Tkx::eval(".b configure -background blue");
$b->configure( -background => "blue")
doc chain is usually http://docs.activestate.com/activeperl/5.22/lib/Tcl/tkkit.html
...
http://docs.activestate.com/activetcl/8.5/tcl/TkCmd/ttk_button.htm
..
http://docs.activestate.com/activetcl/8.5/tcl/TkCmd/options.htm#M-background, http://docs.activestate.com/activetcl/8.5/tcl/TkCmd/ttk_style.htm
My feelings on tkx Re: Is there a Tk to Tkx translator script? (Tk, Tcl::pTk) | [reply] [d/l] [select] |
I posted #4 and after some more experimenting got things to work. Just needed to c/p cowboy's code literally.
In my defense, his comment
"You just have to change the letter to match the button."
mislead me... who would have thought there was a Tkx::i::... method (the "letter i") and most real code wouldn't have used ".b" as the widget id. What a waste of time. FTR, the following snipped works as reported.
...snip...
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"; Tkx::i::call( ".b", "configure",
+"-background", "blue" ); }
},
);
Tkx::pack(".b");
...snip...
| [reply] [d/l] |