Native gui first steps: storage, box and companies are editable

This commit is contained in:
thooge committed 2026-10-21 17:16:55 +02:00
1 parent 1eea4058bf
commit 06a9834688
47 files changed
+3119 -883

No files matched your search

+66 -14
View File
@@ -43,14 +43,67 @@ class ProjectsView(View):
treeview.add_column(self.tree['projects'], _('Remarks'), 5)
self.tree['projects'].set_model(self.lst_projects)
# Responsible
self.dd_user = context.lookup.user()
combobox.load_from_dict(self.combo['responsible'], self.dd_user)
# Status
self.dd_state = self.context.lookup.enum('project.projstate')
combobox.load_from_dict(self.combo['status'], self.dd_state)
def clear_record(self):
self.project.clear()
self.entry['name'].set_text('')
combobox.activate_row(self.combo['responsible'], 0)
self.entry['date_start'].set_text('')
self.spin['costs_plan'].set_value(0)
self.spin['costs_final'].set_value(0)
combobox.activate_row(self.combo['status'], 'new')
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
self.label['name'].set_text(self.project.projname)
self.label['responsible'].set_text(self.dd_user[self.project.responsible])
self.label['date_start'].set_text(self.format_date(self.project.startdate))
self.label['duration'].set_text(self.format_int(self.project.duration, suffix="Days"))
self.label['costs_plan'].set_text(self.format_float(self.project.costs_plan, 2, suffix="€"))
self.label['costs_final'].set_text(self.format_float(self.project.costs_final, 2, suffix="€"))
self.label['status'].set_text(self.project.projstate)
self.label['remarks'].set_text(self.project.remarks or '')
def edit_record(self):
self.entry['name'].set_text(self.project.projname)
combobox.activate_row(self.combo['responsible'], self.project.responsible)
self.entry['date_start'].set_text(self.project.startdate)
self.spin['costs_plan'].set_value(self.project.costs_plan)
self.spin['costs_final'].set_value(self.project.costs_final)
combobox.activate_row(self.combo['status'], self.project.projstate)
self.text['remarks'].get_buffer().set_text(self.project.remarks or '')
def save_record(self):
# fields must have been validated beforehand
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())
self.project.projstate = combobox.get_list_value(self.combo['status'])
self.project.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Project"))
self.clear_record()
self.topwidget.set_visible_child(self.box['proj_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Project"))
projid = treeview.get_value(self.tree['projects'], 0)
if not projidid:
return
self.measure.load(mid)
self.edit_record()
self.topwidget.set_visible_child(self.box['proj_edit'])
def on_but_detail_clicked(self, widget):
@@ -75,24 +128,23 @@ class ProjectsView(View):
self.topwidget.set_visible_child(self.box['projects'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete project!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['projects'])
# buttons on edit page
def on_but_save_clicked(self, widget):
pass
# check mandatory fields
if not self.entry['projname'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.project)
self.project.save()
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['projects'])
def display_record(self):
self.label['name'].set_text(self.project.projname)
self.label['responsible'].set_text(self.dd_user[self.project.responsible])
self.label['date_start'].set_text(self.format_date(self.project.startdate))
self.label['duration'].set_text(self.format_int(self.project.duration, suffix="Days"))
self.label['costs_plan'].set_text(self.format_float(self.project.costs_plan, 2, suffix="€"))
self.label['costs_final'].set_text(self.format_float(self.project.costs_final, 2, suffix="€"))
self.label['status'].set_text(self.project.projstate)
self.label['remarks'].set_text(self.project.remarks or '')
def edit_record(self):
pass