Te damos la bienvenida a nuestra página web, en este lugar hallarás la respuesta de lo que estás buscando.
Ejemplo 1: qmessagebox pyqt5
import sys
from PyQt4.QtGui import*from PyQt4.QtCore import*defwindow():
app = QApplication(sys.argv)
w = QWidget()
b = QPushButton(w)
b.setText("Show message!")
b.move(50,50)
b.clicked.connect(showdialog)
w.setWindowTitle("PyQt Dialog demo")
w.show()
sys.exit(app.exec_())defshowdialog():
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setText("This is a message box")
msg.setInformativeText("This is additional information")
msg.setWindowTitle("MessageBox demo")
msg.setDetailedText("The details are as follows:")
msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
msg.buttonClicked.connect(msgbtn)
retval = msg.exec_()print"value of pressed message box button:", retval
defmsgbtn(i):print"Button pressed is:",i.text()if __name__ =='__main__':
window()
Ejemplo 2: ejemplo de información de pyqt5 qmessagebox
defopen_database(self, filename=''):""" This function opens a database and set this on the UI """# If not filename provide, then open dialog to selectif self.created:
QMessageBox.information(self,
self.tr("Information"),
self.tr("You may only have one database"" open at time."))
DEBUG("Ya existe una base de datos abierta")returnifnot filename:if self.__last_open_folder isNone:
directory = os.path.expanduser("~")else:
directory = self.__last_open_folder
filter_ = settings.SUPPORTED_FILES.split(';;')[0]
filename, _ = QFileDialog.getOpenFileName(self,
self.tr("Open Database"),
directory,
filter_)# If is canceled, returnifnot filename:return# Remember the folder
self.__last_open_folder = file_manager.get_path(filename)
DEBUG("Abriendo la base de datos: ''".format(filename))# If filename providetry:# Read pdb file
pfile_object = pfile.File(filename)
db_data = pfile_object.read()# Create a dict to manipulate data more easy
db_data = self.__sanitize_data(db_data)except Exception as reason:
QMessageBox.information(self,
self.tr("The file couldn't be open"),str(reason))
CRITICAL("Error al intentar abrir el archivo: ".format(reason))return# Create a database container widget
db_container = database_container.DatabaseContainer()try:
db_container.create_database(db_data)except Exception as reason:
QMessageBox.information(self,
self.tr("Error"),str(reason))
CRITICAL("Error al crear la base de datos: ".format(reason))return# Set the PFile object to the new database
db_container.pfile = pfile_object
# Add data base container to stacked
self.add_widget(db_container)# Database name
db_name = file_manager.get_basename(filename)# Update title with the new database name, and enable some actions
pireal = Pireal.get_service("pireal")
pireal.change_title(db_name)
pireal.set_enabled_db_actions(True)
pireal.set_enabled_relation_actions(True)# Add to recent databases
self.recent_databases = filename
self.created =True
Reseñas y puntuaciones
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)