Skip to content

InputDialog

Qt Base Class: QInputDialog

Signature: QInputDialog(self, parent: Optional[PySide6.QtWidgets.QWidget] = None, flags: PySide6.QtCore.Qt.WindowType = Default(Qt.WindowFlags)) -> None

Base classes

Name Children Inherits
DialogMixin
prettyqt.widgets.dialog
QInputDialog
PySide6.QtWidgets
QInputDialog(self, parent: Optional[PySide6.QtWidgets.QWidget] \= None, flags: PySide6.QtCore.Qt.WindowType \= Default(Qt.WindowFlags)) -> None

⋔ Inheritance diagram

graph TD
  1473296372032["widgets.InputDialog"]
  1473296195376["widgets.DialogMixin"]
  1473293688240["widgets.WidgetMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473245548480["gui.PaintDeviceMixin"]
  1473241377888["QtWidgets.QInputDialog"]
  1473241356416["QtWidgets.QDialog"]
  1473290849680["QtWidgets.QWidget"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473300082368["QtGui.QPaintDevice"]
  1473296195376 --> 1473296372032
  1473293688240 --> 1473296195376
  1473299815024 --> 1473293688240
  140713234304496 --> 1473299815024
  1473245548480 --> 1473293688240
  140713234304496 --> 1473245548480
  1473241377888 --> 1473296372032
  1473241356416 --> 1473241377888
  1473290849680 --> 1473241356416
  1473288842240 --> 1473290849680
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208
  1473300082368 --> 1473290849680
  1473291690208 --> 1473300082368

🛈 DocStrings

Bases: DialogMixin, QInputDialog

Simple convenience dialog to get a single value from the user.

Source code in prettyqt\widgets\inputdialog.py
class InputDialog(widgets.DialogMixin, widgets.QInputDialog):
    """Simple convenience dialog to get a single value from the user."""

    def _get_map(self):
        maps = super()._get_map()
        maps |= {
            "textEchoMode": widgets.lineedit.ECHO_MODE,
            "inputMode": INPUT_MODE,
            "options": INPUT_DIALOG_OPTION,
        }
        return maps

    @classmethod
    def get_int(
        cls,
        title: str = "",
        label: str = "",
        icon: datatypes.IconType = None,
    ) -> int | None:
        par = widgets.Dialog()
        par.set_icon(icon)
        v = cls.getInt(par, title, label, value=0)
        return v[0] if v[1] else None

    @classmethod
    def get_float(
        cls,
        title: str = "",
        label: str = "",
        icon: datatypes.IconType = None,
    ) -> float | None:
        par = widgets.Dialog()
        par.set_icon(icon)
        v = cls.getDouble(par, title, label, value=0.0)
        return v[0] if v[1] else None

    @classmethod
    def get_text(
        cls,
        title: str = "",
        label: str = "",
        icon: datatypes.IconType = None,
        value: str = "",
        echo_mode: widgets.lineedit.EchoModeStr | widgets.QLineEdit.EchoMode = "normal",
    ) -> str | None:
        par = widgets.Dialog()
        par.set_icon(icon)
        v = cls.getText(
            par, title, label, widgets.lineedit.ECHO_MODE.get_enum_value(echo_mode), value
        )
        return v[0] if v[1] else None

    @classmethod
    def get_item(
        cls,
        items: list[str],
        title: str = "",
        label: str = "",
        icon: datatypes.IconType = None,
        editable: bool = False,
    ) -> str | None:
        par = widgets.Dialog()
        par.set_icon(icon)
        v = cls.getItem(par, title, label, items, editable=editable, current=0)
        return v[0] if v[1] else None

    def set_text_echo_mode(
        self, mode: widgets.lineedit.EchoModeStr | widgets.QLineEdit.EchoMode
    ):
        """Set text echo mode.

        Args:
            mode: echo mode to use
        """
        self.setTextEchoMode(widgets.lineedit.ECHO_MODE.get_enum_value(mode))

    def get_text_echo_mode(self) -> widgets.lineedit.EchoModeStr:
        """Return text echo mode.

        Returns:
            echo mode
        """
        return widgets.lineedit.ECHO_MODE.inverse[self.textEchoMode()]

    def set_input_mode(self, mode: InputModeStr | mod.InputMode):
        """Set input mode.

        Args:
            mode: input mode to use
        """
        self.setInputMode(INPUT_MODE.get_enum_value(mode))

    def get_input_mode(self) -> InputModeStr:
        """Return input mode.

        Returns:
            input mode
        """
        return INPUT_MODE.inverse[self.inputMode()]

get_input_mode() -> InputModeStr

Return input mode.

Source code in prettyqt\widgets\inputdialog.py
def get_input_mode(self) -> InputModeStr:
    """Return input mode.

    Returns:
        input mode
    """
    return INPUT_MODE.inverse[self.inputMode()]

get_text_echo_mode() -> widgets.lineedit.EchoModeStr

Return text echo mode.

Source code in prettyqt\widgets\inputdialog.py
def get_text_echo_mode(self) -> widgets.lineedit.EchoModeStr:
    """Return text echo mode.

    Returns:
        echo mode
    """
    return widgets.lineedit.ECHO_MODE.inverse[self.textEchoMode()]

set_input_mode(mode: InputModeStr | mod.InputMode)

Set input mode.

Parameters:

Name Type Description Default
mode InputModeStr | InputMode

input mode to use

required
Source code in prettyqt\widgets\inputdialog.py
def set_input_mode(self, mode: InputModeStr | mod.InputMode):
    """Set input mode.

    Args:
        mode: input mode to use
    """
    self.setInputMode(INPUT_MODE.get_enum_value(mode))

set_text_echo_mode(mode: widgets.lineedit.EchoModeStr | widgets.QLineEdit.EchoMode)

Set text echo mode.

Parameters:

Name Type Description Default
mode EchoModeStr | EchoMode

echo mode to use

required
Source code in prettyqt\widgets\inputdialog.py
def set_text_echo_mode(
    self, mode: widgets.lineedit.EchoModeStr | widgets.QLineEdit.EchoMode
):
    """Set text echo mode.

    Args:
        mode: echo mode to use
    """
    self.setTextEchoMode(widgets.lineedit.ECHO_MODE.get_enum_value(mode))

⌗ Property table

Qt Property Type Doc
objectName QString
modal bool
windowModality Qt::WindowModality
enabled bool
geometry QRect
frameGeometry QRect
normalGeometry QRect
x int
y int
pos QPoint
frameSize QSize
size QSize
width int
height int
rect QRect
childrenRect QRect
childrenRegion QRegion
sizePolicy QSizePolicy
minimumSize QSize
maximumSize QSize
minimumWidth int
minimumHeight int
maximumWidth int
maximumHeight int
sizeIncrement QSize
baseSize QSize
palette QPalette
font QFont
cursor QCursor
mouseTracking bool
tabletTracking bool
isActiveWindow bool
focusPolicy Qt::FocusPolicy
focus bool
contextMenuPolicy Qt::ContextMenuPolicy
updatesEnabled bool
visible bool
minimized bool
maximized bool
fullScreen bool
sizeHint QSize
minimumSizeHint QSize
acceptDrops bool
windowTitle QString
windowIcon QIcon
windowIconText QString
windowOpacity double
windowModified bool
toolTip QString
toolTipDuration int
statusTip QString
whatsThis QString
accessibleName QString
accessibleDescription QString
layoutDirection Qt::LayoutDirection
autoFillBackground bool
styleSheet QString
locale QLocale
windowFilePath QString
inputMethodHints QFlags
sizeGripEnabled bool
modal bool