]>
git.datanom.net - lensdatabase.git/blob - main.py
7e0691a727e6c98cc5768cf40f076d22a94d985f
2 gi
.require_version("Gtk", "3.0")
3 from gi
.repository
import Gtk
4 from notebook
import Notebook
5 from newlensdialog
import NewlensDialog
13 class SearchDialog(Gtk
.Dialog
):
14 def __init__(self
, builder
):
15 self
.builder
= builder
16 Gtk
.Dialog
.__init
__(self
, parent
=None)
17 self
.set_title("Search for lens")
18 self
.set_default_size(200, 100)
19 self
.add_button("_OK", Gtk
.ResponseType
.OK
)
20 btn
= self
.add_button("_Cancel", Gtk
.ResponseType
.CANCEL
)
21 self
.connect("response", self
.on_response
)
23 box
= self
.get_content_area()
24 makerLabel
= Gtk
.Label(label
="Lens Maker")
26 self
.makerEntry
= Gtk
.Entry()
27 self
.makerEntry
.set_placeholder_text("Lens Maker")
28 self
.makerEntry
.set_tooltip_text("Enter possible name of lens maker")
29 box
.add(self
.makerEntry
)
30 dataLabel
= Gtk
.Label(label
="Lens data")
32 self
.dataEntry
= Gtk
.Entry()
33 self
.dataEntry
.set_placeholder_text("Lens data")
34 self
.dataEntry
.set_tooltip_text("Enter all or parts of lens data")
35 box
.add(self
.dataEntry
)
39 def on_response(self
, dialog
, response
):
40 if response
== Gtk
.ResponseType
.OK
:
41 from searchwindow
import SearchResultDialog
42 search
= SearchResultDialog(self
.builder
, db
)
43 maker
= self
.makerEntry
.get_text()
44 data
= self
.dataEntry
.get_text()
46 search
.addLensData((maker
, data
))
48 elif response
== Gtk
.ResponseType
.CANCEL
:
53 class RemoveMakerDialog(Gtk
.Dialog
):
54 def __init__(self
, notebook
):
56 self
.maker
= self
.nb
.getCurrentPageLabel()
57 Gtk
.Dialog
.__init
__(self
, parent
=None)
58 self
.set_title("Remove Lens Maker")
59 self
.set_default_size(100, 100)
60 self
.add_button("_OK", Gtk
.ResponseType
.OK
)
61 btn
= self
.add_button("_Cancel", Gtk
.ResponseType
.CANCEL
)
62 self
.connect("response", self
.on_response
)
64 box
= self
.get_content_area()
65 makerLabel
= Gtk
.Label()
66 makerLabel
.set_markup('<span foreground="red" size="x-large"><b>Remove [' + self
.maker
+ '] and all lenses?</b></span>')
71 def on_response(self
, dialog
, response
):
72 if response
== Gtk
.ResponseType
.OK
:
74 db
.deleteMaker(self
.maker
)
75 self
.nb
.deletePage(self
.nb
.getCurrentPage())
76 except Exception as err
:
79 elif response
== Gtk
.ResponseType
.CANCEL
:
85 class NewlensmakerDialog(Gtk
.Dialog
):
86 def __init__(self
, builder
):
87 self
.builder
= builder
88 Gtk
.Dialog
.__init
__(self
, parent
=None)
89 self
.set_title("New Lens Maker")
90 self
.set_default_size(200, 100)
91 self
.add_button("_OK", Gtk
.ResponseType
.OK
)
92 btn
= self
.add_button("_Cancel", Gtk
.ResponseType
.CANCEL
)
93 self
.connect("response", self
.on_response
)
95 box
= self
.get_content_area()
96 label
= Gtk
.Label(label
="Lens Maker")
98 self
.entry
= Gtk
.Entry()
99 self
.entry
.set_placeholder_text("Lens Maker")
100 self
.entry
.set_tooltip_text("Enter name of lens maker")
105 def on_response(self
, dialog
, response
):
106 if response
== Gtk
.ResponseType
.OK
:
107 notebook
= Notebook(self
.builder
, db
)
108 notebook
.addPage(self
.entry
.get_text())
109 elif response
== Gtk
.ResponseType
.CANCEL
:
116 def __init__(self
, builder
):
117 self
.builder
= builder
119 def on_destroy(self
, *args
):
122 def on_app_quit(self
, *args
):
125 self
.on_destroy(self
, args
)
127 def on_show_about(self
, menuitem
, data
=None):
128 about
= self
.builder
.get_object("about_dialog")
133 def on_find_lens_clicked(self
, *args
):
135 dialog
= SearchDialog(self
.builder
)
139 def on_add_lens_clicked(self
, *args
):
141 dialog
= NewlensDialog(self
.builder
, db
)
145 def on_new_maker_clicked(self
, *args
):
146 """ New lens maker"""
147 dialog
= NewlensmakerDialog(self
.builder
)
151 def on_remove_maker_clicked(self
, *args
):
152 """ Remove lens maker"""
153 notebook
= Notebook(self
.builder
, db
)
154 dialog
= RemoveMakerDialog(notebook
)
159 def __init__(self
, path
):
162 self
.builder
= Gtk
.Builder()
163 self
.builder
.add_from_file(path
+ "/lensdatabase.ui")
164 self
.builder
.connect_signals(Handler(self
.builder
))
166 main_window
= self
.builder
.get_object("main_window")
167 aboutdialog
= self
.builder
.get_object("about_dialog")
168 aboutdialog
.set_program_name(name
)
169 aboutdialog
.set_version(version
)
171 main_window
.show_all()
174 makers
= db
.getMakers()
175 notebook
= Notebook(self
.builder
, None)
178 lenses
= db
.getLenses(maker
)
179 notebook
.addPage(maker
)
181 notebook
.addRow(maker
, lens
)
This page took 0.11662 seconds and 6 git commands to generate.