in reply to Problems after upgrading both Perl and Tk

Okay, let me start over and try again. My previous reply was totally irrelevant (though I do like the cleaner technique, which I hope is helpful in its own right).

I managed to get consistent and (presumably close to) intended resizing results by changing this:

$wjLabEntry->destroy; $mode_buttons->destroy; $wjLabEntry = $mw->Frame(-bg => "wheat1")->pack(); $mode_buttons = $mw->Frame(-bg => "wheat1")->pack();
to this:
$_->destroy for ( $wjLabEntry->children ); $_->destroy for ( $mode_buttons->children );
That might not end up doing exactly what you want, but at least the window remains large enough to be usable and in fact gets bigger as needed. And at least it makes a certain amount of sense: Tk's pack manager will work better if the containing frames remain intact, as opposed to being destroyed and rebuilt from scratch.

Apart from that, if you pass those two frame widget handles as params to "do_setup" when calling it from get_job, you would be able to add "use strict" without any additional global variables, which would be a Good Thing.

And you can drop all the use Tk::*; lines -- just use Tk; will suffice. Ditto for all the  $mw->update calls (those just aren't needed in this situation).

FINAL UPDATE: I'm guessing that the unpredictable behavior I was seeing with the OP code is probably related to the relatively recent Perl 5 feature that enhanced the security of hash key management -- this feature may have been missing in the ancient Solaris environment that the OP code came from, and in that old environment the code was probably always working because the Tk internal hashes were always being stored (and accessed/destroyed) in a consistent order. That consistency goes away in current Perl versions, which could mean that from one run to the next, calling "destroy" on the two frames that make up your entire MainWindow might cause variable results, depending on what gets destroyed first... But that's just a guess.

Anyway, I also noticed that since you don't seem to use the "$wjLabEntry" frame ever again, you can destroy that one, and just keep the "$mode_buttons" frame (destroying its children only). That would probably result in the appearance that you really want.

Replies are listed 'Best First'.
Re^2: Problems after upgrading both Perl and Tk
by monksp (Acolyte) on Jul 10, 2009 at 21:05 UTC
    Works like a charm, thanks so much.

    I'm suspecting that you're right with the reasoning behind the cause of the sudden change. I was thinking along the same lines, but couldn't find much reference online that steered me towards the reasons.

    I also appreciate the style guides, but I'm afraid that this code belongs to one of my coworkers, and fixing it only fell to me since I'm handling the Linux conversion. I seem to be the only person here that really wants to do any kind of 'best practice' style of coding. The segment of code I posted was ripped out of a much larger piece of software which likely would have made you cringe if you'd seen it. ;)

    UPDATE: Bah. Still this thing taunts me. If you go a little farther down in the code, there's another MainWindow Frame that gets created, $PartStep. Everything packs and resizes properly up until that appears. Now it's just that section, but I still have to grab the bottom of the window and pull it down until it's tall enough to show that section.

    UPDATE TO THE UPDATE: Seems the solution to this was to move the point where $PartStep got created. I moved the creation/pack up to where the others got created, and then left the population part where it was, and that seemed to take care of the problem.