Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Exit Button and function

Exit Button and function

Exit Button and function

HI all,

I have a little issue with my exit button randomly executing after I execute something on my menubar. So, for example, I go to "open file", select the file, click ok and then the exit function executes. Am I missing something in my creation of the buttons? Any help would be appreciated. Here is the code:


my $main = MainWindow->new();
  $main->minsize(qw(250 150));

  my $mb = $main->Menu(-menuitems=>&menubar_menuitems() );

  my $body = $main->Frame(-background=>'grey',-relief=>'groove')->pack(-side=>'top',-fill=>'x');
  $statFrm = $body->Frame(-background=>'grey',)->pack(-side=>'top',-fill=>'x');
  $btnFrm = $body->Frame(-background=>'grey',)->pack(-side=>'top');

  $main->Button(-text=>'View Log',-state=>'disabled')->pack(-side=>'left',-anchor=>'sw');
  $main->Button(-text=>'Exit',-command=>sub { print LOGFILE "This is exiting\n"; exit;},)->pack(-side=>'right',-anchor=>'se'); 

RE: Exit Button and function


  • Your question is quite off-topic. Even if you use the Tk module, the question is more appropriate for forum219: Perl.
  • Post a functional piece of code. Personally I not wrote Perl/Tk for years, so I can not debug it without running it.
  • Do you execute MainLoop later in the code ?


RE: Exit Button and function

Thanks for the proper direction. I just figured posting the snippet of code would be sufficient because this is where the "error" was occurring and posting my whole program would have been riduculous. And yes, the MainLoop is being called later on down in the code.

Turns out the positioning of the file window just so happened to be placed above the exit button, so when I was double clicking the chosen file, if it was the file icon above the exit button, I was also clicking the exit button. Believe me, this was not easy to figure out since there really wasn't any error, just a freak coincidence that it was positioned in just the right spot banghead

Thanks, and now I know to post on the Perl forum next time!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close