Re: Editable tables and general planning help

From: Date: Sat, 09 Jul 2005 03:17:21 +0000
Subject: Re: Editable tables and general planning help
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-5935@lists.php.net to get a copy of this message
Hi to all, I have coded a little snippet to test the GtkSheet widget, and I think it goes really fast, and hope will show Jake how quick PHP-GTK can be. In my experience, GtkSheet could seem a bit buggy at first, but soon when you know how to handle it, just work fine. No hidden column or row headings, etc. Note: On the other hand I was having some memory leaks using GtkSheet, but only if on an existing not empty sheet, I called first the 'delete_rows', then insert the needed rows and finally call 'rows_labels_set_visibility', in some cases it causes a Glib - Gmem dialog error telling 'could not store x bytes' and next sometimes it causes PHP to crash. Not using these instructions mended the memory leaks. Regards, Gonzalo <?php if (!extension_loaded('gtk')) {
       dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);
} // Create the window: $w = &new GtkWindow; $w->set_title('Testing the GtkSheet'); $w->connect('destroy', create_function('','Gtk::main_quit();')); $w->set_position(GTK_WIN_POS_CENTER); $w->set_default_size((gdk::screen_width()/1.5), (gdk::screen_height()-20)); // Create the widgets:
   $box        =& new GtkVBox(false, 5);
   $scrollw    =& new GtkScrolledWindow();
   $sheet      =& new GtkSheet(100, 22, "sheet");
   $button     =& new GtkButton("Reset");
     $button->connect('clicked', "SheetRenewData");
     // Let's pack the widgets:
$box->pack_start($scrollw, true, true, 0); $box->pack_start($button, false, false, 0); // Configure the sheet: $sheet->set_selection_mode(0); $sheet->set_column_titles_height(21); $sheet->set_row_titles_width(25); $sheet->show_all(); // Insert data for the first time: $count = 0; SheetRenewData(); // Finally pack it to the window: $scrollw->add($sheet); $w->add($box); $w->show_all(); Gtk::main(); function SheetRenewData() {
       global $count, $sheet;
                 $sheet->freeze();
             for($row = 0; $row<=100; $row++) {
                 // Lets adjust the row height for the first time:
           if ($count == 0) {
               $sheet->set_row_height($row,21);
           }
                     for ($col = 0; $col<=22; $col++) {
               // Set the sheet cell data:
               $sheet->set_cell($row, $col, 1, "$count-$row");
                             // Lets adjust column width for the first time:
               if (($row == 0) && ($count == 0)){
                   $sheet->set_column_width($col, 50);
               }
                             if ($count == 0)
                   $sheet->row_set_sensitivity($row, false);
           }
       }
             //$sheet->rows_labels_set_visibility(false);
             $sheet->thaw();
       $sheet->show_all();
             // Keep track of reset count:
       $count++;
} ?> Jake Gordon escribió:
Hi again, I tried GtkSheet but for some reason it doesn't display column and row headings until you go into a cell on the row/column. It seems a bit buggy. Also, it seems stuck at a fixed size so if there are too many rows or columns it can't display them all. Instead for now I've created a grid with GtkTable and GtkEntry and the functionality seems fine for what I need. However, my desired grid size is 22 columns and 100 rows. The program has great difficulty doing this - taking about 30 seconds to load, and then often crashing, possibly due to PHP max execution settings or something. Either way, not desirable. If its possible to get this table to load in a second or two then I'm set... if not then I think I'll have to stop playing with PHP-GTK and just go back to a web based interface. Here's my code for the grid. Perhaps someone can suggest a way to do this without having the application take ages and/or crash?: --- $table = &new GtkTable(); $vbox->add($table); $table->set_row_spacings(0); $table->set_col_spacings(0);
               $rows = 1000;
$cols = 22; // Do $rows rows for($row=1;$row<=$rows;$row++) { // Do $cols columns for($col=1;$col<=$cols;$col++) { ${'text_'.$col.'_'.$row} = &new GtkEntry(); ${'text_'.$col.'_'.$row}->set_text($row.".".$col); ${'text_'.$col.'_'.$row}->set_usize(40, -1); $table->attach(${'text_'.$col.'_'.$row}, $col, $col+1, $row, $row+1, GTK_SHRINK, GTK_SHRINK); } } $table->show_all(); --- Also, PHP seems not to release memory when I $widget->destroy(). Should it do? Or is there a different suggested way to release memory? e.g. I have five 'pages' in my application. When I go to one page the widget for the page that was showing before is destroyed. However, the memory it used doesn't seem to be release. Jake. Ivan Rodriguez wrote:
PHP-GTK 1.0.1 version has all widgets, GtkSheet GtkPlot and other, the GtkExtra widgets and GtkScintilla and others too On 7/7/05, Jake Gordon <php-gtk@jakeg.co.uk> wrote:
Ivan Rodriguez wrote:
I recommend you to see the widget GtkSheet is all what you need.
This seems to be an 'extra' which is no longer maintained. Where can I get it from? I'm on Windows. Apparently I need a .dll as well. Jake. -- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.gtk.general (#5935) next »