Skip to content

Shared Constants

Centralized constants for animation durations, icon sizes, and SVG icon data used across all widget modules.


Overview

ezqt_widgets.widgets.shared defines the canonical values shared across all widgets in the library. Using these constants instead of inline literals ensures that animation timings and icon sizes are consistent throughout an application.

The module contains three groups of constants:

  • Animation durations — millisecond values for QPropertyAnimation duration
  • Icon sizesQSize instances for icon rendering
  • SVG icon bytes — inline bytes objects for all common icons

Import

from ezqt_widgets.widgets.shared import (
    ANIMATION_DURATION_FAST,
    ANIMATION_DURATION_NORMAL,
    ANIMATION_DURATION_SLOW,
    ICON_SIZE_SMALL,
    ICON_SIZE_NORMAL,
    ICON_SIZE_LARGE,
    ICON_SIZE_XLARGE,
    SVG_FOLDER,
    SVG_SEARCH,
    # ... other SVG constants
)

Animation Durations

Integer constants in milliseconds for use as QPropertyAnimation.setDuration() arguments.

Constant Value Intended use
ANIMATION_DURATION_FAST 150 Hover states, quick feedback
ANIMATION_DURATION_NORMAL 250 Standard transitions (most animations)
ANIMATION_DURATION_SLOW 400 Emphasis animations, complex multi-step sequences
from PySide6.QtCore import QPropertyAnimation
from ezqt_widgets.widgets.shared import ANIMATION_DURATION_NORMAL

anim = QPropertyAnimation(widget, b"geometry")
anim.setDuration(ANIMATION_DURATION_NORMAL)

Icon Sizes

QSize constants for icon rendering. Pass directly to QLabel.setFixedSize(), QAbstractButton.setIconSize(), or QSvgRenderer pixel map dimensions.

Constant Value Typical use
ICON_SIZE_SMALL 14 x 14 Compact mode, tight layouts
ICON_SIZE_NORMAL 16 x 16 Standard button and input icons
ICON_SIZE_LARGE 20 x 20 Notification icons, emphasis
ICON_SIZE_XLARGE 24 x 24 Toolbar icons, large touch targets
from ezqt_widgets.widgets.shared import ICON_SIZE_NORMAL

button.setIconSize(ICON_SIZE_NORMAL)

SVG Icon Bytes

Raw SVG data as bytes objects. All icons share a consistent style:

  • viewBox="0 0 24 24"
  • fill="none"
  • stroke="currentColor" (or "white" for notification-level icons)
  • stroke-width="2" (or 2.5 for notification icons)
  • stroke-linecap="round", stroke-linejoin="round"

General-purpose icons (stroke="currentColor")

Constant Description
SVG_FOLDER Open folder — used by FilePickerInput
SVG_SEARCH Magnifying glass — used by SearchInput
SVG_EYE_OPEN Eye (password visible) — used by PasswordInput
SVG_EYE_CLOSED Eye with slash (password hidden) — used by PasswordInput
SVG_CALENDAR Calendar grid — used by DateButton
SVG_CHEVRON_RIGHT Right-pointing chevron — collapsed state indicator
SVG_CHEVRON_DOWN Down-pointing chevron — expanded state indicator
SVG_CLOSE Cross (×) — generic close action
SVG_SPINNER Eight-spoke spinner — used by LoaderButton
SVG_CHECK Checkmark — success confirmation
SVG_CROSS Cross (×) — error or dismissal (alias of SVG_CLOSE style)

Notification icons (stroke="white")

These icons use a white stroke for legibility on the colored backgrounds of NotificationBanner.

Constant Level Description
SVG_INFO INFO Circle with "i" dot
SVG_WARNING WARNING Triangle with "!" lines
SVG_ERROR ERROR Circle with × lines
SVG_SUCCESS SUCCESS Circle with checkmark
from PySide6.QtCore import QByteArray, QSize
from PySide6.QtGui import QPainter, QPixmap
from PySide6.QtSvg import QSvgRenderer
from PySide6.QtCore import Qt
from ezqt_widgets.widgets.shared import SVG_CHECK

renderer = QSvgRenderer(QByteArray(SVG_CHECK))
pixmap = QPixmap(QSize(16, 16))
pixmap.fill(Qt.GlobalColor.transparent)
painter = QPainter(pixmap)
renderer.render(painter)
painter.end()

_defaults

Shared widget constants module.

Centralises all constants shared across widget modules
  • Animation durations
  • Default icon sizes (QSize)
  • SVG icon bytes for all common icons
SVG icons follow a consistent style
  • viewBox="0 0 24 24"
  • fill="none"
  • stroke="currentColor" (or "white" for notification icons)
  • stroke-width="2"
  • stroke-linecap="round"
  • stroke-linejoin="round"

ANIMATION_DURATION_FAST module-attribute

ANIMATION_DURATION_FAST: int = 150

Fast transitions (hover, quick feedback).

ANIMATION_DURATION_NORMAL module-attribute

ANIMATION_DURATION_NORMAL: int = 250

Standard transitions (most animations).

ANIMATION_DURATION_SLOW module-attribute

ANIMATION_DURATION_SLOW: int = 400

Slow transitions (emphasis, complex animations).

ICON_SIZE_SMALL module-attribute

ICON_SIZE_SMALL: QSize = QSize(14, 14)

Small icon size (14x14 px).

ICON_SIZE_NORMAL module-attribute

ICON_SIZE_NORMAL: QSize = QSize(16, 16)

Normal icon size (16x16 px).

ICON_SIZE_LARGE module-attribute

ICON_SIZE_LARGE: QSize = QSize(20, 20)

Large icon size (20x20 px).

ICON_SIZE_XLARGE module-attribute

ICON_SIZE_XLARGE: QSize = QSize(24, 24)

Extra-large icon size (24x24 px).

SVG_FOLDER module-attribute

SVG_FOLDER: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"/></svg>'

Folder / open-folder icon (from FilePickerInput).

SVG_SEARCH: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <circle cx="11" cy="11" r="8"/>  <line x1="21" y1="21" x2="16.65" y2="16.65"/></svg>'

Search / magnifying-glass icon.

SVG_EYE_OPEN module-attribute

SVG_EYE_OPEN: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>  <circle cx="12" cy="12" r="3"/></svg>'

Eye (password visible) icon.

SVG_EYE_CLOSED module-attribute

SVG_EYE_CLOSED: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8   a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12   4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07   a3 3 0 1 1-4.24-4.24"/>  <line x1="1" y1="1" x2="23" y2="23"/></svg>'

Eye-closed (password hidden) icon.

SVG_CALENDAR module-attribute

SVG_CALENDAR: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <rect x="3" y="4" width="18" height="18" rx="2" ry="2"/>  <line x1="16" y1="2" x2="16" y2="6"/>  <line x1="8" y1="2" x2="8" y2="6"/>  <line x1="3" y1="10" x2="21" y2="10"/></svg>'

Calendar icon.

SVG_CHEVRON_RIGHT module-attribute

SVG_CHEVRON_RIGHT: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <polyline points="9 18 15 12 9 6"/></svg>'

Chevron pointing right (collapsed state).

SVG_CHEVRON_DOWN module-attribute

SVG_CHEVRON_DOWN: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <polyline points="6 9 12 15 18 9"/></svg>'

Chevron pointing down (expanded state).

SVG_CLOSE module-attribute

SVG_CLOSE: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <line x1="18" y1="6" x2="6" y2="18"/>  <line x1="6" y1="6" x2="18" y2="18"/></svg>'

Close / × icon.

SVG_INFO module-attribute

SVG_INFO: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"  fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round"  stroke-linejoin="round">  <circle cx="12" cy="12" r="10"/>  <line x1="12" y1="8" x2="12" y2="8"/>  <line x1="12" y1="12" x2="12" y2="16"/></svg>'

Info notification icon (white stroke, for coloured backgrounds).

SVG_WARNING module-attribute

SVG_WARNING: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"  fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round"  stroke-linejoin="round">  <path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0    1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/>  <line x1="12" y1="9" x2="12" y2="13"/>  <line x1="12" y1="17" x2="12.01" y2="17"/></svg>'

Warning notification icon (white stroke, for coloured backgrounds).

SVG_ERROR module-attribute

SVG_ERROR: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"  fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round"  stroke-linejoin="round">  <circle cx="12" cy="12" r="10"/>  <line x1="15" y1="9" x2="9" y2="15"/>  <line x1="9" y1="9" x2="15" y2="15"/></svg>'

Error notification icon (white stroke, for coloured backgrounds).

SVG_SUCCESS module-attribute

SVG_SUCCESS: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"  fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round"  stroke-linejoin="round">  <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/>  <polyline points="22 4 12 14.01 9 11.01"/></svg>'

Success notification icon (white stroke, for coloured backgrounds).

SVG_SPINNER module-attribute

SVG_SPINNER: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <line x1="12" y1="2" x2="12" y2="6"/>  <line x1="12" y1="18" x2="12" y2="22"/>  <line x1="4.93" y1="4.93" x2="7.76" y2="7.76"/>  <line x1="16.24" y1="16.24" x2="19.07" y2="19.07"/>  <line x1="2" y1="12" x2="6" y2="12"/>  <line x1="18" y1="12" x2="22" y2="12"/>  <line x1="4.93" y1="19.07" x2="7.76" y2="16.24"/>  <line x1="16.24" y1="7.76" x2="19.07" y2="4.93"/></svg>'

Spinner / loading icon.

SVG_CHECK module-attribute

SVG_CHECK: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <polyline points="20 6 9 17 4 12"/></svg>'

Checkmark / success icon.

SVG_CROSS module-attribute

SVG_CROSS: bytes = b'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">  <line x1="18" y1="6" x2="6" y2="18"/>  <line x1="6" y1="6" x2="18" y2="18"/></svg>'

Cross / error icon.

options: show_source: false members: - ANIMATION_DURATION_FAST - ANIMATION_DURATION_NORMAL - ANIMATION_DURATION_SLOW - ICON_SIZE_SMALL - ICON_SIZE_NORMAL - ICON_SIZE_LARGE - ICON_SIZE_XLARGE - SVG_FOLDER - SVG_SEARCH - SVG_EYE_OPEN - SVG_EYE_CLOSED - SVG_CALENDAR - SVG_CHEVRON_RIGHT - SVG_CHEVRON_DOWN - SVG_CLOSE - SVG_INFO - SVG_WARNING - SVG_ERROR - SVG_SUCCESS - SVG_SPINNER - SVG_CHECK - SVG_CROSS