代码之家  ›  专栏  ›  技术社区  ›  Streamline

对于右对齐内容的Perl/Tk文本小部件滚动条是否有解决方法?

  •  2
  • Streamline  · 技术社区  · 16 年前

    我在Perl/tk804.027文本小部件(使用 Scrollable('ROText')

    是否有人有一个解决方法或修复程序能够右对齐文本小部件的内容(包括文本和嵌入的条目小部件)和仍然有功能的水平滚动条?

    (更新)

    下面是一个将重现问题的示例脚本:

    use Tk;
    
    $mw = MainWindow->new;
    $mw->title("Testing");
    $mw->geometry();
    
    $pw = $mw->Scrolled('Panedwindow',-showhandle=>0, -sashwidth=>0, -sashpad=>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;
    

    对于我的应用程序,我遇到的问题实际上有两个方面,在上面的示例中,这两个问题都被证明不起作用:

    1. 可水平向右滚动 正当的
    2. 小部件(两个窗格的父级) 左右窗格一起滚动 一起)。
    1 回复  |  直到 13 年前
        1
  •  0
  •   Chas. Owens    16 年前

    我发现,当我认为其他人的代码中存在bug时,生成一个复制该行为的非常小的程序通常是有帮助的。通过这个过程,我通常会发现错误来自我对代码的使用,而不是代码本身(这并不奇怪,因为新代码从未被其他人测试或使用过,与旧代码不同)。

    在许多棘手的应用程序代码中,常常很难看到错误。通过将它分离成一个简单的测试用例,您可以消除问题中的噪音。而且,如果问题仍然存在,您可以向作者报告一个测试用例,或者发布到这样的站点。

    推荐文章