Re: Python3, GObject objects & models

2018-12-19 Thread Marius Gedminas
On Tue, Dec 18, 2018 at 01:01:45PM -0500, Adam Tauno Williams wrote:
> I have created, and registered, a custom GObject type [an object].  I
> can place that type into a ListModel: aka model =
> Gtk.ListModel(MyClass).
> 
> One of the advantages of creating a GObject is the whole property
> system - - - and most notably change signals.
> 
> What I have not been able to find is how to connect/map something like
> a Gtk.CellRendererText to a property, such that having a type in a
> model has some advantage [vs. a model like (int, str, str)].  ???

I think you have to use Gtk.TreeViewColumn.set_cell_data_func(), but I
also fail to see any advantages you'd get of doing that instead of using
plain data types in the model.

Marius Gedminas
-- 
Remember the... the... uhh.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: Python3, GObject objects & models

2018-12-19 Thread Reuben Rissler
So I am assuming that you are looking for a discussion and not for a 
specific problem to be solved. If this is not the case, please post the 
code that is not working for you, delete my email and forgive me.



On 12/18/2018 01:01 PM, Adam Tauno Williams wrote:

I have created, and registered, a custom GObject type [an object].  I
can place that type into a ListModel: aka model =
Gtk.ListModel(MyClass).

One of the advantages of creating a GObject is the whole property
system - - - and most notably change signals.
And how exactly does that improve on the /model.connect("row-changed")/, 
and the signal family already in place?


What I have not been able to find is how to connect/map something like
a Gtk.CellRendererText to a property, such that having a type in a
model has some advantage [vs. a model like (int, str, str)].  ???
For myself, I use Glade for all the Treeviews I can as I would rather 
see the Treeview I build than try to memorize the construction of code. 
My few attempts in trying to subclass Treeview components got more messy 
than just hooking into their signal system and tweaking the data as it 
goes from point A to point B.


In the case I have in mind, I was trying to add a autocomplete feature 
to a Gtk.CellRendererCombo. I finally discovered that Gtk already has a 
provision for that by providing a /editing-started/ signal to add the 
autocomplete object to the entry inside the combo.


With that said, I have tens of Treeviews in my accounting system, and am 
always on the lookout for more fluent/better ways of showing data.


One other case worth mentioning was trying to get a Decimal column to 
play nicely in a Treeview (floats are not acceptable in accounting). I 
could use a PyObject type and display it using cell renderer display 
functions. However, when filtering and sorting, all manner of extra code 
had to be added to work with the Decimals. In the end it was faster and 
easier to use a two column approach, a /str/ for display and an /float/ 
for sorting. Then all the calculations are done in SQL, server side.


Yours,
Reuben
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Python3, GObject objects & models

2018-12-18 Thread Adam Tauno Williams
I have created, and registered, a custom GObject type [an object].  I
can place that type into a ListModel: aka model =
Gtk.ListModel(MyClass).

One of the advantages of creating a GObject is the whole property
system - - - and most notably change signals.

What I have not been able to find is how to connect/map something like
a Gtk.CellRendererText to a property, such that having a type in a
model has some advantage [vs. a model like (int, str, str)].  ???


-- 
Adam Tauno Williams  GPG D95ED383
OpenGroupware Developer 
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list