]>
git.datanom.net - lensdatabase.git/blob - searchwindow.py
d2e8e72d817573db8f2930e0c4d64503fe431b60
2 gi
.require_version("Gtk", "3.0")
3 from gi
.repository
import Gtk
5 class SearchResultDialog():
6 def __init__(self
, builder
, db
):
8 self
.window
= builder
.get_object("search_result_window")
9 self
.window
.set_title("Lenses matching search")
10 self
.window
.connect("destroy", self
.on_destroy
)
11 self
.window
.set_default_size(600, 300)
12 self
.okBtn
= builder
.get_object("search_result_ok_btn")
13 self
.okBtn
.connect("clicked", self
.on_ok_btn_clicked
)
14 box
= builder
.get_object("search_result_content")
15 self
.liststore
= Gtk
.ListStore(str, int, str, str, int)
16 treeview
= Gtk
.TreeView()
17 treeview
.set_model(self
.liststore
)
18 for i
, title
in enumerate(["Maker", "Serial No", "Lens", "Notes"]):
19 renderer
= Gtk
.CellRendererText()
20 column
= Gtk
.TreeViewColumn(title
, renderer
, text
=i
)
21 treeview
.append_column(column
)
22 self
.scrollable_treelist
= Gtk
.ScrolledWindow()
23 self
.scrollable_treelist
.set_vexpand(True)
24 self
.scrollable_treelist
.add(treeview
)
25 box
.add(self
.scrollable_treelist
)
26 self
.window
.show_all()
27 self
.okBtn
.grab_focus()
29 def addLensData(self
, searchData
):
30 if self
.emptyString(searchData
[0]) == True and self
.emptyString(searchData
[1]) == False:
31 rows
= self
.db
.getLensByPattern(searchData
[1])
32 elif self
.emptyString(searchData
[0]) == False and self
.emptyString(searchData
[1]) == False:
33 rows
= self
.db
.getLensByMakerPattern(searchData
[0], searchData
[1])
34 elif self
.emptyString(searchData
[0]) == False and self
.emptyString(searchData
[1]) == True:
35 rows
= self
.db
.getLensByMaker(searchData
[0])
40 self
.liststore
.append(row
)
42 def emptyString(self
, str):
43 return not (str and str.strip())
45 def on_ok_btn_clicked(self
, button
):
48 def on_ok_clicked(self
, button
):
51 def on_destroy(self
, window
):
52 self
.scrollable_treelist
.destroy()
This page took 0.120462 seconds and 6 git commands to generate.