#!/usr/bin/perl --
use Tkx;
$Tkx::TRACE = 64;
Tkx::package_require('tile');
my $mw = Tkx::widget->new(".");
# example bug : new_tk__listbox
( $lb = $mw->new_listbox( -height => 5 ) )
->g_grid( -column => 0, -row => 0, -sticky => "nwes" );
(
$s = $mw->new_ttk__scrollbar(
-command => [ $lb, "yview" ],
-orient => "vertical"
)
)->g_grid( -column => 1, -row => 0, -sticky => "ns" );
$lb->configure( -yscrollcommand => [ $s, "set" ] );
(
$mw->new_ttk__label(
-text => "Status message here",
-anchor => "w"
)
)->g_grid( -column => 0, -row => 1, -sticky => "we" );
( $mw->new_ttk__sizegrip )->g_grid( -column => 1, -row => 1, -sticky =
+> "se" );
$mw->g_grid_columnconfigure( 0, -weight => 1 );
$mw->g_grid_rowconfigure( 0, -weight => 1 );
for ( $i = 0 ; $i < 100 ; $i++ ) {
#~ $lb->insert( "end", "Line " . $i . " of 100" );
$lb->insert( "end", "Line " . $i . " of {100}" );
}
Tkx::MainLoop();
Watch the trace
...
Tkx-114-0.1s-tkx.listbox.pl-30: .l insert end {Line 97 of \{100\}}
Tkx-115-0.1s-tkx.listbox.pl-30: .l insert end {Line 98 of \{100\}}
| [reply] [d/l] [select] |
I don't completely follow what you're saying. Just that using ->insert will work with escaped braces, and that escaping in the list should work the same? In playing around, what's really weird is if I set something up with braces using the list at initialization, tkx will tell me about the unmatched brace and die. But if it happens during runtime, it just falls thorugh...
It's funny because that's how I had my original Tk using hlist with $hlist->add calls. I didn't think Tkx had a similiar interface...
Thanks. I'm going to use the ->insert.
# here's what I mean, I hacked your example
# the trip button adds a third element, which gets dropped
# silently. (and you can escape it, and see the escape...
use Tkx;
$Tkx::TRACE = 64;
Tkx::package_require('tile');
my $mw = Tkx::widget->new(".");
my $list;
my @strings;
$strings[0] = 'Hello, this should be ok';
$strings[1] = 'this too';
$list = &make_tcl_list(@strings);
# example bug : new_tk__listbox
( $lb = $mw->new_listbox( -height => 5,-listvariable => \$list ) )
->g_grid( -column => 0, -row => 0, -sticky => "nwes" );
(
$s = $mw->new_ttk__scrollbar(
-command => [ $lb, "yview" ],
-orient => "vertical"
)
)->g_grid( -column => 1, -row => 0, -sticky => "ns" );
$lb->configure( -yscrollcommand => [ $s, "set" ] );
(
$mw->new_ttk__label(
-text => "Status message here",
-anchor => "w"
)
)->g_grid( -column => 0, -row => 1, -sticky => "we" );
( $mw->new_ttk__sizegrip )->g_grid( -column => 1, -row => 1, -sticky =
+> "se" );
$mw->g_grid_columnconfigure( 0, -weight => 1 );
$mw->g_grid_rowconfigure( 0, -weight => 1 );
## add a button to add an unbalanced brace
(my $button = $mw->new_tk__button(
-text=>"Trip",
-anchor=>'w',
-command=> sub {
$strings[2] = 'watch this{';
$list=&make_tcl_list(@strings);
}
))->g_grid( -column => 0, -row => 1, -sticky => "nwes" );
Tkx::MainLoop();
sub make_tcl_list{
my @LIST = @_;
my $listx = '';
for my $i (@LIST) {
$listx = $listx . ' {' . $i . '}';
}
return $listx;
}
| [reply] [d/l] |