开发者

How can I run initial subroutine after opening new window

In my Perl/Tk script I'm opening new windows, and i want the window opening will run an initial subroutine (when ever the window is开发者_开发问答 opened) How can I do it?


One way is to call the subroutine from the code that creates and/or raises the window. If you want the call to be bound to the action itself rather than the invocation of that action (maybe because the window could be opened from multiple places in the code) you would need to create an event binding. e.g.

$window->bind('<Map>', \&mysub);

Depending on what precisely you're trying to do, you might want to bind to the Create, Activate, or Visibility events instead. See the Tk event type documentation for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜