如何获取 Perl/Tk 文本小部件中的文本?

发布于 2024-09-16 13:57:09 字数 303 浏览 3 评论 0原文

我编写了一个脚本,该脚本获取文件名并将文件内容插入到 文本小部件。现在,当我关闭脚本窗口时,我需要它将文本写入 Unix 屏幕上。

如何获取文本小部件内容?

我的文本小部件插入源代码是:

open(FILE, $file_name);
foreach my $line (<FILE>) {
    $text->insert('end', $line);
}

I have written a script that gets a file name and insert the file content to a Text widget. Now when I close the script window, I need it to write the text onto the Unix screen.

How can I get the Text widget content?

My text widget insertion sorce code is:

open(FILE, $file_name);
foreach my $line (<FILE>) {
    $text->insert('end', $line);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤城病女 2024-09-23 13:57:09
$text->get('1.0','end-1c');

(它是 end-1c – 结尾少一个字符 – 出于相当技术性的原因;仅使用 end 您就会附加一个额外的换行符。一个已知的 Tk 陷阱。)

$text->get('1.0','end-1c');

(It's end-1c – end less one character – for fairly technical reasons; with just end you'd get an extra newline appended. A known Tk gotcha.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文