in reply to Valid chars for Tk Label
Whenever square brackets in a string I've provided to some unknown code cause an error, I look to see if that code is perhaps interpolating the string at some point. This is especially the case if parentheses or a dollar sign appear earlier in the string. I know you gave the string in single quotes, but perhaps the code evals your string later or something.
One could chase around through all the various modules relating to Tk and all the various code evals that happen in them. I can tell you that the error comes from entryconfigure() in some way, because that's what is at line 63 of Tk::Menu::Item in the configure sub.
What I'd try first, though, is to put a backslash in front of each square bracket and see if it helps. Unfortunately in this case it won't.
What will help is to change around your creation and configuration. In fact, I have a code sample for you in which Tk allows one to configure the label but not create with it. This works:
#!/usr/local/bin/perl use strict; use warnings; use diagnostics; use Tk; my $top = MainWindow->new( -width => 300, -height => 200 ); my $menu = $top->Menu( -type=> 'menubar', -tearoff => 0 ); $top->configure( -menu => $menu ); my $label = '8 million ways to die (1986) [HD].TAG'; my $item = $menu->Button( -label => 'foo' ); $item->configure( -label => $label, -command => sub {exit()} ); MainLoop;
If you switch that around to this:
use strict; use warnings; use diagnostics; use Tk; my $top = MainWindow->new( -width => 300, -height => 200 ); my $menu = $top->Menu( -type=> 'menubar', -tearoff => 0 ); $top->configure( -menu => $menu ); my $label = '8 million ways to die (1986) [HD].TAG'; my $item = $menu->Button( -label => $label ); $item->configure( -command => sub {exit()} ); MainLoop;
... then you get a failure on line 63 of Tk::Menu::Item (Tk::Menu::Item version 4.005 with Tk::Menu version 4.023 and Tk version 804.029). Sounds familiar, doesn't it?
Perhaps you can play with ordering or use what remiah posted.
I'd say it is a bug, but working around it seems more useful than waiting for it to be fixed. Now, if you wanted to dive in and send a patch to the maintainer that fixes it without breaking anything else, I'm sure that would be appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Valid chars for Tk Label
by ron7 (Beadle) on Jan 21, 2011 at 04:16 UTC |