Reputation: 81
I have a simple GTK GUI with a treeview on it. It gives the following errors when I drag columns to reorder. How this problem could be fixed?
Warnings:
Gtk-WARNING **: 15:43:03.151: Negative content width -8 (allocation 1, extents 5x4) while allocating gadget (node button, owner GtkButton)
Gtk-WARNING **: 15:43:03.151: Negative content height -1 (allocation 1, extents 1x1) while allocating gadget (node button, owner GtkButton)
Gtk-WARNING **: 15:43:05.886: Negative content width -8 (allocation 1, extents 5x4) while allocating gadget (node button, owner GtkButton)
Simplified Code:
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GLib
builder = Gtk.Builder()
builder.add_from_file('test.glade')
window1 = builder.get_object('window1')
treeview1 = builder.get_object('treeview1')
class Signals:
def on_window1_destroy(self, widget):
Gtk.main_quit()
list_data = [["text1", "data1", "data2"], ["text2", "data1", "data2"], ["text3", "data1", "data3"]]
treestore1 = Gtk.TreeStore(str, str, str)
piter1 = treestore1.append(None, list_data[0])
piter2 = treestore1.append(piter1, list_data[1])
piter3 = treestore1.append(piter1, list_data[2])
treeview1.set_model(treestore1)
for i, column_title in enumerate(["col1", "col2", "col3"]):
renderer = Gtk.CellRendererText()
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
treeview1.append_column(column)
column.set_sort_column_id(i)
column.set_resizable(True)
column.set_reorderable(True)
treeview1.expand_all()
builder.connect_signals(Signals())
window1.show_all()
Gtk.main()
Software versions: GTK 3, Python 3.8.
Important:
listview
in my previous attempts.Upvotes: 4
Views: 420
Reputation: 549
If setting the sizing property to gtk.TREE_VIEW_COLUMN_GROW_ONLY
does not prevent the warnings and the warnings don't make the application crash, it is safe to let them there by now. It seems a GTK bug.
If you are interested in check the repo issues GTK negative content issue but it does not promise much; they haven't been solved. So, though the warnings are annoying, they seem to be inoffensive
Upvotes: 0
Reputation: 348
I have had the same problems with a GTK listview a long time ago. I could not fix the problem. But it may be a bug of the software. There are some examples on the web that contains similar problems (link1, link2).
They have negative column warnings when treeview columns are resized to 0 or column header buttons are moved in order to reorder them. GTK versions are 3.22 and 3.24 for them. I do not know if it is fixed, I do not have the latest version installed.
Upvotes: 2