Re: Link Gtk.ListStore to the real data

2018-06-02 Thread '-'
Swap items in your data_list in response to rows-reordered signal on the model? 
As for data_list, in your example you have multiple sources but the data_list 
is only one, so working on it makes sense. Could you try applying these 
suggestions to your example so we can see what doesn't work?

On June 3, 2018 12:47:30 AM GMT+03:00, c.bu...@posteo.jp wrote:
>On 2018-06-02 20:07 '-'  wrote:
>> Can you make the data_list a field on your class? It's a list
>> with indices, right? Then, on the iter you get from your selection,
>> use gtk_tree_model_get_path and gtk_tree_path_get_indices. Finally
>> get the item from your data_list by that index.
>
>You mean e. g. if the first row in the view is selected then it must be
>the first item in the 'data_list'?
>
>In that case I have to take care about that the order of the data
>items is the same then in the view. This is impossible because
> - the view can modify the ordering based on the columns
> - the view use more then one data_list at the same time.
>___
>gtk-app-devel-list mailing list
>gtk-app-devel-list@gnome.org
>https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Link Gtk.ListStore to the real data

2018-06-02 Thread c.buhtz
On 2018-06-02 20:07 '-'  wrote:
> Can you make the data_list a field on your class? It's a list
> with indices, right? Then, on the iter you get from your selection,
> use gtk_tree_model_get_path and gtk_tree_path_get_indices. Finally
> get the item from your data_list by that index.

You mean e. g. if the first row in the view is selected then it must be
the first item in the 'data_list'?

In that case I have to take care about that the order of the data
items is the same then in the view. This is impossible because
 - the view can modify the ordering based on the columns
 - the view use more then one data_list at the same time.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Link Gtk.ListStore to the real data

2018-06-02 Thread Eric Cashon via gtk-app-devel-list


Try a relational database. Sqlite is an easy one to use. It can sort and save 
data to multiple tables. Use the list model and treeview to retrieve and view 
the data. That way the columns can be set up dynamically along with the 
renderer. Use SQL to update the database.

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


Re: Link Gtk.ListStore to the real data

2018-06-02 Thread '-'
Hello. Can you make the data_list a field on your class? It's a list with 
indices, right? Then, on the iter you get from your selection, use 
gtk_tree_model_get_path and gtk_tree_path_get_indices. Finally get the item 
from your data_list by that index.

On June 2, 2018 3:09:25 PM GMT+03:00, c.bu...@posteo.jp wrote:
>Does no one has an idea?
>Am I the only one facing such problems?
>
>https://stackoverflow.com/q/50643938/4865723
>
>On 2018-05-31 23:59  wrote:
>> I am looking for an elegant and pythonic way to connect the model of
>a
>> Gtk.ListStore (the content container for a Gtk.TreeView) to the real
>> data.
>> 
>> Thinking the C-way I would store a pointer as a hidden column linking
>> to the data structure in each entry of Gtk.ListStore. But I don't see
>> a way to do this.
>> 
>> The data is just one or more lists of dictionaries. The point is that
>> the Gtk.ListStore can represent on complete data list or only a
>> selection of some entries of multiple data lists. It is important to
>> know that the entries doesn't have a unique key. A data list could
>> look like this:
>> 
>> data_list = [
>> {
>> 'title': 'A title',
>> 'read_status': False
>> },
>> {
>> 'title': 
>> }]
>> 
>> Imagine news or mail messages. The font is bold if 'read_status' is
>> False and otherwise. When I click on an entry in the Gtk.TreeView the
>> font is modified from bold to normal. But the entry in the data list
>> should know this also! But how does the Gtk.TreeView or the
>> Gtk.ListStore entry know the real data?
>> 
>> How do you solve such problems?
>> 
>> I could create unique keys for each data list entry and store this
>> keys in a hidden column in the Gtk.ListStore. But this would blow up
>> the (real) code and would cause some other problems I need to deal
>> with. What is about pythons id() function? Or is there any other
>> solution? ___
>> gtk-app-devel-list mailing list
>> gtk-app-devel-list@gnome.org
>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
>
>___
>gtk-app-devel-list mailing list
>gtk-app-devel-list@gnome.org
>https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: Link Gtk.ListStore to the real data

2018-06-02 Thread c.buhtz
Does no one has an idea?
Am I the only one facing such problems?

https://stackoverflow.com/q/50643938/4865723

On 2018-05-31 23:59  wrote:
> I am looking for an elegant and pythonic way to connect the model of a
> Gtk.ListStore (the content container for a Gtk.TreeView) to the real
> data.
> 
> Thinking the C-way I would store a pointer as a hidden column linking
> to the data structure in each entry of Gtk.ListStore. But I don't see
> a way to do this.
> 
> The data is just one or more lists of dictionaries. The point is that
> the Gtk.ListStore can represent on complete data list or only a
> selection of some entries of multiple data lists. It is important to
> know that the entries doesn't have a unique key. A data list could
> look like this:
> 
> data_list = [
> {
> 'title': 'A title',
> 'read_status': False
> },
> {
> 'title': 
> }]
> 
> Imagine news or mail messages. The font is bold if 'read_status' is
> False and otherwise. When I click on an entry in the Gtk.TreeView the
> font is modified from bold to normal. But the entry in the data list
> should know this also! But how does the Gtk.TreeView or the
> Gtk.ListStore entry know the real data?
> 
> How do you solve such problems?
> 
> I could create unique keys for each data list entry and store this
> keys in a hidden column in the Gtk.ListStore. But this would blow up
> the (real) code and would cause some other problems I need to deal
> with. What is about pythons id() function? Or is there any other
> solution? ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

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