Re: Dynamic Build Types for GtkListStore.
| From: | Eddie Hixson | Date: | Fri, 07 Apr 2006 18:50:43 +0000 |
| Subject: | Re: Dynamic Build Types for GtkListStore. | ||
| References: | 1 2 3 4 5 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6843@lists.php.net to get a copy of this message | ||
Andrei,
Here is the code to build the store.
The variable $keys is the array of column names from mysql query.
$ListStoreTypes = array();
$ListStoreTypes = array_fill(0,count($keys),Gtk::TYPE_STRING);
$store = new GtkListStore();
$store->set_column_types($ListStoreTypes);
do {
for($i=0; $i < count($data)/2; $i++) {
$row_data[$i] = $data[$i];
}
$store->append($row_data);
}while ($data = mysql_fetch_array($result));
$treeview = new GtkTreeView($store);
$treeview->set_model($store);
//the text renderer is used to display text
$cell_renderer = new GtkCellRendererText();
//Create the column list
for ($i=0;$i<count($keys);$i++) {
$column[$i] = new GtkTreeViewColumn($keys[$i], $cell_renderer,
'text', $i);
$column[$i]->set_resizable(true);
$column[$i]->set_sort_column_id($i);
$treeview->append_column($column[$i]);
}
$scrolled_win->add($treeview);
Regards,
Eddie
On Fri, 2006-04-07 at 10:40 -0700, Andrei Zmievski wrote:
> Can you paste in the code you're using?
>
> -Andrei
>
> On Apr 7, 2006, at 5:47 AM, Eddie Hixson wrote:
>
> > Andrei,
> >
> > Thank you for response and quick fix in the code. That is exactly what
> > I was looking to do in my application. The program is working but does
> > create this CRITICAL ERROR.
> >
> > (sm_MySql.php:16162): Gtk-CRITICAL **: gtk_list_store_set_n_columns:
> > assertion `n_columns > 0' failed
> >
> > Is this error related to your new implementaion of the override?
> > OR
> > Do I have another issue I need to be looking for?
> >
> > "YOU ARE THE MAN"
> >
> > Regards,
> > Eddie
> >
>