def mostrar_mensaje(self): mensaje = QMessageBox() mensaje.setIcon(QMessageBox.Icon.Information) #Information, NoIcon, Question,Warning, Critical mensaje.setText('Ha hecho Click sobre el botón!!!') mensaje.setDetailedText('Hola..') mensaje.setWindowTitle('sdf') mensaje.exec()
def importImages(self): """Import the images a user selects, remove duplicates, and add items to the QListWidget.""" duplicate_images = [] # Store the names of duplicate images image_paths, _ = QFileDialog.getOpenFileNames(self, "Select Image Files", "", "Images (*.png *.xpm *.jpg *.jpeg)") if image_paths: if self.image_dir.exists(): for image_path in image_paths: # Pass image path to QFileInfo object image_info = QFileInfo(image_path) file_name = image_info.fileName() item_name = image_info.baseName() # Copy the files into the Images directory, check for files # with the same name new_name = self.image_dir.absolutePath() + f"/{file_name}" file_exists = QFile.copy(image_path, new_name) if file_exists == False: duplicate_images.append(image_path) else: self.createListItems(image_path, item_name, image_info, new_name) if self.is_delete_checked == True: # Handle deleting images QFile.moveToTrash(image_path) else: QMessageBox.warning(self, "Images Location Not Found", """<p>The Images Location cannot be found. Restart the application to recreate the directory.</p>""") # Display a custom dialog to inform the user of duplicate images if len(duplicate_images) != 0: duplicates_dialog = QMessageBox(self) duplicates_dialog.setIcon(QMessageBox.Icon.Information) duplicates_dialog.setWindowTitle("Duplicate Images") duplicates_dialog.setText("""<p>Some images were not imported because they already exist.</p>""") details = '\n'.join([item for item in duplicate_images]) duplicates_dialog.setDetailedText(details) duplicates_dialog.exec() duplicate_images.clear() # Clear the list # Check if window is still in focus. If not, give it focus if self.isActiveWindow() == False: self.activateWindow()
def eliminar(self): confirmacion = QMessageBox(self) confirmacion.setText( f'Desea Eliminar el Producto con ID {self.txt_producto.text()}?') confirmacion.setIcon(QMessageBox.Icon.Question) confirmacion.setDetailedText( 'El producto se eliminará definitivamente...') confirmacion.setWindowTitle('Confirmación...') confirmacion.setStandardButtons(QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No) boton_yes = confirmacion.button(QMessageBox.StandardButton.Yes) confirmacion.exec() if confirmacion.clickedButton() == boton_yes: self.lbl_resultado.setText( f'Se ha eliminado el producto con ID {self.txt_producto.text()}.' ) else: self.lbl_resultado.setText( f'No se ha eliminado el producto con ID {self.txt_producto.text()}.' )