def delete(self, fileProj_id): try: q_box = QtWidgets.QMessageBox( self) #create a message box asking do you want to delete file q_box.setStandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes) q_box.setWindowTitle("Delete File") q_box.setText("Are you sure you would like to delete this file?") q_box.setStyleSheet( 'background-color: darkSlateGray; color: white; font: Courier') q_box.exec_() if (q_box.result() == QtWidgets.QMessageBox.Yes ): #if response is yes, deletes the file s.delete(service, self.fileProj_id[0]) #hide the deleted widget self.hide() else: print("User chose not to delete", self.name) except: #if file doesn't exist, must already be deleted error_dialog = QtWidgets.QErrorMessage( ) #show file already deleted error msg error_dialog.showMessage("File already deleted") error_dialog.setWindowTitle("File error") error_dialog.setStyleSheet( 'background-color: darkSlateGray; color: white; font: Courier') error_dialog.exec_()
def deleteProj(self): try: q_box = QtWidgets.QMessageBox( self ) #create a message box asking do you want to delete the project q_box.setStandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes) q_box.setWindowTitle("Delete Project") q_box.setText( "Are you sure you would like to delete this project?") q_box.setStyleSheet( 'background-color: darkSlateGray; color: white; font: Courier') q_box.setCursor(QCursor(QtCore.Qt.PointingHandCursor)) q_box.exec_() if (q_box.result() == QtWidgets.QMessageBox.Yes ): #if response is yes, deletes the the project s.delete(service, self.project_id) #hide the deleted widget self.win.currentWindow = self.win.projWidget self.hide() else: print("User chose not to delete", self.name) except: #if file doesn't exist, must already be deleted error_dialog = QtWidgets.QErrorMessage( ) #show project already deleted error msg error_dialog.showMessage("Project already deleted") error_dialog.setWindowTitle("File error") error_dialog.setStyleSheet( 'background-color: darkSlateGray; color: white; font: Courier') error_dialog.exec_()