Re: Link Gtk.ListStore to the real data



Well, what you want is a way to catch/handle the data that always changes
and you want to show it on screen in anytime, right? There's no good
solutions for that, I mean you must make an algorithm to do that by
yourself. Why? Don't always lets Gtk or QT or something else stores our
data because the users often do what we will not know. Remember Gtk is a
tool to render what you want to the user on the screen.

My recommendation you can use Json/Xml or something else for
storing/getting the data.

On Fri, Jun 1, 2018 at 4:59 AM, <c buhtz posteo jp> 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]