天道酬勤,学无止境

perltk

Perl/Tk menubar quirks

I'm trying to add a menubar with the standard File Open, Save and New options. However, instead of behaving as expected, the subroutine handling the open, save and new actions is launched upon creation of the frame. But, when I actually click on them, it is not. Following is the code I'm using. (Main window contains only the menubar) #!/usr/bin/perl use strict; use warnings; use diagnostics; use Data::Dumper; use Tk 8.0; use Tk::NoteBook; use Tk::MsgBox; my $mw=MainWindow->new; $mw->geometry("+500+300"); # Menu Bar Buttons my $mbar=$mw->Menu(); $mw->configure(-menu => $mbar); my $file=$mbar-

2021-11-11 17:42:45    分类:问答    perl   tk   perltk

使用 destroy() 命令时的 Perl/Tk 内存泄漏(Perl/Tk Memory Leak When Using destroy() Command)

问题 我遇到了在 Unix 上运行的 Perl/Tk 中的大量泄漏问题。 由于某些限制,我无法发布大部分代码,但我已经能够确定导致内存泄漏的原因并创建了一个具有相同症状的小程序。 基本上我正在运行一个 GUI,其中一个框架被定期销毁并重新填充。 然而,这似乎会导致大量内存泄漏,并且不断增长。 我以为 destroy 命令会清除内存中的所有痕迹,但似乎并非如此。 我对 Perl 中的垃圾收集也不太熟悉。 该程序将一次运行数天或数周,因此内存泄漏并不理想。 有没有人有任何想法来阻止内存泄漏? 我只能使用 Perl,所以不幸的是,我不能轻易地将代码移植到 Python 或其他东西。 提前感谢您的帮助。 #!opt/project/COTS/bin/perl use strict; use warnings; use Tk; $Tk::mw = MainWindow->new; $Tk::mw->repeat(10,\$build); my $status; &build; sub build{ $status->destroy() if ($status); $status = $Tk::mw->Frame->pack(-side => 'top'); my $left_frame = $status->Frame( -relief =>'sunken', -borderwidth =>

2021-09-11 21:43:27    分类:技术分享    memory-leaks   destroy   perltk

Perl/Tk Memory Leak When Using destroy() Command

I am having an issue with a large leak in Perl/Tk running on Unix. I am unable to post most of the code due to certain restrictions, but I have been able to identify what is causing the memory leak and create a small program that has the same symptoms. Basically I am running a GUI where a frame is destroyed and repopulated regularly. This seems to cause a large memory leak that keeps growing however. I thought the destroy command would get rid of all traces in memory, but it does not seem to be that way. I am not too familiar with the garbage collection in Perl either. This program will be

2021-09-04 13:16:21    分类:问答    memory-leaks   destroy   perltk

Limiting scroll bar length

I am trying to create a simple notepad like GUI using Perl Tk. I have used the Scrolled widget to create a Text widget with two scrollbars - one on the right and one on the bottom. The place where the two scrollbars meet looks like this: However I would like to make it look like what is seen in the "Notepad" application by Microsoft. This is how I want it: As you can see, there is a now an "empty square" where the two scrollbars meet. One more feature of notepad is that this "square" can be used to resize the window size. I want to be able to achieve the same. How do I go about doing this

2021-08-10 16:25:25    分类:问答    perl   tkinter   tcl   tk   perltk