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

+33 -5
View File
@@ -5,7 +5,7 @@ from gi.repository import Gtk
from dateutil.parser import parse
from gettext import pgettext
from .view import View
from .view import View, DatePicker
from yms import gtkutils, combobox, treeview
from yms.model import project
@@ -37,6 +37,26 @@ class ProjectsView(View):
self.dd_state = self.context.lookup.enum('project.projstate')
combobox.load_from_dict(self.combo['status'], self.dd_state)
self.entry['date_start'].set_placeholder_text(context.get_datefmt_placeholder())
DatePicker(self.entry['date_start'], self.button['date_start'], context.get_datefmt())
def get_list_row(self):
return (
self.project.projid,
self.project.projname,
self.format_date(self.project.startdate),
self.project.duration,
self.dd_state.get(self.project.projstate, ''),
self.project.remarks
)
def add_row(self):
treeiter = self.lst_projects.append(self.get_list_row())
self.tree['projects'].get_selection().select_iter(treeiter)
def refresh_row(self):
treeview.set_row_values(self.tree['projects'], self.get_list_row())
def load_list(self):
selected_id = treeview.get_value(self.tree['projects'])
self.lst_projects.clear()
@@ -87,7 +107,7 @@ class ProjectsView(View):
self.entry['name'].set_text(self.project.projname)
combobox.activate_row(self.combo['responsible'], self.project.responsible)
self.entry['date_start'].set_text(self.format_date(self.project.startdate))
if self.project.costs_plan:
if self.project.duration:
self.spin['duration'].set_value(self.project.duration)
else:
self.spin['duration'].set_text('')
@@ -108,8 +128,13 @@ class ProjectsView(View):
self.project.vid = self.context.vessel.vid
self.project.projname = self.entry['name'].get_text()
self.project.responsible = combobox.get_list_value(self.combo['responsible'])
self.project.costs_plan = int(self.spin['costs_plan'].get_value())
self.project.costs_final = int(self.spin['costs_final'].get_value())
try:
self.project.startdate = parse(self.entry['date_start'].get_text(), dayfirst=True)
except ValueError:
self.project.startdate = None
self.project.duration = self.spin['duration'].get_value_as_int()
self.project.costs_plan = self.spin['costs_plan'].get_value_as_int()
self.project.costs_final = self.spin['costs_final'].get_value_as_int()
self.project.projstate = combobox.get_list_value(self.combo['status'])
self.project.remarks = gtkutils.get_text_contents(self.text['remarks'])
@@ -177,8 +202,11 @@ class ProjectsView(View):
return
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['proj_detail'])