import os import logging from PyQt5.QtGui import QIcon from PyQt5 import QtWidgets from ArtNet.gui.dialogs.db_connection_dialog.db_connection_dialog import Ui_DBConnection class DBDialog(QtWidgets.QDialog): def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_DBConnection() self.ui.setupUi(self) self.data = {} self.ui.buttonBox.accepted.connect(self.getConnectionDetails) if os.path.isfile("./application_icon.png"): self.setWindowIcon(QIcon("./application_icon.png")) else: logging.warning("Didn't find application icon!") def getConnectionDetails(self): self.data = dict() self.data["host"] = self.ui.host_line_edit.text() self.data["port"] = self.ui.port_line_edit.text() self.data["database"] = self.ui.database_line_edit.text() self.data["user"] = self.ui.user_line_edit.text() self.data["password"] = self.ui.password_line_edit.text() self.accept() def exec_(self) -> dict: if super(DBDialog, self).exec_() == QtWidgets.QDialog.Rejected: return None return self.data