Exemplo n.º 1
0
class DepartmentConf(QtGui.QDialog):
    def __init__(self,query,db,parent=None):
        QtGui.QDialog.__init__(self,parent)
        self.ui  = Ui_Department()
        self.ui.setupUi(self)
        self.query = query
        self.db = db
        self.signal()
        self.fetch_dept()

    def signal(self):
        QtCore.QObject.connect(self.ui.add,QtCore.SIGNAL("clicked()"),self.onclick_add)
        

    def onclick_add(self):
        self.ui.departmentName.clear()
        if len(str(self.ui.departmentName.text())) == 0:
            QtGui.QMessageBox.warning(self,'Warning','Please Add Department!!!')
        else :    
            self.query.exec_("""insert into department (department_name) values ('%s')"""%(self.ui.departmentName.text()))

            self.ui.treeWidget.clear() 
            self.fetch_dept()
            QtGui.QMessageBox.information(self,'Information','Department Saved !!!')

    def fetch_dept(self):
        self.query.exec_(""" select department_name from department ;""")
        dept = []                     
        while self.query.next():
            dept.append(self.query.value(0).toString())
        for i in range(len(dept)):
            item = QtGui.QTreeWidgetItem(self.ui.treeWidget)
            item.setText(0, dept[i])
Exemplo n.º 2
0
 def __init__(self,query,db,parent=None):
     QtGui.QDialog.__init__(self,parent)
     self.ui  = Ui_Department()
     self.ui.setupUi(self)
     self.query = query
     self.db = db
     self.signal()
     self.fetch_dept()