Added data change event system to native gui
This commit is contained in:
1 parent
f6ab45c465
commit
8ac72e717e
6 files changed
+259
-2
No files matched your search
+1
-1
@@ -40,7 +40,7 @@ class Vessel(DbRecord):
|
|||||||
"VALUES ('table', 1, NOW()) "
|
"VALUES ('table', 1, NOW()) "
|
||||||
"ON DUPLICATE KEY UPDATE changed = NOW()"
|
"ON DUPLICATE KEY UPDATE changed = NOW()"
|
||||||
)
|
)
|
||||||
self.db.cur.execute()
|
self.db.cur.execute(sql)
|
||||||
self.conn.commit()
|
self.conn.commit()
|
||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
|
|||||||
@@ -0,0 +1,229 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
version="1.1"
|
||||||
|
id="svg66"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg">
|
||||||
|
<defs
|
||||||
|
id="defs42">
|
||||||
|
<radialGradient
|
||||||
|
id="a"
|
||||||
|
cx="31.113001"
|
||||||
|
cy="19.009001"
|
||||||
|
r="8.6620998"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="matrix(2.5632,0,0,1.2196,-55.984,14.041)">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
id="stop2" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-opacity="0"
|
||||||
|
id="stop4" />
|
||||||
|
</radialGradient>
|
||||||
|
<radialGradient
|
||||||
|
id="h"
|
||||||
|
cx="11.329"
|
||||||
|
cy="10.584"
|
||||||
|
r="15.532"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="translate(1.4634694,0.39303442)">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
stop-color="#f3f4ff"
|
||||||
|
id="stop7" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-color="#9193af"
|
||||||
|
id="stop9" />
|
||||||
|
</radialGradient>
|
||||||
|
<radialGradient
|
||||||
|
id="d"
|
||||||
|
cx="11.902"
|
||||||
|
cy="10.045"
|
||||||
|
r="29.292999"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="translate(1.7072971,0.45851765)">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
stop-color="#fffffd"
|
||||||
|
id="stop12" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-color="#cbcbc9"
|
||||||
|
id="stop14" />
|
||||||
|
</radialGradient>
|
||||||
|
<radialGradient
|
||||||
|
id="f"
|
||||||
|
cx="23.375"
|
||||||
|
cy="10.973"
|
||||||
|
r="3.3478"
|
||||||
|
gradientTransform="matrix(3.6304,0,0,3.7421,-60.363428,-28.884518)"
|
||||||
|
gradientUnits="userSpaceOnUse">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
stop-color="#c4a000"
|
||||||
|
id="stop17" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-color="#c4a000"
|
||||||
|
stop-opacity="0"
|
||||||
|
id="stop19" />
|
||||||
|
</radialGradient>
|
||||||
|
<radialGradient
|
||||||
|
id="c"
|
||||||
|
cx="8.7468004"
|
||||||
|
cy="6.8283"
|
||||||
|
r="29.889999"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="translate(1.3880212,0.3727718)">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
stop-color="#9497b3"
|
||||||
|
id="stop22" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-color="#4c4059"
|
||||||
|
id="stop24" />
|
||||||
|
</radialGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="b"
|
||||||
|
x1="8.9155998"
|
||||||
|
x2="9.8855"
|
||||||
|
y1="37.196999"
|
||||||
|
y2="52.091"
|
||||||
|
gradientTransform="matrix(3.1238,0,0,0.96969,-29.901048,-19.061377)"
|
||||||
|
gradientUnits="userSpaceOnUse">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
stop-color="#9aa29a"
|
||||||
|
id="stop27" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-color="#b5beb5"
|
||||||
|
id="stop29" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="e"
|
||||||
|
x1="6.3421998"
|
||||||
|
x2="22.218"
|
||||||
|
y1="7.7893"
|
||||||
|
y2="25.884001"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="translate(1.7072971,0.45851765)">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
stop-color="#a0a0a0"
|
||||||
|
id="stop32" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-color="#fff"
|
||||||
|
id="stop34" />
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient
|
||||||
|
id="g"
|
||||||
|
x1="19.667"
|
||||||
|
x2="20.33"
|
||||||
|
y1="4.2571001"
|
||||||
|
y2="5.2845998"
|
||||||
|
gradientUnits="userSpaceOnUse"
|
||||||
|
gradientTransform="translate(1.122572,0.30148183)">
|
||||||
|
<stop
|
||||||
|
offset="0"
|
||||||
|
stop-color="#c4a000"
|
||||||
|
id="stop37" />
|
||||||
|
<stop
|
||||||
|
offset="1"
|
||||||
|
stop-color="#c4a000"
|
||||||
|
stop-opacity="0"
|
||||||
|
id="stop39" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<g
|
||||||
|
id="g407"
|
||||||
|
transform="matrix(0.36405586,0,0,0.35772375,-0.72336166,-0.19088956)">
|
||||||
|
<path
|
||||||
|
fill="url(#b)"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M 18.588,1.4037 4.227,18.0967 5.4857,19.3399 18.5877,1.4039 Z"
|
||||||
|
color="#000000"
|
||||||
|
id="path46"
|
||||||
|
style="fill:url(#b)" />
|
||||||
|
<path
|
||||||
|
fill="#fefefe"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="M 18.467,1.3138 5.66,19.0728 7.4895,20.6881 18.4665,1.3141 Z"
|
||||||
|
id="path48" />
|
||||||
|
<path
|
||||||
|
fill="url(#c)"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#605773"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="0.69855"
|
||||||
|
d="m 31.161,16.911 a 14.911,14.911 0 1 1 -29.821,0 14.911,14.911 0 1 1 29.821,0 z"
|
||||||
|
transform="matrix(1.4315,0,0,1.4315,0.56946,-1.6546)"
|
||||||
|
id="path50"
|
||||||
|
style="fill:url(#c)" />
|
||||||
|
<path
|
||||||
|
fill="url(#d)"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="url(#e)"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="0.7114"
|
||||||
|
d="m 31.161,16.911 a 14.911,14.911 0 1 1 -29.821,0 14.911,14.911 0 1 1 29.821,0 z"
|
||||||
|
transform="matrix(1.1638,0,0,1.1638,4.8248,2.7776)"
|
||||||
|
id="path52"
|
||||||
|
style="fill:url(#d);stroke:url(#e)" />
|
||||||
|
<path
|
||||||
|
fill="url(#f)"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="url(#g)"
|
||||||
|
stroke-width="0.56499"
|
||||||
|
d="m 16.679,6.6387 a 8.5,8.5 0 0 1 6.6533,-3.2636 l 0.04231,8.4999 z"
|
||||||
|
color="#000000"
|
||||||
|
transform="matrix(1.77,0,0,1.77,-17.024,1.6107)"
|
||||||
|
id="path54"
|
||||||
|
style="fill:url(#f);stroke:url(#g)" />
|
||||||
|
<path
|
||||||
|
fill="#f3f3f3"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="0.999994"
|
||||||
|
d="m 26.70436,22.691697 a 2.526938,2.526938 0 1 1 -5.053669,0 2.526938,2.526938 0 1 1 5.053669,0 z"
|
||||||
|
id="path56" />
|
||||||
|
<path
|
||||||
|
fill="none"
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-linecap="round"
|
||||||
|
d="M 22.177,20.718 13.1561,13.1403"
|
||||||
|
id="path58" />
|
||||||
|
<path
|
||||||
|
fill="none"
|
||||||
|
stroke="#000000"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="m 19.409,29.777 2.96,-4.4933"
|
||||||
|
id="path60" />
|
||||||
|
<path
|
||||||
|
fill="#b6b9b1"
|
||||||
|
fill-rule="evenodd"
|
||||||
|
d="m 25.331338,8.7434534 a 1.7011706,1.7011706 0 1 1 -3.402231,0 1.7011706,1.7011706 0 1 1 3.402231,0 z m 0,27.2179996 a 1.7011706,1.7011706 0 1 1 -3.402231,0 1.7011706,1.7011706 0 1 1 3.402231,0 z m -13.609,-13.6091 a 1.7011706,1.7011706 0 1 1 -3.4022313,0 1.7011706,1.7011706 0 1 1 3.4022313,0 z m 27.2186,0 a 1.7011706,1.7011706 0 1 1 -3.402231,0 1.7011706,1.7011706 0 1 1 3.402231,0 z"
|
||||||
|
id="path62" />
|
||||||
|
<path
|
||||||
|
fill="none"
|
||||||
|
stroke="url(#h)"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="0.73657"
|
||||||
|
d="m 31.161,16.911 a 14.911,14.911 0 1 1 -29.821,0 14.911,14.911 0 1 1 29.821,0 z"
|
||||||
|
id="path64"
|
||||||
|
transform="matrix(1.3577,0,0,1.3577,1.7699,-0.49374)"
|
||||||
|
style="stroke:url(#h)" />
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 6.3 KiB |
@@ -32,6 +32,10 @@ class BoxesView(View):
|
|||||||
self.dd_boxtype = self.context.lookup.dropdown(Dropdown.BOX_TYPE)
|
self.dd_boxtype = self.context.lookup.dropdown(Dropdown.BOX_TYPE)
|
||||||
combobox.load_from_dict(self.combo['type'], {-1: _("─── none ───")} | self.dd_boxtype)
|
combobox.load_from_dict(self.combo['type'], {-1: _("─── none ───")} | self.dd_boxtype)
|
||||||
|
|
||||||
|
# subscribe to data change events
|
||||||
|
self.context.subscribe("storage_added", self.storage_added)
|
||||||
|
self.context.subscribe("storage_changed", self.storage_changed)
|
||||||
|
|
||||||
def load_list(self):
|
def load_list(self):
|
||||||
selected_id = treeview.get_value(self.tree['box'])
|
selected_id = treeview.get_value(self.tree['box'])
|
||||||
self.lst_box.clear()
|
self.lst_box.clear()
|
||||||
@@ -49,6 +53,19 @@ class BoxesView(View):
|
|||||||
# restore previous selected row
|
# restore previous selected row
|
||||||
selection.select_iter(treeiter)
|
selection.select_iter(treeiter)
|
||||||
|
|
||||||
|
def storage_added(self, data):
|
||||||
|
self.dd_storage.append(data)
|
||||||
|
lst = self.combo['storage'].get_model()
|
||||||
|
lst.append(data)
|
||||||
|
|
||||||
|
def storage_changed(self, data):
|
||||||
|
self.dd_storage[data[0]] = data[1]
|
||||||
|
lst = self.combo['storage'].get_model()
|
||||||
|
for row in lst:
|
||||||
|
if row[0] == data[0]:
|
||||||
|
row[1] = data[1]
|
||||||
|
return
|
||||||
|
|
||||||
def clear_record(self):
|
def clear_record(self):
|
||||||
self.entry['label'].set_text('')
|
self.entry['label'].set_text('')
|
||||||
combobox.activate_row(self.combo['storage'], 0)
|
combobox.activate_row(self.combo['storage'], 0)
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class CompaniesView(View):
|
|||||||
selection.select_iter(treeiter)
|
selection.select_iter(treeiter)
|
||||||
|
|
||||||
def clear_record(self):
|
def clear_record(self):
|
||||||
|
self.comp.clear()
|
||||||
self.entry['compname'].set_text('')
|
self.entry['compname'].set_text('')
|
||||||
self.entry['shortname'].set_text('')
|
self.entry['shortname'].set_text('')
|
||||||
self.entry['street'].set_text('')
|
self.entry['street'].set_text('')
|
||||||
|
|||||||
+2
-1
@@ -189,9 +189,10 @@ class StorageView(View):
|
|||||||
self.storage.save()
|
self.storage.save()
|
||||||
if self.newrecord:
|
if self.newrecord:
|
||||||
self.load_list()
|
self.load_list()
|
||||||
|
self.context.publish("storage_added", (self.storage.pk_value, self.storage.sname))
|
||||||
self.newrecord = False
|
self.newrecord = False
|
||||||
else:
|
else:
|
||||||
pass
|
self.context.publish("storage_changed", (self.storage.pk_value, self.storage.sname))
|
||||||
# TODO aktuelle Listenzeile aktualisieren!
|
# TODO aktuelle Listenzeile aktualisieren!
|
||||||
self.display_record()
|
self.display_record()
|
||||||
self.topwidget.set_visible_child(self.box['stor_detail'])
|
self.topwidget.set_visible_child(self.box['stor_detail'])
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ class AppContext:
|
|||||||
self.curr_sym = '€'
|
self.curr_sym = '€'
|
||||||
self.img_max_width = 1024
|
self.img_max_width = 1024
|
||||||
self.img_max_height = 768
|
self.img_max_height = 768
|
||||||
|
# event system
|
||||||
|
self.callbacks = {}
|
||||||
|
|
||||||
def set_db(self, db):
|
def set_db(self, db):
|
||||||
self.db = db
|
self.db = db
|
||||||
@@ -125,6 +127,13 @@ class AppContext:
|
|||||||
self.lookup.load()
|
self.lookup.load()
|
||||||
self.init_scanner()
|
self.init_scanner()
|
||||||
|
|
||||||
|
def subscribe(self, event, callback):
|
||||||
|
self.callbacks.setdefault(event, []).append(callback)
|
||||||
|
|
||||||
|
def publish(self, event, data=None):
|
||||||
|
for callback in self.callbacks.get(event, []):
|
||||||
|
callback(data)
|
||||||
|
|
||||||
def init_scanner(self):
|
def init_scanner(self):
|
||||||
self.scan_enabled = False
|
self.scan_enabled = False
|
||||||
if not self.cfg['scanner']:
|
if not self.cfg['scanner']:
|
||||||
|
|||||||
Reference in new issue
Block a user