]>
git.datanom.net - lensdatabase.git/blob - notebook.py
d5a4a02aba5fb371ab0dee03476a258eca1bd19b
2 gi
.require_version("Gtk", "3.0")
3 from gi
.repository
import Gtk
4 from newlensdialog
import NewlensDialog
10 def __new__(cls
, *args
, **kwargs
):
11 if (cls
.__instance
is None):
12 cls
.__instance
= super(Notebook
, cls
).__new
__(cls
)
15 def __init__(self
, builder
, db
):
16 self
.builder
= builder
18 self
.nb
= self
.builder
.get_object("lens_maker_notebook")
23 def addPage(self
, name
):
24 if pages
.get(name
) is not None:
25 raise Exception("{page}: Page exists".format(page
= name
))
28 liststore
= Gtk
.ListStore(int, str, str, int)
29 treeview
= Gtk
.TreeView()
30 treeview
.connect("row-activated", self
.on_row_activated
)
31 treeview
.set_model(liststore
)
32 for i
, title
in enumerate(["Serial No", "Lens", "Notes"]):
33 renderer
= Gtk
.CellRendererText()
34 column
= Gtk
.TreeViewColumn(title
, renderer
, text
=i
)
35 treeview
.append_column(column
)
36 scrollable_treelist
= Gtk
.ScrolledWindow()
37 scrollable_treelist
.set_vexpand(True)
38 scrollable_treelist
.add(treeview
)
39 index
= self
.nb
.append_page(scrollable_treelist
, label
)
41 raise Exception("{page}: Page not added".format(page
= name
))
42 if self
.db
is not None:
43 self
.db
.addMaker(name
)
44 pages
[name
] = liststore
47 def addRow(self
, tab
, tuple):
50 raise Exception("{name}: Page does not exist".format(name
= tab
))
52 if self
.db
is not None:
53 id = self
.db
.addLens(tab
, tuple)
54 page
.append(tuple + (id, ))
57 except Exception as err
:
61 def updateRow(self
, path
, tuple):
65 for i
in range(0, len(tuple)):
66 model
[row
][i
] = tuple[i
]
67 if self
.db
is not None:
68 self
.db
.updateLens(tuple)
69 except Exception as err
:
73 def deleteRow(self
, path
, id):
76 iter = model
.get_iter(path
[1])
78 if self
.db
is not None:
79 self
.db
.deleteLens(id)
80 except Exception as err
:
84 def deletePage(self
, pagenum
):
85 self
.nb
.remove_page(pagenum
)
87 def getCurrentPage(self
):
88 return self
.nb
.get_current_page()
90 def getCurrentPageLabel(self
):
91 page
= self
.nb
.get_nth_page(self
.getCurrentPage())
92 label
= self
.nb
.get_tab_label_text(page
)
95 def on_row_activated(self
, widget
, row
, col
):
96 model
= widget
.get_model()
99 lensdata
.append(model
[row
][i
])
100 lensDialog
= NewlensDialog(self
.builder
, self
.db
, (model
, row
))
101 lensDialog
.setText(lensdata
)
This page took 0.149979 seconds and 6 git commands to generate.