def test_ustr(self) -> None: """Test ustr function.""" self.assertEqual(utils_base.ustr(1.01), "1.01") self.assertEqual(utils_base.ustr(6.00), "6") self.assertEqual(utils_base.ustr(b"hola"), "hola") self.assertEqual(utils_base.ustr(), "")
def errorMsgBox(self, msg: str = None) -> None: """Show error message box.""" msg = ustr(msg) msg += u"\n" if self.interactiveGUI(): # QtWidgets.QMessageBox.critical( # QtWidgets.QApplication.focusWidget(), "Eneboo", msg, QtWidgets.QMessageBox.Ok # ) application.PROJECT.message_manager().send("msgBoxError", None, [msg]) else: LOGGER.warning(ustr(u"ERROR: ", msg))
def infoMsgBox(self, msg: str = "") -> None: """Show information message box.""" msg = ustr(msg) msg += u"\n" if self.interactiveGUI(): # QtWidgets.QMessageBox.information( # QtWidgets.QApplication.focusWidget(), "Eneboo", msg, QtWidgets.QMessageBox.Ok # ) application.PROJECT.message_manager().send("msgBoxInfo", None, [msg]) else: LOGGER.warning(ustr(u"INFO: ", msg))
def errorPopup(self, msg: str = "") -> None: """Show error popup.""" msg = ustr(msg) msg = msg.replace("\n", "<br>") caption = self.translate(u"AbanQ Error") msg_html = ustr( u'<img source="remove.png" align="right">', u"<b><u>", caption, u"</u></b><br><br>", msg, u"<br>", ) self._warnHtmlPopup(msg_html, [])
def infoPopup(self, msg: Optional[str] = None) -> None: """Show information popup.""" msg = ustr(msg) caption = self.translate(u"AbanQ Información") msg = msg.replace("\n", "<br>") msg_html = ustr( u'<img source="about.png" align="right">', u"<b><u>", caption, u"</u></b><br><br>", msg, u"<br>", ) self._warnHtmlPopup(msg_html, [])
def warnMsgBox(self, msg: str = "", *buttons: Any) -> None: """Show Warning message box.""" new_list = [] new_list.append("%s.\n" % ustr(msg)) for button in buttons: new_list.append(button) if self.interactiveGUI(): # QtWidgets.QMessageBox.warning( # QtWidgets.QApplication.focusWidget(), "Eneboo", msg, QtWidgets.QMessageBox.Ok # ) application.PROJECT.message_manager().send("msgBoxWarning", None, new_list) else: LOGGER.warning(ustr(u"WARN: ", msg))
def debug(txt: Union[bool, str, int, float]) -> None: """ Debug for QSA messages. @param txt. Mensaje. """ from pineboolib import application application.PROJECT.message_manager().send("debug", None, [ustr(txt)])
def testObj(self, container: QtWidgets.QWidget = None, component: str = "") -> Optional[QtWidgets.QWidget]: """Test if object does exist.""" if not container or container is None: return None object_ = cast(QtWidgets.QWidget, container.findChild(QtWidgets.QWidget, component)) if not object_: LOGGER.warning(ustr(component, u" no existe")) return None return object_
def runObjMethod(self, container: QtWidgets.QWidget, component: str, method: str, param: Any = None) -> bool: """Execute method from object.""" object_ = cast(QtWidgets.QWidget, container.findChild(QtWidgets.QWidget, component)) attr = getattr(object_, method, None) if attr is not None: attr(param) else: LOGGER.warning(ustr(method, u" no existe")) return True