# Gtk::TreeView slow?

**URL:** <https://rubytalk.org/t/gtk-treeview-slow/13126>\
**Category:** ruby-talk\
**Created:** [19 August 2004 00:10 UTC](https://rubytalk.org/t/gtk-treeview-slow/13126 "2004-08-19T00:10:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Laughlin](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joe\_Laughlin](https://rubytalk.org/u/Joe_Laughlin)\
**Post date:** [19 August 2004 00:10 UTC](https://rubytalk.org/t/gtk-treeview-slow/13126/1 "2004-08-19T00:10:55Z")

</div>

I'm not sure if I'm asking too much of Gtk::ListView, or if my  
implementation is slowing things down...

I have a Gtk::ListStore. The first column in the model is an object that  
contains about twenty attributes. I then create a Gtk::TreeView that has  
one column per attribute in the object (so, around 20 attributes). I use a  
cell data rendering function to connect each treeview column to each  
attribute in the object.

Each object in the ListStore is updated with new data every X number of  
seconds (five, for example).

It works fine if I have a pretty low amount of objects in the ListStore.  
But if I put 400 objects in the ListStore and all are displayed in the  
TreeView, when updates are applied to the objects, there's a noticable delay  
for when the changes are displayed in the TreeView.

Am I approaching the limits of Ruby/Gtk here, or is something else that I'm  
doing probably inefficient? I would greatly appreciate any suggestions  
anyone has.

Thanks,  
Joe Laughlin

---

<div class="post-metadata">

**Author:** ![Masao\_Mutoh](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@Masao\_Mutoh](https://rubytalk.org/u/Masao_Mutoh)\
**Post date:** [19 August 2004 16:38 UTC](https://rubytalk.org/t/gtk-treeview-slow/13126/2 "2004-08-19T16:38:27Z")

</div>

Hi,

> **···**
>
> On Thu, 19 Aug 2004 09:10:55 +0900 "Joe Laughlin" \<Joseph.V.Laughlin@boeing.com\> wrote:
> 
> > I'm not sure if I'm asking too much of Gtk::ListView, or if my  
> > implementation is slowing things down...
> > 
> > I have a Gtk::ListStore. The first column in the model is an object that  
> > contains about twenty attributes. I then create a Gtk::TreeView that has  
> > one column per attribute in the object (so, around 20 attributes). I use a  
> > cell data rendering function to connect each treeview column to each  
> > attribute in the object.
> > 
> > Each object in the ListStore is updated with new data every X number of  
> > seconds (five, for example).
> 
> If "cell data rendering function" means Gtk::TreeViewColumn#set\_cell\_data\_func(),  
> It is one of slowest method. It's better to avoid to use it.
> 
> Or, have you tried GLib::Object#freeze\_notify, #thaw\_notify?  
> They may make your application faster.
> 
> --  
> .:% Masao Mutoh\<mutoh@highway.ne.jp\>

---

<div class="post-metadata">

**Author:** ![Joe\_Laughlin](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joe\_Laughlin](https://rubytalk.org/u/Joe_Laughlin)\
**Post date:** [19 August 2004 19:55 UTC](https://rubytalk.org/t/gtk-treeview-slow/13126/3 "2004-08-19T19:55:54Z")

</div>

Masao Mutoh wrote:

> Hi,
> 
> > I'm not sure if I'm asking too much of Gtk::ListView, or  
> > if my implementation is slowing things down...
> > 
> > I have a Gtk::ListStore. The first column in the model  
> > is an object that contains about twenty attributes. I  
> > then create a Gtk::TreeView that has one column per  
> > attribute in the object (so, around 20 attributes). I  
> > use a cell data rendering function to connect each  
> > treeview column to each attribute in the object.
> > 
> > Each object in the ListStore is updated with new data  
> > every X number of seconds (five, for example).
> 
> If "cell data rendering function" means  
> Gtk::TreeViewColumn#set\_cell\_data\_func(), It is one of  
> slowest method. It's better to avoid to use it.

Yes, that's the function I'm using. Any ideas on how to avoid using it? Or  
is it best not to store an object in each row in the ListStore and instead  
store the attributes of the objects in the ListStore.

> Or, have you tried GLib::Object#freeze\_notify,  
> #thaw\_notify?  
> They may make your application faster.

I haven't tried that, I will and get back to you.

> **···**
>
> > On Thu, 19 Aug 2004 09:10:55 +0900 \> "Joe Laughlin" \<Joseph.V.Laughlin@boeing.com\> wrote:

---

<div class="post-metadata">

**Author:** ![Joe\_Laughlin](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joe\_Laughlin](https://rubytalk.org/u/Joe_Laughlin)\
**Post date:** [19 August 2004 20:55 UTC](https://rubytalk.org/t/gtk-treeview-slow/13126/4 "2004-08-19T20:55:52Z")

</div>

Joe Laughlin wrote:

> Masao Mutoh wrote:
> 
> > Hi,
> > 
> > > I'm not sure if I'm asking too much of Gtk::ListView, or  
> > > if my implementation is slowing things down...
> > > 
> > > I have a Gtk::ListStore. The first column in the model  
> > > is an object that contains about twenty attributes. I  
> > > then create a Gtk::TreeView that has one column per  
> > > attribute in the object (so, around 20 attributes). I  
> > > use a cell data rendering function to connect each  
> > > treeview column to each attribute in the object.
> > > 
> > > Each object in the ListStore is updated with new data  
> > > every X number of seconds (five, for example).
> > 
> > If "cell data rendering function" means  
> > Gtk::TreeViewColumn#set\_cell\_data\_func(), It is one of  
> > slowest method. It's better to avoid to use it.
> 
> Yes, that's the function I'm using. Any ideas on how to  
> avoid using it? Or is it best not to store an object in  
> each row in the ListStore and instead store the  
> attributes of the objects in the ListStore.
> 
> > Or, have you tried GLib::Object#freeze\_notify,  
> > #thaw\_notify?  
> > They may make your application faster.
> 
> I haven't tried that, I will and get back to you.

[http://ruby-gnome2.sourceforge.jp](http://ruby-gnome2.sourceforge.jp) seems to be down. ☹

Would I call freeze\_notify on the ListStore or on the TreeView?

The rows update on time if I'm scrolling through the TreeView at the same  
time that the data is updated, but if I'm not scrolling, the data shown is  
much behind the updated data. Are there any ways I can fix this?

Thanks,  
Joe

> **···**
>
> > > On Thu, 19 Aug 2004 09:10:55 +0900 \>\> "Joe Laughlin" \<Joseph.V.Laughlin@boeing.com\> wrote:

---

<div class="post-metadata">

**Author:** ![Masao\_Mutoh](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@Masao\_Mutoh](https://rubytalk.org/u/Masao_Mutoh)\
**Post date:** [21 August 2004 16:32 UTC](https://rubytalk.org/t/gtk-treeview-slow/13126/5 "2004-08-21T16:32:42Z")

</div>

Hi,

> **···**
>
> On Fri, 20 Aug 2004 04:55:54 +0900 "Joe Laughlin" \<Joseph.V.Laughlin@boeing.com\> wrote:
> 
> > \> If "cell data rendering function" means  
> > \> Gtk::TreeViewColumn#set\_cell\_data\_func(), It is one of  
> > \> slowest method. It's better to avoid to use it.
> > 
> > Yes, that's the function I'm using. Any ideas on how to avoid using it? Or  
> > is it best not to store an object in each row in the ListStore and instead  
> > store the attributes of the objects in the ListStore.
> 
> Usually, you don't need to use the method if you don't use complex column.  
> I recommand to make your table simple.
> 
> --  
> .:% Masao Mutoh\<mutoh@highway.ne.jp\>

---

<div class="post-metadata">

**Author:** ![Masao\_Mutoh](https://avatars.discourse-cdn.com/v4/letter/m/7993a0/32.png) [@Masao\_Mutoh](https://rubytalk.org/u/Masao_Mutoh)\
**Post date:** [21 August 2004 16:43 UTC](https://rubytalk.org/t/gtk-treeview-slow/13126/6 "2004-08-21T16:43:06Z")

</div>

Hi,

> \>\> Or, have you tried GLib::Object#freeze\_notify,  
> \>\> #thaw\_notify?  
> \>\> They may make your application faster.  
> \>  
> \> I haven't tried that, I will and get back to you.
> 
> [http://ruby-gnome2.sourceforge.jp](http://ruby-gnome2.sourceforge.jp) seems to be down. ☹

Now you can see it, though there is no answer what you want.

> Would I call freeze\_notify on the ListStore or on the TreeView?

I'm not sure. Try it to both classes.

> The rows update on time if I'm scrolling through the TreeView at the same  
> time that the data is updated, but if I'm not scrolling, the data shown is  
> much behind the updated data. Are there any ways I can fix this?

Hmm. Did you try google?

I found some informations, for example:  
[http://www.pygtk.org/pygtk2tutorial/sec-TreeModelInterface.html#sec-LargeDataStores](http://www.pygtk.org/pygtk2tutorial/sec-TreeModelInterface.html#sec-LargeDataStores)

Anyway, try to remove Gtk::TreeViewColumn#set\_cell\_data\_func once.

> **···**
>
> On Fri, 20 Aug 2004 05:55:52 +0900 "Joe Laughlin" \<Joseph.V.Laughlin@boeing.com\> wrote:
> 
> --  
> .:% Masao Mutoh\<mutoh@highway.ne.jp\>

---

<div class="post-metadata">

**Author:** ![Joe\_Laughlin](https://avatars.discourse-cdn.com/v4/letter/j/ed8c4c/32.png) [@Joe\_Laughlin](https://rubytalk.org/u/Joe_Laughlin)\
**Post date:** [23 August 2004 18:55 UTC](https://rubytalk.org/t/gtk-treeview-slow/13126/7 "2004-08-23T18:55:43Z")

</div>

Masao Mutoh wrote:

> Hi,
> 
> > > > Or, have you tried GLib::Object#freeze\_notify,  
> > > > #thaw\_notify?  
> > > > They may make your application faster.
> > > 
> > > I haven't tried that, I will and get back to you.
> > 
> > [http://ruby-gnome2.sourceforge.jp](http://ruby-gnome2.sourceforge.jp) seems to be down. ☹
> 
> Now you can see it, though there is no answer what you  
> want.
> 
> > Would I call freeze\_notify on the ListStore or on the  
> > TreeView?
> 
> I'm not sure. Try it to both classes.
> 
> > The rows update on time if I'm scrolling through the  
> > TreeView at the same time that the data is updated, but  
> > if I'm not scrolling, the data shown is much behind the  
> > updated data. Are there any ways I can fix this?
> 
> Hmm. Did you try google?
> 
> I found some informations, for example:

[http://www.pygtk.org/pygtk2tutorial/sec-TreeModelInterface.html#sec-LargeDataStores](http://www.pygtk.org/pygtk2tutorial/sec-TreeModelInterface.html#sec-LargeDataStores)

Thanks for the link, but my problem is not adding new rows to the ListStore,  
it's showing the update when the object(s) in the ListStore are updated.

> **···**
>
> > On Fri, 20 Aug 2004 05:55:52 +0900 \> "Joe Laughlin" \<Joseph.V.Laughlin@boeing.com\> wrote:
> 
> > Anyway, try to remove  
> > Gtk::TreeViewColumn#set\_cell\_data\_func once.
