in reply to Re: pTk popup not returning value and not locking calling window
in thread pTk popup not returning value and not locking calling window

Here is the OK button from the popup window.
my $ok_but = $bf->Button( -text => 'Continue', -width => 10, -command => sub { ($idx) = $list_box->curselection(); if ( defined $idx ){ $job = $jobs[$idx]; $mw->destroy(); } else { $mw->destroy(); } )->pack(-side => 'bottom', -padx => 10, -pady => 5);
. . . at the end of the subroutine i have
$top->Mainloop(); return $job if defined $job; return 0;
I must be missing something very obvious or I've been looking at the code too long to see my mistake. Because it always returns 0 before I even click 'Continue'.

Thanks for the help.

Replies are listed 'Best First'.
(jcwren) Re: (3) pTk popup not returning value and not locking calling window
by jcwren (Prior) on Oct 10, 2000 at 00:15 UTC
    I'm not a TK guy, but looking at your code, this would occur if $idx wasn't defined. Have you put some debug code at the point to make sure you know which path your're taking on the if (defined $idx) statement?

    --Chris

    e-mail jcwren
      I removed the debugging print statements before I posted here. Everything is set as I expect it to be within this section of code... but the popup doesn't wait... therefore, my calling window/program doesn't ever get the value I have selected.

      To get this project off of my plate I just grew my original window and placed the list into it. But I still have to understand what I'm doing incorrectly because, even though I don't have to use Tk very often, I still have some programs I've inherited that I must maintain. And they're chock full of pTk stuff.

      Thanks for the help.