使用 perl win32::gui 在运行时添加控件
如何使用 perl win32::GUI 在运行时在窗口中添加控件? 我的窗口中有一个按钮控件。我需要在单击按钮时在同一窗口中创建一个复选框控件。 我已经编写了下面提到的代码,该代码也不起作用。 请给出使用 perl Win32::GUI 在运行时添加控件的正确方法
use strict;
use Win32;
use Win32::GUI;
my $win=Win32::GUI::Window->new(
-name => 'wino',
-text => 'window',
-left => 375,
-top => 400,
-width =>380,
-height =>260,
);
my $but=$win->AddButton(
-text=>"Add Control",
-onclick=>\&add_control,
);
$win->Show();
Win32::GUI::Dialog();
sub add_control(){
my $mchk=$win->AddCheckbox(
-text=>"run_time_con",
-pos=>[180,145],
);
$mchk->Show();
}
How to add a control in a window at run time using perl win32::GUI?
I have a button control in my window. I need to create a checkbox control in the same window, while I am clicking the button.
I have written the code as mentioned in below, which is not working also.
Please give the correct way to proceed to adding controls at run time using perl Win32::GUI
use strict;
use Win32;
use Win32::GUI;
my $win=Win32::GUI::Window->new(
-name => 'wino',
-text => 'window',
-left => 375,
-top => 400,
-width =>380,
-height =>260,
);
my $but=$win->AddButton(
-text=>"Add Control",
-onclick=>\&add_control,
);
$win->Show();
Win32::GUI::Dialog();
sub add_control(){
my $mchk=$win->AddCheckbox(
-text=>"run_time_con",
-pos=>[180,145],
);
$mchk->Show();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题不是添加控件的代码,而是按钮单击事件未正确连接的事实。请参阅文档。
试试这个:
Your problem isn't the code which adds the control, it's the fact that the button click event isn't wired up properly. See the documentation.
Try this instead: