Cannot delete an object from FlowBox

I have a FlowBox with objects and I need to perform sorting of them. I’m adding them all to dict and then sorting it. But when I’m trying to delete all objects to add them from sorted dictionary, I’m getting this error:
Gtk-CRITICAL **: 01:53:04.731: gtk_flow_box_child_set_child: assertion 'child == NULL || priv->child == child || gtk_widget_get_parent (child) == NULL' failed
As I researched, this happening because one of the objects isn’t removing from its parent. But when I’m trying to manually delete its parent, I can’t do this.
So, what should I do with this?:cry:

def sorting(method):
    cards = {}
    for child in shared.win.music_lib:
        cards[f"{child.get_child().get_title()}"] = child.get_child()
    if method == "a-z":
        cards = dict(sorted(cards.items()))
    else:
        cards = dict(sorted(cards.items(), reverse=True))
    shared.win.music_lib.remove_all()
    for key in cards:
        card = cards[key]
        shared.win.music_lib.append(card)

Why not use Gtk.FlowBox.set_sort_func() ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.