Вопрос

I'm writing Perl/Tk program which uses AnyEvent's timer. And I have a problem with closing window if timer is active. I made this window close handler:

$self -> {window} -> protocol( 'WM_DELETE_WINDOW' => sub {
                                                   undef $self -> {timer};
                                                   $self -> {window} -> destroy;
});

If timer is active when I close the window, timer stops, window closes, but MainLoop doesn't stop. What's wrong?

Это было полезно?

Решение

According to the AnyEvent::Impl::Tk documentation, a hidden Tk MainWindow is created to get things working. But it seems that this hidden window is never destroyed automatically. As a workaround, you can do it yourself:

$AnyEvent::Impl::Tk::mw->destroy;
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top