Native gui usable for data editing. Lots of fixes and improvenemts

This commit is contained in:
thooge committed 2026-11-11 18:58:02 +01:00
1 parent a6abdaa614
commit 09387280fc
52 files changed
+1579 -294

No files matched your search

+35
View File
@@ -15,6 +15,31 @@ def add_column(treeview, label, index, xalign=None, col_fg=None, col_bg=None, vi
col.add_attribute(cell, 'background', col_bg)
treeview.append_column(col)
def create_columns(treeview, columns, keys=0, alignments=None):
"""
columns - is a list of column titles
keys - is the number of the first visible column from the left containing
the identifying column key
alignments - l, c or r
"""
i = 0
visible_cols = len(columns) - keys
if alignments:
alignments = alignments.lower()
if len(alignments) < visible_cols:
alignments += "l" * (visible_cols - len(alignments))
for column in columns:
if not alignments:
add_column(treeview, column, i + keys)
else:
if alignments[i] == 'r':
add_column(treeview, column, i + keys, 1.0)
elif alignments[i] == 'c':
add_column(treeview, column, i + keys, 0.5)
else:
add_column(treeview, column, i + keys)
i += 1
def get_value(treeview, column=0):
"""
Returns the value of the specified column of the linked model
@@ -65,3 +90,13 @@ def set_row_values(treeview, data):
model.set_value(iter, column, value)
column += 1
return True
def remove_selected_rows(treeview):
"""
Removes the currently selected rows from the model
"""
selection = treeview.get_selection()
model, paths = selection.get_selected_rows()
for path in paths:
it = model.get_iter(path)
model.remove(it)