1 # class for main window
4 import biacv_mainwindow_ui
as bui
6 class Biacv_mainwindow (PyQt4
.QtGui
.QMainWindow
, bui
.Ui_biacv_mainwindow
):
8 PyQt4
.QtGui
.QMainWindow
.__init
__ (self
)
10 self
.currentfile
= None
12 # delete educational qualification
13 def on_delete_education (self
):
14 # get the selected items in the education list
15 selitems
= self
.educationlist
.selectedItems ()
16 # if no items are selected
18 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot delete", "No items selected.")
19 # delete the items after confirmation
21 ans
= PyQt4
.QtGui
.QMessageBox
.question (self
, "Confirm",
22 "Are you sure you wish to delete selected item?",
23 PyQt4
.QtGui
.QMessageBox
.Yes
, PyQt4
.QtGui
.QMessageBox
.No
)
24 if ans
== PyQt4
.QtGui
.QMessageBox
.Yes
:
25 # remove the item selected
27 self
.educationlist
.takeTopLevelItem (self
.educationlist
.indexOfTopLevelItem (item
))
28 self
.reset_education_fields ()
30 # selection is changed
31 def on_select_education (self
):
32 self
.set_education_fields ()
34 # update educational qualification button
35 def on_update_education (self
):
36 selitems
= self
.educationlist
.selectedItems ()
37 # if no item is selected
39 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "No item selected")
41 # if the qualification title is not set
42 if self
.degree_name
.text () == "":
43 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot update", "A required field is missing.")
47 selitem
.setText (0, self
.degree_name
.text ())
48 selitem
.setText (1, self
.yearofpassing
.date ().toString ("MMM, yyyy"))
49 selitem
.setText (2, self
.institution
.text ())
50 selitem
.setText (3, self
.university
.text ())
51 selitem
.setText (4, self
.grade
.text ())
52 selitem
.setText (5, str (self
.percentage
.value ()))
54 # add educational qualification button
55 def on_add_education (self
):
56 # check if the qualification title is set
57 if self
.degree_name
.text () == "":
58 PyQt4
.QtGui
.QMessageBox
.critical (self
, "Cannot add", "A required fields is missing.")
60 educationitem
= PyQt4
.QtGui
.QTreeWidgetItem ([
61 self
.degree_name
.text (),
62 self
.yearofpassing
.date ().toString ("MMM, yyyy"),
63 self
.institution
.text (),
64 self
.university
.text (),
66 str (self
.percentage
.value ())
68 self
.educationlist
.addTopLevelItem (educationitem
)
70 self
.reset_education_fields ()
72 # set fields in the education tab from current selected item
73 def set_education_fields (self
):
74 selitems
= self
.educationlist
.selectedItems ()
78 # set the fields to the data in the selected item in the list
79 self
.degree_name
.setText (selitem
.text (0))
80 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate
.fromString (selitem
.text(1), "MMM, yyyy"))
81 self
.institution
.setText (selitem
.text (2))
82 self
.university
.setText (selitem
.text (3))
83 self
.grade
.setText (selitem
.text(4))
84 self
.percentage
.setValue (self
.percentage
.valueFromText (selitem
.text(5)))
86 # reset fields in the education tab
87 def reset_education_fields (self
):
88 self
.degree_name
.setText ("")
89 self
.yearofpassing
.setDate (PyQt4
.QtCore
.QDate (1988, 1, 1))
90 self
.institution
.setText ("")
91 self
.university
.setText ("")
92 self
.grade
.setText ("")
93 self
.percentage
.setValue (50.0)