Fixes for webgui and more native gui development
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
# SPDX-License-Identifier: WTFPL
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
def load_from_dict(combobox, dictionary, selected=None, sort=False):
|
||||
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
# SPDX-License-Identifier: WTFPL
|
||||
|
||||
"""
|
||||
Dropdowns and database enums
|
||||
|
||||
dropdowns can change
|
||||
enums are static
|
||||
|
||||
"""
|
||||
|
||||
class Dropdown:
|
||||
HULL_TYPE = 1
|
||||
COMPANY_TYPE = 2
|
||||
STORAGE_TYPE = 3
|
||||
EQUIPMENT_CATEGORY = 4
|
||||
PROVISION_CATEGORY = 5
|
||||
PROVISION_UNIT = 6
|
||||
FUSE_TYPE = 7
|
||||
UNIT = 8
|
||||
BOX_TYPE = 9
|
||||
FUSE_BLOCK = 10
|
||||
CABLE_TYPE = 11
|
||||
CABLE_TECHNAME = 12
|
||||
|
||||
class Lookup:
|
||||
|
||||
def __init__(self, db):
|
||||
self.db = db
|
||||
self._enums = {}
|
||||
self._dropdowns = {}
|
||||
|
||||
def load(self):
|
||||
self._load_enums()
|
||||
self._load_dropdowns()
|
||||
|
||||
def _load_enums(self):
|
||||
"""
|
||||
TODO translation via gettext needed
|
||||
"""
|
||||
db_enums = {
|
||||
'user.role': ('user', 'role'),
|
||||
'dropdown.flags': ('dropdown', 'flags'),
|
||||
'vessel.vtype': ('vessel', 'vtype'),
|
||||
'storage.capaunit': ('storage', 'capaunit'),
|
||||
'tagref.objtype': ('tagref', 'objtype'),
|
||||
'inventory.conttype': ('inventory', 'conttype'),
|
||||
'inventory.invcond': ('inventory', 'invcond'),
|
||||
'cable.cablecond': ('cable', 'cablecond'),
|
||||
'measurement.accuracy': ('measurement', 'accuracy'),
|
||||
'document.doctype': ('document', 'doctype'),
|
||||
'document.roleaccess': ('document', 'roleaccess'),
|
||||
'docref.reftype': ('docref', 'reftype'),
|
||||
'maintenance.maintstate': ('maintenance', 'maintstate'),
|
||||
'project.projstate': ('project', 'projstate'),
|
||||
'task.priority': ('task', 'priority'),
|
||||
'task.taskstate': ('task', 'taskstate'),
|
||||
'note.notetype': ('note', 'notetype'),
|
||||
'checklist.clstate': ('checklist', 'clstate'),
|
||||
'checkitem.checkresult': ('checkitem', 'checkresult'),
|
||||
'signalk.objtype': ('signalk', 'objtype'),
|
||||
'signalk.datatype': ('signalk', 'datatype')
|
||||
}
|
||||
for key, (table, column) in db_enums.items():
|
||||
self._enums[key] = self.db.load_enum(table, column)
|
||||
|
||||
def _load_dropdowns(self):
|
||||
self._dropdowns.clear()
|
||||
sql = (
|
||||
"SELECT ddid, ddval, ddtext "
|
||||
"FROM dropdown "
|
||||
"WHERE ddid>0 "
|
||||
"ORDER BY ddid, sort, ddval"
|
||||
)
|
||||
self.db.cur.execute(sql)
|
||||
for ddid, ddval, ddtext in self.db.cur.fetchall():
|
||||
if ddid not in self._dropdowns:
|
||||
self._dropdowns[ddid] = {}
|
||||
self._dropdowns[ddid][ddval] = ddtext
|
||||
|
||||
def enum(self, name):
|
||||
return self._enums[name]
|
||||
|
||||
def dropdown(self, ddid):
|
||||
return self._dropdowns[ddid]
|
||||
|
||||
def refresh(self):
|
||||
# TODO ugly hack please improve
|
||||
self._load_dropdowns()
|
||||
|
||||
class ListDefinition:
|
||||
pass
|
||||
|
||||
"""
|
||||
EQUIPMENT_LIST = ListDefinition(
|
||||
name="equipment",
|
||||
|
||||
query=
|
||||
"SELECT
|
||||
e.eid,
|
||||
e.ename,
|
||||
c.name AS manufacturer,
|
||||
e.model,
|
||||
e.ecat,
|
||||
e.weight
|
||||
FROM equipment e
|
||||
LEFT JOIN company c
|
||||
ON c.cid = e.manufacturer"
|
||||
,
|
||||
|
||||
columns=[
|
||||
Column("ename", _("Name")),
|
||||
Column("manufacturer", _("Manufacturer")),
|
||||
Column(
|
||||
"model",
|
||||
_("Model")
|
||||
),
|
||||
Column(
|
||||
"ecat",
|
||||
_("Category"),
|
||||
formatter=dropdown(Dropdown.EQUIPMENT_CATEGORY)
|
||||
),
|
||||
Column(
|
||||
"weight",
|
||||
_("Weight"),
|
||||
formatter=weight()
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
"""
|
||||
+1
-1
@@ -7,7 +7,7 @@ class Box(DbRecord):
|
||||
table = "box"
|
||||
pk_field = "boxid"
|
||||
fields = ('boxid', 'sid', 'boxtype', 'parent', 'label', 'color', 'content',
|
||||
'weight', 'remarks')
|
||||
'wx', 'wy', 'wz', 'weight', 'weight_net', 'price', 'remarks')
|
||||
|
||||
def __init__(self, db, boxid=None):
|
||||
super().__init__(db, boxid)
|
||||
|
||||
+11
-1
@@ -22,14 +22,24 @@ class Vessel(DbRecord):
|
||||
"WHERE v1.vid>=0 AND v2.vid IS NULL"
|
||||
)
|
||||
self.dcur.execute(sql)
|
||||
row = self.cur.fetchone()
|
||||
row = self.dcur.fetchone()
|
||||
if row is None:
|
||||
# vessel table empty: create first vessel
|
||||
self.pk_value = 1
|
||||
else:
|
||||
# create additional vessel
|
||||
self.pk_value = row['newid']
|
||||
self.clear()
|
||||
self.vid = self.pk_value
|
||||
self.vesselname = f"Vessel #{self.pk_value}"
|
||||
self.vtype = 1 # monohull
|
||||
self._insert()
|
||||
self.conn.commit()
|
||||
|
||||
def save(self):
|
||||
super().save()
|
||||
self.conn.commit()
|
||||
|
||||
def delete(self):
|
||||
# there must be no assiciated data!
|
||||
pass
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# SPDX-License-Identifier: WTFPL
|
||||
|
||||
from gi.repository import Gtk
|
||||
|
||||
def add_column(treeview, label, index, xalign=None, col_fg=None, col_bg=None, visible=True):
|
||||
|
||||
+758
-367
File diff suppressed because it is too large
Load Diff
+844
@@ -0,0 +1,844 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkAdjustment" id="adj_price">
|
||||
<property name="upper">90</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="adj_weight">
|
||||
<property name="upper">100</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="adj_weight_net">
|
||||
<property name="upper">100</property>
|
||||
<property name="step-increment">1</property>
|
||||
<property name="page-increment">10</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="adj_width_x">
|
||||
<property name="upper">9999</property>
|
||||
<property name="step-increment">10</property>
|
||||
<property name="page-increment">100</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="adj_width_y">
|
||||
<property name="upper">9999</property>
|
||||
<property name="step-increment">10</property>
|
||||
<property name="page-increment">100</property>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="adj_width_z">
|
||||
<property name="upper">9999</property>
|
||||
<property name="step-increment">10</property>
|
||||
<property name="page-increment">100</property>
|
||||
</object>
|
||||
<object class="GtkStack" id="topobject">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">8</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkExpander">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child>
|
||||
<!-- n-columns=3 n-rows=3 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Filter Box</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="tvw_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<child internal-child="selection">
|
||||
<object class="GtkTreeSelection"/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButtonBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_new">
|
||||
<property name="label" translatable="yes">New</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_but_new_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_edit">
|
||||
<property name="label" translatable="yes">Edit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_but_edit_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_detail">
|
||||
<property name="label" translatable="yes">Details</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_but_detail_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">page0</property>
|
||||
<property name="title" translatable="yes">page0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_box_detail">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Box Detais</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<!-- n-columns=2 n-rows=8 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Label</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Placeholder</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Remarks</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_remarks">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Content</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_content">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Type</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Color</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Weight</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_type">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_color">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_weight">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Weight net</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_weight_net">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Price</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_price">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButtonBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_delete">
|
||||
<property name="label" translatable="yes">Delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_but_delete_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
<property name="secondary">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_edit2">
|
||||
<property name="label" translatable="yes">Edit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_but_edit_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_close">
|
||||
<property name="label" translatable="yes">Close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_but_close_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">page1</property>
|
||||
<property name="title" translatable="yes">page1</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box_box_edit">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_title_edit">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Edit Box</property>
|
||||
<attributes>
|
||||
<attribute name="weight" value="bold"/>
|
||||
</attributes>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<!-- n-columns=7 n-rows=9 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Label</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Type</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="ent_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">0</property>
|
||||
<property name="width">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="cmb_type">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
<property name="width">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Dimensions (L x W x H)</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="label" translatable="yes">x</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">2</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="label" translatable="yes">x</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">4</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spi_wx">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="max-length">4</property>
|
||||
<property name="width-chars">4</property>
|
||||
<property name="text" translatable="yes">0</property>
|
||||
<property name="adjustment">adj_width_x</property>
|
||||
<property name="numeric">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spi_wy">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="max-length">4</property>
|
||||
<property name="width-chars">4</property>
|
||||
<property name="text" translatable="yes">0</property>
|
||||
<property name="adjustment">adj_width_y</property>
|
||||
<property name="numeric">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">3</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spi_wz">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="max-length">4</property>
|
||||
<property name="width-chars">4</property>
|
||||
<property name="text" translatable="yes">0</property>
|
||||
<property name="adjustment">adj_width_z</property>
|
||||
<property name="numeric">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">5</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Price</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Weight</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Remarks</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">8</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<child>
|
||||
<object class="GtkTextView" id="txt_remarks">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">8</property>
|
||||
<property name="width">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Weight net</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="label" translatable="yes">mm</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">6</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Content</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkEntry" id="ent_content">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
<property name="width">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spi_weight_net">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="text" translatable="yes">0</property>
|
||||
<property name="adjustment">adj_weight_net</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">7</property>
|
||||
<property name="width">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spi_weight">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="text" translatable="yes">0</property>
|
||||
<property name="adjustment">adj_weight</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">6</property>
|
||||
<property name="width">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="spi_price">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="text" translatable="yes">0</property>
|
||||
<property name="adjustment">adj_price</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">5</property>
|
||||
<property name="width">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Colour</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_color">
|
||||
<property name="label" translatable="yes">#FFFFFF</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="relief">half</property>
|
||||
<signal name="clicked" handler="on_but_color_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">4</property>
|
||||
<property name="width">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButtonBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_save">
|
||||
<property name="label" translatable="yes">Save</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_but_save_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="but_cancel">
|
||||
<property name="label" translatable="yes">Cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_but_cancel_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">page2</property>
|
||||
<property name="title" translatable="yes">page2</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
+103
-8
@@ -205,7 +205,7 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<!-- n-columns=3 n-rows=3 -->
|
||||
<!-- n-columns=2 n-rows=7 -->
|
||||
<object class="GtkGrid">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
@@ -224,7 +224,7 @@
|
||||
<object class="GtkLabel" id="lbl_name">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Placeholder</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
@@ -239,7 +239,7 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
<property name="top-attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
@@ -249,23 +249,118 @@
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Type</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Position (x, y, z)</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Dimension (x, y, z)</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Angle</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Capacity</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">0</property>
|
||||
<property name="top-attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
<object class="GtkLabel" id="lbl_type">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_position">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_dimension">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_angle">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="lbl_capacity">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left-attach">1</property>
|
||||
<property name="top-attach">5</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
|
||||
+32
-3
@@ -14,6 +14,7 @@ from gi.repository import GLib, Gtk, Gdk, Rsvg
|
||||
|
||||
from .view import View
|
||||
from yms import gtkutils, combobox, treeview
|
||||
from yms.lookup import Dropdown
|
||||
|
||||
class BaseView(View):
|
||||
|
||||
@@ -63,7 +64,15 @@ class BaseView(View):
|
||||
self.db.cur.execute("INSERT INTO settings (userid, sno, valint) VALUES (0, 1, 0)")
|
||||
self.db.conn.commit()
|
||||
else:
|
||||
self.context.vessel.vid = row[0]
|
||||
# check if vessel from settings exist
|
||||
self.db.cur.execute("SELECT count(*) FROM vessel WHERE vid=%s", (row[0],))
|
||||
res = self.db.cur.fetchone()[0]
|
||||
if res > 0:
|
||||
self.context.vessel.vid = row[0]
|
||||
else:
|
||||
# TODO set vessel to first in list
|
||||
self.context.vessel.vid = 0
|
||||
self.context.vessel.vesselname = "Ghost"
|
||||
|
||||
# default storage for current vessel
|
||||
sql = "SELECT sid, sname FROM storage WHERE stype=0 AND vid=%s ORDER BY sname"
|
||||
@@ -75,7 +84,7 @@ class BaseView(View):
|
||||
vessellist = {}
|
||||
self.db.dcur.execute("SELECT vid, vesselname, model FROM vessel ORDER BY vid")
|
||||
for row in self.db.dcur.fetchall():
|
||||
vessellist[row['vid']] = (
|
||||
vessellist[row['vid']] = (
|
||||
row['vesselname'] if row['model'] is None
|
||||
else row['vesselname'] + " - " + row['model']
|
||||
)
|
||||
@@ -154,6 +163,15 @@ class BaseView(View):
|
||||
if answer == False:
|
||||
return
|
||||
self.context.vessel.create()
|
||||
model = self.combo['vessel'].get_model()
|
||||
model.append((self.context.vessel.vid, self.context.vessel.vesselname))
|
||||
combobox.activate_row(self.combo['vessel'], self.context.vessel.vid)
|
||||
self.edit_vessel(self.context.vessel)
|
||||
self.stack['vessel'].set_visible_child(self.box['vessel_edit'])
|
||||
|
||||
def on_but_vessel_edit_clicked(self, widget):
|
||||
self.edit_vessel(self.context.vessel)
|
||||
self.stack['vessel'].set_visible_child(self.box['vessel_edit'])
|
||||
|
||||
def on_but_vessel_save_clicked(self, widget):
|
||||
print("Save vessel")
|
||||
@@ -172,6 +190,13 @@ class BaseView(View):
|
||||
txtbuf = self.text['vessel_remarks'].get_buffer()
|
||||
vessel.remarks = txtbuf.get_text(txtbuf.get_start_iter(), txtbuf.get_end_iter(), True)
|
||||
vessel.save()
|
||||
self.stack['vessel'].set_visible_child(self.box['vessel'])
|
||||
|
||||
def on_but_vessel_cancel_clicked(self, widget):
|
||||
self.stack['vessel'].set_visible_child(self.box['vessel'])
|
||||
|
||||
def on_but_vessel_delete_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_comp_new_clicked(self, widget):
|
||||
print("New company")
|
||||
@@ -189,7 +214,11 @@ class BaseView(View):
|
||||
pass
|
||||
|
||||
def display_vessel(self, vessel):
|
||||
print("Display vessel")
|
||||
self.label['vesselname'].set_text(vessel.vesselname)
|
||||
self.label['model'].set_text(vessel.model or '')
|
||||
self.label['year_built'].set_text(self.format_int(vessel.year_built, default='n/a'))
|
||||
|
||||
def edit_vessel(self, vessel):
|
||||
self.entry['vesselname'].set_text(vessel.vesselname)
|
||||
self.entry['model'].set_text(vessel.model or '')
|
||||
self.spin['year_built'].set_value(vessel.year_built or 0)
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# SPDX-License-Identifier: WTFPL
|
||||
|
||||
import os
|
||||
import gi
|
||||
gi.require_version("Gtk", "3.0")
|
||||
from gi.repository import GLib, Gtk, Gdk
|
||||
|
||||
from .view import View
|
||||
from yms import gtkutils, combobox, treeview
|
||||
from yms.model import box
|
||||
|
||||
class BoxesView(View):
|
||||
|
||||
def __init__(self, context):
|
||||
super().__init__(context, _("Box"), "boxes.ui")
|
||||
|
||||
# box already used for controls so other name here
|
||||
self.sbox = box.Box(context.db) # current record
|
||||
self.newrecord = False
|
||||
|
||||
self.lst_box = Gtk.ListStore(int, str, str, str)
|
||||
sql = (
|
||||
"SELECT b.boxid, b.label, b.content, b.remarks "
|
||||
"FROM box AS b JOIN storage AS s USING (sid) "
|
||||
"WHERE s.vid=%s "
|
||||
"ORDER BY b.label"
|
||||
)
|
||||
self.db.cur.execute(sql, (context.vessel.vid,))
|
||||
for row in self.db.cur.fetchall():
|
||||
self.lst_box.append(row)
|
||||
|
||||
treeview.add_column(self.tree['box'], _('ID'), 0)
|
||||
treeview.add_column(self.tree['box'], _('Label'), 1)
|
||||
treeview.add_column(self.tree['box'], _('Content'), 2)
|
||||
treeview.add_column(self.tree['box'], _('Remarks'), 3)
|
||||
self.tree['box'].set_model(self.lst_box)
|
||||
|
||||
|
||||
def load_list(self):
|
||||
pass
|
||||
|
||||
def display_record(self):
|
||||
self.label['label'].set_text(self.sbox.label)
|
||||
self.label['remarks'].set_text(self.sbox.remarks or '')
|
||||
|
||||
def edit_record(self):
|
||||
self.entry['label'].set_text(self.sbox.label)
|
||||
self.entry['content'].set_text(self.sbox.content or '')
|
||||
self.spin['wx'].set_value(self.sbox.wx or 0)
|
||||
self.spin['wy'].set_value(self.sbox.wy or 0)
|
||||
self.spin['wz'].set_value(self.sbox.wz or 0)
|
||||
self.text['remarks'].get_buffer().set_text(self.sbox.remarks or '')
|
||||
|
||||
# buttons on list page
|
||||
def on_but_new_clicked(self, widget):
|
||||
self.newrecord = True
|
||||
self.label['title_edit'].set_text("Add new Box")
|
||||
self.topwidget.set_visible_child(self.box['box_edit'])
|
||||
|
||||
def on_but_edit_clicked(self, widget):
|
||||
self.newrecord = False
|
||||
self.label['title_edit'].set_text("Edit Box")
|
||||
sid = treeview.get_value(self.tree['box'], 0)
|
||||
self.sbox.load(sid)
|
||||
self.edit_record()
|
||||
self.topwidget.set_visible_child(self.box['box_edit'])
|
||||
|
||||
def on_but_detail_clicked(self, widget):
|
||||
sid = treeview.get_value(self.tree['box'], 0)
|
||||
self.sbox.load(sid)
|
||||
self.display_record()
|
||||
self.topwidget.set_visible_child(self.box['box_detail'])
|
||||
|
||||
# buttons on detail page
|
||||
# edit2 uses edit callback
|
||||
def on_but_close_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['box'])
|
||||
|
||||
def on_but_delete_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['box'])
|
||||
self.newrecord = False
|
||||
|
||||
# buttons on edit page
|
||||
def on_but_save_clicked(self, widget):
|
||||
print("save not implemented yet")
|
||||
self.newrecord = False
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['box'])
|
||||
self.newrecord = False
|
||||
|
||||
def on_but_color_clicked(self, widget):
|
||||
pass
|
||||
|
||||
@@ -62,3 +62,9 @@ class CablesView(View):
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['cables'])
|
||||
|
||||
def display_record(self):
|
||||
pass
|
||||
|
||||
def edit_record(self):
|
||||
pass
|
||||
|
||||
@@ -59,3 +59,9 @@ class DocumentsView(View):
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['documents'])
|
||||
|
||||
def display_record(self):
|
||||
pass
|
||||
|
||||
def edit_record(self):
|
||||
pass
|
||||
|
||||
@@ -64,3 +64,9 @@ class FusesView(View):
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['fuses'])
|
||||
|
||||
def display_record(self):
|
||||
pass
|
||||
|
||||
def edit_record(self):
|
||||
pass
|
||||
|
||||
@@ -58,3 +58,9 @@ class MaintenanceView(View):
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['maintenance'])
|
||||
|
||||
def display_record(self):
|
||||
pass
|
||||
|
||||
def edit_record(self):
|
||||
pass
|
||||
|
||||
@@ -68,3 +68,9 @@ class ProjectsView(View):
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['projects'])
|
||||
|
||||
def display_record(self):
|
||||
pass
|
||||
|
||||
def edit_record(self):
|
||||
pass
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ class StatusView:
|
||||
gtkutils.init_named_controls(self, builder)
|
||||
|
||||
# Generic information
|
||||
self.label['dbinfo'].set_text("Database: {}".format(context.cfg['db']))
|
||||
self.label['dbinfo'].set_text("Database: {} on {}".format(context.cfg['db'], context.cfg['host']))
|
||||
|
||||
# Load table status info
|
||||
self.lst_tables = Gtk.ListStore(str, int)
|
||||
|
||||
+17
-2
@@ -8,6 +8,7 @@ from gi.repository import GLib, Gtk, Gdk
|
||||
from .view import View
|
||||
from yms import gtkutils, combobox, treeview
|
||||
from yms.model import storage
|
||||
from yms.lookup import Dropdown
|
||||
|
||||
class StorageView(View):
|
||||
|
||||
@@ -34,6 +35,14 @@ class StorageView(View):
|
||||
treeview.add_column(self.tree['storage'], _('Remarks'), 3)
|
||||
self.tree['storage'].set_model(self.lst_storage)
|
||||
|
||||
combodict = self.context.lookup.dropdown(Dropdown.STORAGE_TYPE)
|
||||
combobox.load_from_dict(self.combo['type'], combodict)
|
||||
|
||||
combodict = self.context.lookup.dropdown(Dropdown.STORAGE_TYPE)
|
||||
combobox.load_from_dict(self.combo['type'], combodict)
|
||||
|
||||
combodict = self.context.lookup.enum('storage.capaunit')
|
||||
combobox.load_from_dict(self.combo['unit'], combodict)
|
||||
|
||||
def load_list(self):
|
||||
pass
|
||||
@@ -56,9 +65,11 @@ class StorageView(View):
|
||||
self.topwidget.set_visible_child(self.box['stor_edit'])
|
||||
|
||||
def on_but_edit_clicked(self, widget):
|
||||
sid = treeview.get_value(self.tree['storage'], 0)
|
||||
if sid is None:
|
||||
return
|
||||
self.newrecord = False
|
||||
self.label['title_edit'].set_text("Edit Storage")
|
||||
sid = treeview.get_value(self.tree['storage'], 0)
|
||||
self.storage.load(sid)
|
||||
self.edit_record()
|
||||
self.topwidget.set_visible_child(self.box['stor_edit'])
|
||||
@@ -80,8 +91,12 @@ class StorageView(View):
|
||||
|
||||
# buttons on edit page
|
||||
def on_but_save_clicked(self, widget):
|
||||
print("save not implemented yet")
|
||||
self.newrecord = False
|
||||
# check mandatory fields
|
||||
sname = self.entry['sname'].get_text().strip()
|
||||
if not sname:
|
||||
return
|
||||
# here be dragons
|
||||
|
||||
def on_but_cancel_clicked(self, widget):
|
||||
self.topwidget.set_visible_child(self.box['storage'])
|
||||
|
||||
+6
-6
@@ -27,25 +27,25 @@ class View:
|
||||
self.topwidget = builder.get_object("topobject")
|
||||
gtkutils.init_named_controls(self, builder)
|
||||
|
||||
def format_int(self, ival, separator=True, suffix=None):
|
||||
def format_int(self, ival, separator=True, suffix=None, default=''):
|
||||
if ival is None:
|
||||
return ''
|
||||
return default
|
||||
formatted = locale.format_string("%d", ival, separator)
|
||||
if suffix:
|
||||
formatted += f"\u00A0{suffix}"
|
||||
return formatted
|
||||
|
||||
def format_float(self, fval, digits=2, grouping=True, suffix=None):
|
||||
def format_float(self, fval, digits=2, grouping=True, suffix=None, default=''):
|
||||
if fval is None:
|
||||
return ''
|
||||
return default
|
||||
formatted = locale.format_string(f"%.{digits}f", fval, grouping)
|
||||
if suffix:
|
||||
formatted += f"\u00A0{suffix}"
|
||||
return formatted
|
||||
|
||||
def format_date(self, dval):
|
||||
def format_date(self, dval, default=''):
|
||||
if dval is None:
|
||||
return ''
|
||||
return default
|
||||
return dval.strftime(self.context.datefmt)
|
||||
|
||||
def on_textview_keypress(self, widget, event):
|
||||
|
||||
Reference in New Issue
Block a user