Native gui usable for data editing. Lots of fixes and improvenemts
This commit is contained in:
1 parent
a6abdaa614
commit
09387280fc
52 files changed
+1579
-294
No files matched your search
+40
-29
@@ -25,8 +25,7 @@ class StatusView:
|
||||
|
||||
# Load table status info
|
||||
self.lst_tables = Gtk.ListStore(str, int)
|
||||
for row in self.get_table_counts():
|
||||
self.lst_tables.append(row)
|
||||
self.load_table_counts()
|
||||
treeview.add_column(self.tree['tables'], 'Table', 0)
|
||||
treeview.add_column(self.tree['tables'], '# Records', 1)
|
||||
self.tree['tables'].set_model(self.lst_tables)
|
||||
@@ -53,9 +52,9 @@ class StatusView:
|
||||
self.load_svg()
|
||||
|
||||
# subscribe to data change events
|
||||
self.context.subscribe("vessel_changed", self.vessel_changed)
|
||||
self.context.subscribe("vessel_modified", self.vessel_modified)
|
||||
|
||||
def vessel_changed(self, data):
|
||||
def vessel_modified(self, eventtype, data):
|
||||
print(f"Vessel changed. New ID={data[0]}")
|
||||
self.load_svg()
|
||||
|
||||
@@ -92,9 +91,9 @@ class StatusView:
|
||||
for element in root.iter():
|
||||
if element.get("id") == "centerline":
|
||||
found = True
|
||||
print("\n--- centerline gefunden ---")
|
||||
print("Tag:", element.tag)
|
||||
print("Attribute:", element.attrib)
|
||||
#print("\n--- centerline gefunden ---")
|
||||
#print("Tag:", element.tag)
|
||||
#print("Attribute:", element.attrib)
|
||||
y1 = element.get("y1")
|
||||
y2 = element.get("y2")
|
||||
if y1 is not None and y2 is not None:
|
||||
@@ -106,7 +105,7 @@ class StatusView:
|
||||
self.centerline_y = (y1 + y2) / 2
|
||||
else:
|
||||
self.centerline_y = y1
|
||||
print(f"centerline: SVG Y = {self.centerline_y}")
|
||||
#print(f"centerline: SVG Y = {self.centerline_y}")
|
||||
return
|
||||
if not found:
|
||||
print("No centerline with id='centerline' found!")
|
||||
@@ -119,31 +118,36 @@ class StatusView:
|
||||
cr.set_source_rgb(0.92, 0.97, 1.0)
|
||||
cr.paint()
|
||||
|
||||
allocation = area.get_allocation()
|
||||
scale_x = allocation.width / self.svg_width
|
||||
scale_y = allocation.height / self.svg_height
|
||||
self.svg_scale = min(scale_x, scale_y)
|
||||
if self.svg:
|
||||
allocation = area.get_allocation()
|
||||
scale_x = allocation.width / self.svg_width
|
||||
scale_y = allocation.height / self.svg_height
|
||||
self.svg_scale = min(scale_x, scale_y)
|
||||
|
||||
width = self.svg_width * self.svg_scale
|
||||
height = self.svg_height * self.svg_scale
|
||||
width = self.svg_width * self.svg_scale
|
||||
height = self.svg_height * self.svg_scale
|
||||
|
||||
self.svg_x = (allocation.width - width) / 2
|
||||
self.svg_y = (allocation.height - height) / 2
|
||||
self.svg_x = (allocation.width - width) / 2
|
||||
self.svg_y = (allocation.height - height) / 2
|
||||
|
||||
cr.save()
|
||||
cr.translate(self.svg_x, self.svg_y)
|
||||
cr.scale(self.svg_scale, self.svg_scale)
|
||||
viewport = Rsvg.Rectangle()
|
||||
viewport.x = 0
|
||||
viewport.y = 0
|
||||
viewport.width = self.svg_width
|
||||
viewport.height = self.svg_height
|
||||
self.svg.render_document(cr, viewport)
|
||||
cr.restore()
|
||||
cr.save()
|
||||
cr.translate(self.svg_x, self.svg_y)
|
||||
cr.scale(self.svg_scale, self.svg_scale)
|
||||
viewport = Rsvg.Rectangle()
|
||||
viewport.x = 0
|
||||
viewport.y = 0
|
||||
viewport.width = self.svg_width
|
||||
viewport.height = self.svg_height
|
||||
self.svg.render_document(cr, viewport)
|
||||
cr.restore()
|
||||
else:
|
||||
# TODO paint placeholder image
|
||||
pass
|
||||
|
||||
return False
|
||||
|
||||
def get_table_counts(self):
|
||||
def load_table_counts(self):
|
||||
self.lst_tables.clear()
|
||||
# Detect all tables in database
|
||||
sql= ("SELECT table_name "
|
||||
"FROM information_schema.tables "
|
||||
@@ -156,5 +160,12 @@ class StatusView:
|
||||
for table in tables:
|
||||
sql = f"SELECT COUNT(*) FROM {table}"
|
||||
self.context.db.cur.execute(sql)
|
||||
records.append((table, self.context.db.cur.fetchone()[0]))
|
||||
return records
|
||||
self.lst_tables.append((table, self.context.db.cur.fetchone()[0]))
|
||||
|
||||
def on_but_tables_reload_clicked(self, widget):
|
||||
self.load_table_counts()
|
||||
|
||||
def on_ntb_status_switch_page(self, notebook, page, page_num):
|
||||
#if Gtk.Buildable.get_name(page) == 'scw_tables':
|
||||
# self.load_table_counts()
|
||||
pass
|
||||
Reference in new issue
Block a user