Native gui first steps: storage, box and companies are editable
This commit is contained in:
1 parent
1eea4058bf
commit
06a9834688
47 files changed
+3119
-883
No files matched your search
@@ -37,7 +37,7 @@ from yms import database
|
||||
from yms import gtkutils, combobox, treeview
|
||||
from yms.model import user
|
||||
from yms.model import vessel
|
||||
from yms.lookup import Lookup
|
||||
from yms.lookup import Lookup, Table
|
||||
|
||||
from yms.view.base import BaseView
|
||||
from yms.view.storage import StorageView
|
||||
@@ -90,7 +90,8 @@ class AppContext:
|
||||
self.user = None
|
||||
self.vessel = None
|
||||
self.ui_path = os.path.join(self.get_sharepath(), "yms", "ui")
|
||||
self.textdomain = "ymsgui"
|
||||
self.textdomain = "ymsgui" # static here for early initialization
|
||||
self.localedir = "locale"
|
||||
self.datefmt = '%d.%m.%Y'
|
||||
# system settings stored in database
|
||||
self.curr_sym = '€'
|
||||
@@ -131,7 +132,17 @@ class AppContext:
|
||||
class Frontend:
|
||||
|
||||
def __init__(self, context):
|
||||
self.initializing = True
|
||||
self.context = context
|
||||
self.db = context.db
|
||||
builder = Gtk.Builder()
|
||||
builder.set_translation_domain(context.textdomain)
|
||||
ui_path = os.path.join(context.ui_path)
|
||||
builder.add_from_file(os.path.join(ui_path, "main.ui"))
|
||||
builder.connect_signals(self)
|
||||
self.window = builder.get_object("wnd_main")
|
||||
self.notebook = builder.get_object("ntb_modules")
|
||||
|
||||
self.modules = {
|
||||
"base": BaseView(context),
|
||||
"storage": StorageView(context),
|
||||
@@ -149,34 +160,61 @@ class Frontend:
|
||||
"documents": DocumentsView(context),
|
||||
"status": StatusView(context)
|
||||
}
|
||||
builder = Gtk.Builder()
|
||||
builder.set_translation_domain(context.textdomain)
|
||||
ui_path = os.path.join(context.ui_path)
|
||||
builder.add_from_file(os.path.join(ui_path, "main.ui"))
|
||||
builder.connect_signals(self)
|
||||
self.window = builder.get_object("wnd_main")
|
||||
self.notebook = builder.get_object("ntb_modules")
|
||||
self.moduleindex = {}
|
||||
for module in self.modules.values():
|
||||
self.notebook.append_page(module.topwidget, Gtk.Label(label=module._title))
|
||||
pageno = self.notebook.append_page(module.topwidget, Gtk.Label(label=module._title))
|
||||
self.moduleindex[pageno] = module
|
||||
|
||||
self.db_poll_ts = context.db.get_timestamp()
|
||||
GLib.timeout_add_seconds(30, self.db_change_poller)
|
||||
self.initializing = False
|
||||
|
||||
def run(self):
|
||||
#self.label['vessel'].set_text(self._vessel.vesselname)
|
||||
self.window.show_all()
|
||||
Gtk.main()
|
||||
|
||||
def db_change_poller(self):
|
||||
# get all list ids which changes since last query
|
||||
print("db list change poller")
|
||||
#sql = "SELECT revid FROM revision WHERE changed>%s"
|
||||
# dynamic combobox data refresh
|
||||
|
||||
# look for dropdown entries newer than last check
|
||||
sql = "SELECT revid FROM revision WHERE revtype='dropdown' AND changed>%s"
|
||||
self.db.cur.execute(sql, (self.db_poll_ts,))
|
||||
for row in self.db.cur.fetchall():
|
||||
print(f"refresh dropdown list no.{row[0]}")
|
||||
self.lookup.reload_dropdown(row[0])
|
||||
|
||||
# look for table list entries newer than last check
|
||||
sql = "SELECT revid FROM revision WHERE revtype='table' AND changed>%s"
|
||||
self.db.cur.execute(sql, (self.db_poll_ts,))
|
||||
for row in self.db.cur.fetchall():
|
||||
print(f"refresh table based list #{row[0]}")
|
||||
# TODO get module name für changes in table
|
||||
modulemap = {
|
||||
#Table.VESSEL: "base",
|
||||
#Table.USERS: "base",
|
||||
Table.COMPANIES: "companies",
|
||||
Table.STORAGE: "storage",
|
||||
Table.BOXES: "box",
|
||||
Table.EQUIPMENT: "equipment",
|
||||
##Table.INVENTORY: "inventory"
|
||||
Table.PROJECTS: "projects",
|
||||
Table.CABLES: "cables",
|
||||
Table.FUSES: "fuses",
|
||||
Table.TAGS: "tags"
|
||||
}
|
||||
# execute method from module
|
||||
self.modules[modulemap[row[0]]].load_list()
|
||||
|
||||
self.db_poll_ts = self.db.get_timestamp()
|
||||
return True
|
||||
|
||||
def on_ntb_modules_switch_page(self, notebook, page, page_num):
|
||||
print("Neue Seite:", page_num)
|
||||
# TODO here re-load lists
|
||||
# signal handler: call view method for e.g. list refresh
|
||||
if self.initializing:
|
||||
return
|
||||
callback = getattr(self.moduleindex[page_num], "on_page_activated", None)
|
||||
if callable(callback):
|
||||
callback()
|
||||
|
||||
def on_destroy(self, widget, data=None):
|
||||
Gtk.main_quit()
|
||||
@@ -199,11 +237,10 @@ def create_config(cfg, cfgfile):
|
||||
if __name__ == "__main__":
|
||||
|
||||
context = AppContext()
|
||||
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
gettext.bindtextdomain(context.textdomain, 'locale')
|
||||
gettext.bindtextdomain(context.textdomain, context.localedir)
|
||||
gettext.textdomain(context.textdomain)
|
||||
gettext.install(context.textdomain, 'locale')
|
||||
gettext.install(context.textdomain, context.localedir)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
cfgfile = os.path.expanduser(context.cfg['cfgfile'])
|
||||
|
||||
Reference in new issue
Block a user