Skip to content

LocaleEdit

Qt Base Class: QComboBox

Signature: QComboBox(self, parent: Optional[PySide6.QtWidgets.QWidget] = None) -> None

Base classes

Name Children Inherits
ComboBox
prettyqt.widgets.combobox

⋔ Inheritance diagram

graph TD
  1473367092112["custom_widgets.LocaleEdit"]
  1473296236368["widgets.ComboBox"]
  1473296223680["widgets.ComboBoxMixin"]
  1473293688240["widgets.WidgetMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473245548480["gui.PaintDeviceMixin"]
  1473241370080["QtWidgets.QComboBox"]
  1473290849680["QtWidgets.QWidget"]
  1473288842240["QtCore.QObject"]
  1473291690208["Shiboken.Object"]
  1473300082368["QtGui.QPaintDevice"]
  1473296236368 --> 1473367092112
  1473296223680 --> 1473296236368
  1473293688240 --> 1473296223680
  1473299815024 --> 1473293688240
  140713234304496 --> 1473299815024
  1473245548480 --> 1473293688240
  140713234304496 --> 1473245548480
  1473241370080 --> 1473296236368
  1473290849680 --> 1473241370080
  1473288842240 --> 1473290849680
  1473291690208 --> 1473288842240
  140713234304496 --> 1473291690208
  1473300082368 --> 1473290849680
  1473291690208 --> 1473300082368

🛈 DocStrings

Bases: ComboBox

Source code in prettyqt\custom_widgets\editors\localeedit.py
class LocaleEdit(widgets.ComboBox):
    value_changed = core.Signal(core.Locale)

    def __init__(
        self,
        locale: core.QLocale | None = None,
        object_name: str = "locale_edit",
        **kwargs,
    ):
        super().__init__(object_name=object_name, **kwargs)
        self._current_locale = core.Locale()
        for i in core.Locale.get_all_locales():
            self.addItem(i.bcp47Name())
        if locale is not None:
            self.set_current_locale(locale)
        self.currentTextChanged.connect(self.set_current_locale)

    def __repr__(self):
        return get_repr(self, self._current_locale)

    def clear(self):
        self._current_locale = core.Locale()
        super().clear()
        for i in core.Locale.get_all_locales():
            self.addItem(i.bcp47Name())

    # def _on_value_change(self):
    #     self._value = self.get_value()
    #     self.value_changed.emit(self._value)

    def set_current_locale(self, locale: core.QLocale | str):
        self._current_locale = core.Locale(locale)
        self.set_current_text(self._current_locale.bcp47Name())

    def is_valid(self) -> bool:
        return self._current_locale.isValid()

    def get_value(self) -> core.QLocale:
        return self._current_locale

    def set_value(self, value: core.QLocale | str):
        self.set_current_locale(value)

    value = core.Property(
        core.QLocale,
        get_value,
        set_value,
        user=True,
        doc="Currently chosen locale",
    )

⌗ 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
editable bool
count int
currentText QString
currentIndex int
currentData QVariant
maxVisibleItems int
maxCount int
insertPolicy QComboBox::InsertPolicy
sizeAdjustPolicy QComboBox::SizeAdjustPolicy
minimumContentsLength int
iconSize QSize
placeholderText QString
duplicatesEnabled bool
frame bool
modelColumn int
value QLocale Currently chosen locale