Work on native gui: list views for objects; set version to 0.2.2
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
# SPDX-License-Identifier: WTFPL
|
||||
|
||||
import os
|
||||
from gi.repository import Gtk
|
||||
|
||||
from .view import View
|
||||
from yms import gtkutils, combobox, treeview
|
||||
from yms.model import company
|
||||
|
||||
class CompaniesView(View):
|
||||
|
||||
def __init__(self, context):
|
||||
super().__init__(context, _("Companies"), "companies.ui")
|
||||
|
||||
self.comp = company.Company(context.db) # current record
|
||||
self.newrecord = False
|
||||
|
||||
# company types
|
||||
self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=2 ORDER BY ddval")
|
||||
self.comptype = dict(self.db.cur.fetchall())
|
||||
combobox.load_from_dict(self.combo['flt_type'], {-2: _("─── all ───")} | self.comptype, -2)
|
||||
|
||||
# companied
|
||||
self.lst_companies = Gtk.ListStore(int, str, str, str)
|
||||
self.db.cur.execute("SELECT compid, compname, comptype, remarks FROM company ORDER BY compname")
|
||||
for row in self.db.cur.fetchall():
|
||||
self.lst_companies.append((row[0], row[1], self.comptype[row[2]], row[3]))
|
||||
treeview.add_column(self.tree['companies'], _('ID'), 0)
|
||||
treeview.add_column(self.tree['companies'], _('Name'), 1)
|
||||
treeview.add_column(self.tree['companies'], _('Type'), 2)
|
||||
treeview.add_column(self.tree['companies'], _('Remarks'), 3)
|
||||
self.tree['companies'].set_model(self.lst_companies)
|
||||
|
||||
def display_company(self, company):
|
||||
self.entry['compname'].set_text(company.compname)
|
||||
# Type
|
||||
# Type2
|
||||
self.entry['shortname'].set_text(company.shortname)
|
||||
self.entry['street'].set_text(company.street)
|
||||
self.entry['zip'].set_text(company.zip)
|
||||
self.entry['city'].set_text(company.city)
|
||||
self.entry['country'].set_text(company.country)
|
||||
self.entry['contact'].set_text(company.contact)
|
||||
self.entry['phone'].set_text(company.phone)
|
||||
self.entry['email'].set_text(company.email)
|
||||
self.entry['web'].set_text(company.web)
|
||||
self.entry['customerno'].set_text(company.customerno)
|
||||
self.entry['contractno'].set_text(company.contractno)
|
||||
|
||||
# buttons on list page
|
||||
def on_but_new_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['comp_edit'])
|
||||
|
||||
def on_but_edit_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['comp_edit'])
|
||||
|
||||
def on_but_detail_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['comp_detail'])
|
||||
|
||||
# buttons on detail page
|
||||
# edit2 uses edit callback
|
||||
def on_but_close_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['companies'])
|
||||
|
||||
def on_but_delete_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['companies'])
|
||||
|
||||
# buttons on edit page
|
||||
def on_but_save_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['companies'])
|
||||
Reference in New Issue
Block a user