开发者

Is there a workaround to the disappearing Perl/Tk text widget scrollbar for right justified content?

I've come across a bug I believe in Perl/Tk 804.027 Text Widget (using Scrollable('ROText')). When I add a tag that selects all and apply the configuration change to justify to the right, the scrollbars do not show up. If I comment out the tagConfigure where I justify to the right, the scrollbars come back.

Does anyone have a workaround or fix for being able to right justify a text widget's contents (includes text and embedded entry widgets) and still have functional horizontal scrollbars?

(Update)

Here is an example script that will reproduce the problem:

use Tk;

$mw = MainWindow->new;
$mw->title("Testing");
$mw->geometry();

$pw = $mw->Scrolled('Panedwindow',-showhandle=>0, -sashwidth=>0, -sashpad开发者_如何学C=>0, -scrollbars=>'e');

$pw->pack(qw/-side top -expand yes -fill both -pady 2 -padx 2m/);

$t1 = $pw->Scrolled("Text", -scrollbars => 'os', -bg=>"red", -width => 40, -wrap => "none", -relief=>"flat");
$t2 = $pw->Scrolled("Text", -scrollbars => 'os', -bg=>"blue", -width => 20, -wrap => "none", -relief=>"flat");

$pw->add($t1,$t2);

# this loop is only to demonstrate the second problem: vertical scrolling 
# on parent widget not working
foreach my $ct (1..50) {
$t1->insert("end","abcdef-abcdef-abcdef-abcdef-abcdef-abcdef-abcdef-abcdef-abcdef-abcdef\n");
 }
$t1->tagAdd("content", '1.0', 'end');


# this is the justify right & loose horizontal scrolling problem:
# change the justify from left to right and the scrollbars will not show up
$t1->tagConfigure("content", -justify=>"left");

MainLoop;

The problem I have is really two-fold for my application and both are demonstrated to not work in the above example:

  1. I need the left side of the pane horizontally scrollable and right justified
  2. I need the Paned Window widget (the parent of the two panes) to be vertically scrollable (both left and right panes together scroll together).


I find that when I think there is a bug in someone else's code, It is often helpful to produce a very small program that duplicates the behavior. I generally find through this process that the error was coming from my usage of the code, not from the code itself (this is not surprising since the new code has never been tested or used by anyone else, unlike the old code).

It is often hard to see your error in the middle of a lot of tricky application code. By separating it out into a simple test case you remove the noise from the problem. And, if the problem continues to exist, you have a test case you can report to the author or post to a site like this one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜