Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exit Button and function

Status
Not open for further replies.

flnMichael

Programmer
Nov 13, 2003
96
US
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:

Code:
  my $main = MainWindow->new();
  $main->minsize(qw(250 150));
  $main->resizable(0,0);
  $main->configure(-background=>'grey');
  $main->geometry("+100+100");
  $main->focus;

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

  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');
 
Hi

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

Feherke.
[link feherke.github.com/][/url]
 
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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top