无法从Tk窗口中删除边框

时间:2013-07-17 14:35:12

标签: perl tk perltk

我正在使用Perl和Tk来显示里面有图像的窗口。它循环通过图像的白色背景,黑色背景,图像(1280x800),重复。问题是我需要能够查看整个图像。 Tk在图像顶部放置一个2像素的边框,包括黑色和白色背景。这是我的代码......

use Tk;

# Create and configure the canvas:
my $canvas = $mw->Canvas( -cursor=>"crosshair", -background=>"black",
              -width=>1280, -height=>800 )->pack();
my $canvasWidth = 1280;
my $canvasHeight = 800;
my $blackRect = $canvas->createRectangle(0,0,$canvasWidth,$canvasHeight, -fill => "black", -tags => ['blackRect']);
my $whiteRect = $canvas->createRectangle(0,0,$canvasWidth,$canvasHeight, -fill => "white", -tags => ['whiteRect']);

# create a Photo object and one Button then we will reuse it.
my $shot = $canvas->Photo();
my $image = $canvas->createImage(0,0, -image => $shot, -anchor => "nw", -tags => ['image']);

# Remove the borders
$mw->overrideredirect(1);

# Loop through images

我知道overrideredirect摆脱了大部分额外的东西,但它仍然没有给我一个窗口。我尝试将-borderwidth=>0添加到Canvas创建中,并且它什么都没有改变。

边框立即出现并且永远不会消失,而不仅仅是在显示第一张图像时。

Here is a screenshot of the border on an image

可以删除此边框吗?如果是这样,怎么样?

1 个答案:

答案 0 :(得分:3)

添加

-highlightthickness => 0

Canvas来电。这将删除用于显示当前焦点小部件的边框。