I have somewhat of a dillema with how to pack a Text widget into my Tk program. Let's say that I have a very simple GUI with a Text widget on top and a Frame on the bottom. The text widget must contain X characters of text at font Y and the window can be resized to size Z. In other words, the text in the Text widget can span a varying number of lines. What I'd like to do is to make the Text widget only as large as I need to given the number of lines that are in the widget at the time. So, what I have so far is:
my $t = $mw->Text(-height=>2, -font=>'helvetica 12')->pack(-side=>'top +', -expand=>'1', -fill=>'both'); $t->insert('end', "Blah " x 10); my $f = $mw->Frame(-background=>"#FF0000")->pack(-side=>'top', -expand +=>'1', -fill=>'both');
The problem that I have is that I need to make the Text widget large enough at all times to display all of the lines of text, even if the window is resized so that the text wraps around to, in this example, 3rd line. At the same time, I don't want the Text box to be any more lines than it has to be (and if possible not even expand when the window is resized and the text can fully fit in the alloted number of lines).
Basically, what I want is the ability to catch the MW_RESIZE events and use that as the trigger to get the line number of the 'end' character in the Text widget, so I could then configure the height accordingly. Is this possible in Tk?
In reply to Tk:Text resize dillema by gri6507
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |