Esempio n. 1
0
 def AddWordEntryToDatabase(self):
     defaultpointervalue = int(0)
     if path.isdir("DATA"):
         try:
             chdir("DATA")
         except:
             pass
     if not path.isfile("position"):
         with open("position","w") as ap:
             ap.write("%d"%defaultpointervalue)
     self.DbObj = DatabaseManagement(self.databasename)
     self.DbObj.CreateTable()
     with open("position","r") as gp:
         self.databaseposition = int(gp.read())
     self.databasePosition = self.databaseposition + 1
     #self.databasePosition = len(self.DbObj.FetchData()) + 1
     self.newword = self.addword_inputneword.text()
     self.newword_syn = self.addword_inputsynonym.text()
     self.newword_mean = self.additem_meaning.text()
     if len(self.newword) == 0 or len(self.newword_mean) == 0:
         #!it should raise error as requisite information is not given.
         self.error_msgBox = QMessageBox()
         self.error_msgBox.setIcon(QMessageBox.Critical)
         self.error_msgBox.setText("Please Input Required information To Save New Word.")
         self.error_msgBox.setWindowTitle("Complete Details Not Provided")
         self.error_msgBox.setStandardButtons(QMessageBox.Ok)
         self.error_msgBox.show()
         pass
     else:
         with open("position","w") as lp:
             lp.write("%d"%self.databasePosition)
         self.DbObj.InsertNewDetails(self.databasePosition,self.newword,self.newword_syn,self.newword_mean)
         self.AddWord_.close()
Esempio n. 2
0
 def RefreshContents(self):
     self.DbObj = DatabaseManagement(self.database_name)
     self.DbObj.CreateTable()
     while True:
         if Ui_SpecificCatagory_Manager.DatabaseDeleted:
             self.DbObj.DeleteDatabase()
             Ui_SpecificCatagory_Manager.DatabaseDeleted = False
         else:
             sleep(0.5)
             self.DatabaseDetails = self.DbObj.FetchData()
             self.opened_cata_tableWidget.clearContents()
             if len(self.DatabaseDetails) != 0:
                 for rowno, rowdata in enumerate(self.DatabaseDetails):
                     for colno, coldata in enumerate(rowdata):
                         self.opened_cata_tableWidget.setItem(
                             rowno, colno,
                             QtWidgets.QTableWidgetItem(str(coldata)))
Esempio n. 3
0
 def OpenCataManager(self, catagory_name):
     if path.isfile(catagory_name):
         self.Dialog.close()
         self.SpecificCatagory_Manager = QtWidgets.QMainWindow()
         self.SpecificCatagory_ManagerUI = Ui_SpecificCatagory_Manager(
             catagory_name)
         self.SpecificCatagory_ManagerUI.setupUi(
             self.SpecificCatagory_Manager)
         self.SpecificCatagory_Manager.show()
     else:
         #!Catagory Entry Found In Configuration File But No Database Found Of Such Catagory.
         DbObj = DatabaseManagement(catagory_name)
         DbObj.CreateTable()
         DbObj.CloseConnections()
         self.error_msgBox = QMessageBox()
         self.error_msgBox.setIcon(QMessageBox.Information)
         self.error_msgBox.setText(
             "No Database Entry Found Of Catagory, Blank Database Created.")
         self.error_msgBox.setWindowTitle("No Catagory Exists.")
         DbObj.CloseConnections()
         self.error_msgBox.setStandardButtons(QMessageBox.Ok)
         self.error_msgBox.show()
Esempio n. 4
0
 def DeleteFinal(self):
     self.targetdeleteID = self.deleteword_id.text()
     self.DbObj = DatabaseManagement(self.databasename)
     self.DbObj.DeleteWholeRow(self.targetdeleteID)
     self.DeleteWord.close()