Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Problem in row deletion with Tk::Table

by Anonymous Monk
on Aug 30, 2013 at 07:47 UTC ( [id://1051561]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Problem in row deletion with Tk::Table
in thread Problem in row deletion with Tk::Table

I had a look at csgrouper.pl, sorry, that is way too much code (7k lines). Here is the idea
#!/usr/bin/perl -- use strict; use warnings; use Tk; my $mw = tkinit; my $Section_tblw = $mw->Table( ... 20 lines or less MainLoop;

If you can get it down to 20 lines + boilerplate, we might make some progress

Replies are listed 'Best First'.
Re^4: Problem in row deletion with Tk::Table
by emilbarton (Scribe) on Aug 30, 2013 at 08:40 UTC
    Here's your standalone:
    UPDATE: using choroba's solution in Table constructor, doesn't change the issue.
      You seem to not define the number of rows for the table, so it defaults to 10. If you call clear, only the first 10 lines are deleted. Add
      -rows => 100

      to the table constructor parameters and everything works.

      BTW, you can chomp @vals and push @rows, \@vals.

      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Thanks for the tips, but regarding the table your solution doesn't help. It behaves exactly the same whether I set rows => 100 or not. Anyway I was only testing within the first 10 rows.

      :) Ignoring all the issues with your code with short-circuit

      sub section_del { return $Section_tblw->clear;
      looks like Tk::Table is not deleting checkboxes

      so I replace that with  return my_clear( $Section_tblw ); and one or three dd-Dumper-ings later, its an off-by-one error in clear

      sub my_clear { my $self = shift; my $rows = $self->cget( -rows ); my $cols = $self->cget( -columns ); ## 1st row is labels foreach my $r ( 1 .. $rows ) { #~ foreach my $c ( 1 .. $cols ) { ## 1st column is 1st column foreach my $c ( 0 .. $cols ) { my $old = $self->get( $r, $c ); next unless $old; $self->LostSlave( $old ); $old->destroy; } } $self->_init; $self->QueueLayout( Tk::Table::_SlaveSize() ); } ## end sub my_clear

      I imagine the OBO error migt stem because at one point the first column in each row might have been a counter (nth row) ...

        Great, this is it! I'll try updating Tk::Table too. Many thanks!
        hmm, considering chorobas comment, maybe the row/col start indexes in clear ought to consider -fixedrows / -fixedcolumns

        but, I really don't know my way around Tk::Table :) so I've no idea what it/clear should actually do

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-19 04:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found