Hello monks,
This seemingly simple problem frustrated me enough to sign up as a new user just to ask your opinions! I am no stranger to perl, but am a beginner incorporating TK into my scripts...
My problem is that I have a TK listbox which I am using to display search results of a database. The catch is that each result contains a "short title" and a "description", each of varying lengths. I want each line in the listbox to display the short title followed by the description. I can easily do this with various forms of concatenation, however the differing character lengths make for a "jagged" and ugly listing.
The obvious answer would be to use a tab (\t) in between, but the listbox doesn't seem to recognize escape sequences and instead displays their regex (xism?) equivalent?? I have looked everywhere for some listbox-specific tab, but as it doesn't use TK::text as a base I don't think it supports insertTab()? I don't see this problem when using ROText.
EXAMPLE:
displays (literally):my $text1 = "cherry\tred fruit"; my $text2 = "carrot\torange vegetable"; $lb->insert('end', $text1, $text2);
What is the "\x{9}"?? How do I use escape sequences / regex with listbox?? Thanks!!cherry\x{9}red fruit carrot\x{9}orange vegetable
Thanks for the input folks. sprintf was a good idea, but no luck; it still printed the \x{9} equivalent. I had briefly read about HList, but didn't want to go through the trouble of changing the widget. I think I'll try that now.
Until then, I have temporarily kludged it for our users haha:
my $string1 = "cherry"; my $string2 = "a red fruit"; my $spaces = 30 - length($string1); my $text = sprintf("%-${spaces}s\%s\%s",$string1,$string2);
In reply to TK listbox escape text by jbuck
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |