PHP-GTK2 Cookbook Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Re:treeview and glade (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Re:treeview and glade


#5308
tomkuanq0705 (User)
Junior Boarder
Posts: 30
graphgraph
User Offline Click here to see the profile of this user
treeview and glade 11 Months, 3 Weeks ago Karma: 0  
Hi,

I am Tom Kuanq.
It's my first time codeing treeview with glade.
I got one Glade treeview.
Code:
<widget class="GtkTreeView" id="treeview_diff">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
And codes
Code:
function show_content()
{
$scrolledwindow_diff->set_policy( Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);
if(defined("GObject::TYPE_STRING"))
{
  $model=new GtkListStore(GObject::TYPE_STRING,GObject::TYPE_STRING);
}
else
{
  $model=new GtkListStore(Gtk::TYPE_STRING,Gtk::TYPE_STRING);
}
$field_header=array('A','B');
$field_justification=array(1.0,1.0);

$view=$treeview_diff->get_model();

for($col=0;$col<count($field_header);++$col)
{
$cell_renderer=new GtkCellRendererText();
$cell_renderer->set_property("xalign",$field_justification[$col]);
$cell_renderer->set_property('editable',true);
$cell_renderer->connect("edited","on_edit_done_showdiff",$view,$col);
$cell_renderer->connect("editing-started","on_editing_started_en_cell_showdiff",$view,$col);

$column = new GtkTreeViewColumn($field_header[$col],$cell_renderer,'text',$col);
$column->set_alignment($field_justification[$col]);
$column->set_sort_column_id($col);
$column->set_resizable(true);
$column->set_min_width(1);

$label = new GtkLabel($field_header[$col]);
$label->modify_font(new PangoFontDescription(""));
$label->modify_fg(Gtk::STATE_NORMAL, GdkColor::parse("#0000FF"));
$column->set_widget($label);
$label->show();

$column->set_cell_data_func($cell_renderer, "format_col_showdiff", $col);
$treeview_diff->append_column($column);
}

for($row=0;$row<count($data);++$row)
{
$values=array();
for($col=0;$col<count($data[$row]);++$col)
{
$values[]=$data[$row][$col];
}
$model->append($values);
}
return $view;
}
can not see any content ! this is my first time codeing treview with glade. Please help me. Thank you very much ! Tom Kuanq 2012.06.02.
 
  The administrator has disabled public write access.

#5312
kksou (Admin)
Admin
Posts: 1678
graph
User Online Now Click here to see the profile of this user
Re:treeview and glade 11 Months, 2 Weeks ago Karma: 27  
Hi Tom,

Did you include the whole code? Because I didn't see the code:
$glade = new GladeXML('helloglade.glade');
that loads the glade file.

I also don't see the code: $glade->get_widget() that loads the treeview widget.

Have you read the Glade tutorial in the official PHP-GTK site:
Hello Glade!

This is a very good tutorial. I started learning about PHP-GTK Glade from this.

If you haven't read this, please do take a look at it.

Regards,
/kksou
 
  The administrator has disabled public write access.

#5319
tomkuanq0705 (User)
Junior Boarder
Posts: 30
graphgraph
User Offline Click here to see the profile of this user
Re:treeview and glade 11 Months, 2 Weeks ago Karma: 0  
hi,

thank you for reply.

the code :
$view=$treeview_diff->get_model();
=====>
$view=$treeview_diff->set_model($model);

then
it works very well. ^.^

Tom Kuanq 2012.06.07
 
  The administrator has disabled public write access.



Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop

Blog - Forum - Privacy Policy - Contact Us
Links - Classes - Social Business - BPM - Web - General
Copyright © 2006-2013. kksou.com. All Rights Reserved