QMessageBox executing action even thou I clicked NO
-
Hello my friends,
yet again I have trouble with my code (which WORKED a few days ago...). In my project, I made a pushButton which is connected to a function which deletes a row from sqlite database. Function is displayed below.
Problem is, a row will be deleted EVEN IF I PRESS NO. MessageBox pops up with the question, but whatever answer I chose, it ALWAYS executes the query.
@def deleteFromDB(self):
name = (str(self.ui.searchName.text()).upper())
if name:
with con:
cur = con.cursor()
cur.execute('SELECT name FROM cases WHERE name =?',[name])
tempname = str(cur.fetchone())
if len(tempname) != 4 :
reply = QtGui.QMessageBox.question(self, 'Removal',
"Are you sure ", QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
cur.execute('DELETE FROM cases where name =?',[name])@indentation might be a little off, because my editor uses tabs for indentation and I tried to fix it on the spot for this posting.