Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: failed AUTOLOAD widgets when trying to destory widget

by zentara (Archbishop)
on Oct 26, 2012 at 11:37 UTC ( #1001050=note: print w/ replies, xml ) Need Help??


in reply to failed AUTOLOAD widgets when trying to destory widget

I recognize that reusable toplevel code. When I run your code, all I needed to do was ( in addition to use warnings; use strict; ) was to add a global my $tl

Then the code runs fine, with a warning that on subsequent invoking of the reusable toplevel $tl, the Text widget from the last invocation will be gone.

So just add a global my $tl;

The whole idea of the reusable toplevel was to prevent memory gains, and this code may be such a beast. Everytime you run the toplevel, the private Text widget it contained gets stuffed aside into no-man's land, where memory accumulates. The Text widget I included with that toplevel example, is not needed. If you do need a persistent Text widget, for that reusable toplevel, just make my $text; a global variable, rather than just scoped to the toplevel subroutine.


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh


Comment on Re: failed AUTOLOAD widgets when trying to destory widget
Re^2: failed AUTOLOAD widgets when trying to destory widget
by reaper9187 (Scribe) on Oct 26, 2012 at 12:06 UTC
    pardon the stupid question, but how do you invoke the grid manager for top level windows, I've been tryin to do it like this:
    my $frame = $tl->Frame()->pack; my $lab = $tl->Label()->pack; my $ent = $tl->Entry()->pack; my $label = $frame -> Label(-text=>"NQR Reports "); $lab -> grid(-row=>0,-column=>0); $ent -> grid(-row=>0,-column=>1); $label -> grid(-row=>0,-column=>0); $frame -> grid(-row=>2,-column=>1,-columnspan=>2); my $but1 = $tl->Button( -text => 'Open File1', -command => $push_butt +on2 )->pack; $but1 -> grid(-row=>2,-column=>2,-columnspan=>2);

    The code starts executing but the top level window is never created and the system jus hangs .. Any suggestions ??
      As far as I know, you can't mix pack and grid. First you pack() your widgets, then you try to use grid() on them, you can't. See Geometry Management

      Here is a simple grid usage:

      #!/usr/bin/perl use warnings; use strict; use Tk; use Data::Dumper; my $top = new MainWindow(); #my %items = ( A => [1,1a], B => [2,2a], C => [3,3a] ); my $count = 0; my %items = (); for('A'..'Z','a'..'z'){ $count++; $items{$_} = [$count, "$count-a"]; } my $row = 0; foreach my $item ( sort keys(%items) ) { #print @{$items{$item}},"\n"; $top->Label( -text => $item, -anchor => "w", -relief => 'solid', #will show gridlines )->grid( -row => $row, -column => 0 ); $top->Entry( -textvariable => \$items{$item}[0], -width => 5, -relief => 'solid', #will show gridlines )->grid( -row => $row, -column => 1 ); $top->Entry( -textvariable => \$items{$item}[1], -width => 5, -relief => 'solid', #will show gridlines )->grid( -row => $row, -column => 2 ); $row++; } MainLoop();

      I'm not really a human, but I play one on earth.
      Old Perl Programmer Haiku ................... flash japh
        i realized my mistake later and tried it without packing it ..
        It works Now ..!!! THank you so much ..!!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001050]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2015-07-03 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls