]>
git.datanom.net - lensdatabase.git/blob - newlensdialog.py
2 gi
.require_version("Gtk", "3.0")
3 from gi
.repository
import Gtk
5 class NewlensDialog(Gtk
.Dialog
):
6 def __init__(self
, builder
, db
, path
= None):
7 from notebook
import Notebook
8 from textview
import Textview
11 self
.builder
= builder
12 self
.notebook
= Notebook(self
.builder
, db
)
13 Gtk
.Dialog
.__init
__(self
, parent
=None)
14 self
.set_title("New [{maker}] Lens".format(maker
= self
.notebook
.getCurrentPageLabel()))
15 self
.set_default_size(400, 200)
17 self
.add_button("_Delete", Gtk
.ResponseType
.DELETE_EVENT
)
18 self
.add_button("_Update", Gtk
.ResponseType
.APPLY
)
19 btn
= self
.add_button("_Close", Gtk
.ResponseType
.CLOSE
)
21 self
.add_button("_OK", Gtk
.ResponseType
.OK
)
22 btn
= self
.add_button("_Cancel", Gtk
.ResponseType
.CANCEL
)
24 self
.connect("response", self
.on_response
)
26 box
= self
.get_content_area()
27 snLabel
= Gtk
.Label(label
="Serial No")
28 self
.snEntry
= Gtk
.Entry()
29 self
.snEntry
.set_placeholder_text("Serial No")
30 self
.snEntry
.set_tooltip_text("Enter serial no of the lens")
33 descLabel
= Gtk
.Label(label
="Lens description")
34 self
.descEntry
= Gtk
.Entry()
35 self
.descEntry
.set_placeholder_text("Lens description")
36 self
.descEntry
.set_tooltip_text("Enter description of the lens")
38 box
.add(self
.descEntry
)
39 noteLabel
= Gtk
.Label(label
="Notes")
40 self
.textview
= Textview()
42 box
.add(self
.textview
.getScrolledWindow())
46 def on_response(self
, dialog
, response
):
47 if response
== Gtk
.ResponseType
.OK
:
48 sn
= int(self
.snEntry
.get_text())
49 desc
= self
.descEntry
.get_text()
50 notes
= self
.textview
.getText()
51 page
= self
.notebook
.getCurrentPageLabel()
52 self
.notebook
.addRow(page
, (sn
, desc
, notes
))
53 elif response
== Gtk
.ResponseType
.CANCEL
:
55 elif response
== Gtk
.ResponseType
.APPLY
:
56 sn
= int(self
.snEntry
.get_text())
57 desc
= self
.descEntry
.get_text()
58 notes
= self
.textview
.getText()
60 iter = model
.get_iter(self
.path
[1])
61 id = model
.get_value(iter, 3)
62 self
.notebook
.updateRow(self
.path
, (sn
, desc
, notes
, id))
63 elif response
== Gtk
.ResponseType
.DELETE_EVENT
:
65 iter = model
.get_iter(self
.path
[1])
66 id = model
.get_value(iter, 3)
67 self
.notebook
.deleteRow(self
.path
, id)
68 elif response
== Gtk
.ResponseType
.CLOSE
:
74 def setText(self
, data
):
75 self
.snEntry
.set_text(str(data
[0]))
76 self
.descEntry
.set_text(data
[1])
77 self
.textview
.setText(data
[2])
This page took 0.089229 seconds and 6 git commands to generate.