コード例 #1
0
    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(), "")
コード例 #2
0
 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))
コード例 #3
0
 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))
コード例 #4
0
 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, [])
コード例 #5
0
 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, [])
コード例 #6
0
    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))
コード例 #7
0
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)])
コード例 #8
0
    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_
コード例 #9
0
    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