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

+80 -3
View File
@@ -55,6 +55,38 @@ class MeasurementView(View):
self.entry['date'].set_placeholder_text(context.get_datefmt_placeholder())
DatePicker(self.entry['date'], self.button['date'], context.get_datefmt())
self.context.subscribe("dd_mcat_modified", self.category_modified)
self.context.subscribe("dd_unit_modified", self.unit_modified)
self.context.subscribe("equipment_modified", self.equipment_modified)
def get_list_row(self):
unit = self.dd_unit[self.measure.unit]
if self.measure.nval == 1:
value = "{} {}".format(self.measure.val1, unit)
elif self.measure.nval == 2:
value = "{}x{} {}".format(self.measure.val1, self.measure.val2, unit)
elif self.measure.nval == 3:
value = "{}x{}x{} {}".format(self.measure.val1, self.measure.val2, self.measure.val3, unit)
else:
#invalid
value = "#invalid"
return (
self.measure.mid,
self.measure.mname,
value,
self.measure.accuracy,
self.dd_equipment.get(self.measure.eid, ''),
self.measure.note
)
def add_row(self):
treeiter = self.lst_measurement.append(self.get_list_row())
self.tree['measurement'].get_selection().select_iter(treeiter)
def refresh_row(self):
treeview.set_row_values(self.tree['measurement'], self.get_list_row())
def load_list(self):
selected_id = treeview.get_value(self.tree['measurement'])
self.lst_measurement.clear()
@@ -91,6 +123,48 @@ class MeasurementView(View):
# restore previous selected row
selection.select_iter(treeiter)
def equipment_modified(self, eventtype, data):
self.dd_equipment[data[0]] = data[1]
lst = self.combo['equipment'].get_model()
if eventtype == self.context.EVENT_UPD:
for row in lst:
if row[0] == data[0]:
row[1] = data[1]
return
elif eventtype == self.context.EVENT_ADD:
lst.append(data)
else:
# not implemented
pass
def category_modified(self, eventtype, data):
self.dd_category[data[0]] = data[1]
lst = self.combo['category'].get_model()
if eventtype == self.context.EVENT_UPD:
for row in lst:
if row[0] == data[0]:
row[1] = data[1]
return
elif eventtype == self.context.EVENT_ADD:
lst.append(data)
else:
# not implemented
pass
def unit_modified(self, eventtype, data):
self.dd_unit[data[0]] = data[1]
lst = self.combo['unit'].get_model()
if eventtype == self.context.EVENT_UPD:
for row in lst:
if row[0] == data[0]:
row[1] = data[1]
return
elif eventtype == self.context.EVENT_ADD:
lst.append(data)
else:
# not implemented
pass
def clear_record(self):
self.measure.clear()
self.entry['name'].set_text('')
@@ -146,8 +220,8 @@ class MeasurementView(View):
combobox.activate_row(self.combo['unit'], self.measure.unit or 1)
combobox.activate_row(self.combo['accuracy'], self.measure.accuracy)
self.entry['date'].set_text(self.format_date(self.measure.mdate))
combobox.activate_row(self.combo['equipment'], self.measure.eid)
combobox.activate_row(self.combo['category'], self.measure.mcat)
combobox.activate_row(self.combo['equipment'], self.measure.eid or -1)
combobox.activate_row(self.combo['category'], self.measure.mcat or -1)
self.text['note'].get_buffer().set_text(self.measure.note or '')
self.entry['name'].grab_focus()
@@ -253,8 +327,11 @@ class MeasurementView(View):
pass
self.record_unlock()
if self.newrecord:
self.load_list()
#self.load_list()
self.add_row()
self.newrecord = False
else:
self.refresh_row()
self.display_record()
self.topwidget.set_visible_child(self.box['measure_detail'])