Monday, 25 June 2012

About Dialogs and Gtk.TreeView

Just finished working on this: open a new dialog with a simple treeview inside and other widgets.
This dialog will be used for searching inside the stock quote table(see the previous post)

First problem first
Adding a new dialog to your project it is easier than you think.. if you know that you should use Quickly (and if your project is quickly based)!

Quickly team make easy to add a new dialog to your project.. just follow this answer.
I wasted an hour searching for an answer on how to manage it with glade3 and finally I found that post.
I like this solution... it is easy to add a new dialog and it manage files for you.. just quickly.

After a dialog finish his task, it return a response code; a list of response code is here.

Second problem.. Treeview, pygtk and Glade
This is a complicated task... information on the net are poor or refers to old version.. but you can do a lot with glade3.
You need to create a TreeView and the associated ListStore.
On the treeview you should define:
  • column list with information
  • the renderer for every column you need like Text, Image or other widget available
On the liststore you have to define:
  •  the column to use with the type for every column (for text gchararray is enough)
  • eventually, any static information you need in the list when the treeview start.
ListStore need to be connected with Treestore and also you need to map every cellrenderer to an attribute on the liststore! For this last point, there is a "Text" property in the tab General of a CellRenderer element.
If you don't map the attribute and you have elements on the liststore, you will probably see 0 lenght string on the treeview.

What now?
Now, I have enough informations to stop hacking and start designing the app.
Also I will try to include the feautres that someone asked on reddit :).
Need to sleep now, it is a working day tomorrow and it's too late!

No comments:

Post a Comment