-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Hi,
i am trying to add some buttons dynamically to a frame. The frame itself is in another frame.
----------- SAMPLE CODE -----------
use IUP ':all';
my ($frame1,$subFrame,$hbox1,$dlg,$butt);
$subFrame=IUP::Frame->new(SIZE=>'200x200',TITLE=>'Projects',SCROLLBAR=>'VERTICAL');
sub create_project{
print "\n create proj\n";
$butt=IUP::Button->new(TITLE=>"proj",ACTION=>&bla);
$subFrame->Append($butt);
$butt->Map();
$subFrame->Refresh();
}
sub bla{
print " bla\n";
}
create the main dialog
sub init_dialog {
my $menu = IUP::Menu->new( child=>[
IUP::Item->new(TITLE=>"Message", ACTION=>&my_cb ),
IUP::Item->new(TITLE=>"Quit", ACTION=>sub { IUP_CLOSE } ),
]
);
$frame1 = IUP::Frame->new(SIZE=>'200x200',TITLE=>"PC", child=>
IUP::Vbox->new( child=>[
IUP::Button->new( EXPAND=>'HORIZONTAL',TITLE=>"Create project", ACTION=>\&create_project ),
$subFrame
])
);
$hbox1 = IUP::Hbox->new( child=>$frame1);
return IUP::Dialog->new(SIZE=>'200x260',MENU=>$menu, TITLE=>"Custom Dialog Sample", child=>$hbox1 );
}
main program
$dlg = init_dialog();
$dlg->Show();
IUP->MainLoop();
----------- SAMPLE CODE -----------
So when i press on the button the in '$frame1' i can create one button without errors. Unfortunately the second time i press the main window closes with seg fault.
I was reading the manual and tried to find some examples of the exact procedures of dynamically adding widgets but could not find any, at least for perl-iup.
Any ideas what i might be doing wrong? Or how to resolve the issue?
Thank you for your time and efforts!
Cheers
D.