Skip to content

UI elements do not adapt to high-DPI / Windows display scaling #101

@ThomasMalletCodra

Description

@ThomasMalletCodra

Describe the bug

guidata is not natively DPI-aware. When using a high-DPI monitor or a Windows display scaling factor of 150% / 200% / 300%, several UI elements rendered by guidata (especially DataSet edit dialogs, HTML representations, and utility widgets) do not scale properly. Text appears tiny, buttons and icons remain at their original pixel size, and HTML/_repr_html_ output uses hardcoded px values.

This is the foundational layer of the PlotPyStack: any application built on guidata (DataLab, X-GRID, custom scientific apps) inherits these issues, including the fact that guidata.qapplication() does not enable any high-DPI Qt attribute.

This is a global issue — sub-tasks are listed below.

To Reproduce

  1. Set Windows display scaling to 200% or 300% (Settings → Display → Scale and layout)
  2. Run any script that opens a DataSet edit dialog containing FloatItem, ChoiceItem, ImageChoiceItem, ColorItem, DictItem
  3. Observe: native Qt menus and title bars scale correctly, but
    • DataSet labels and editors look disproportionately small,
    • the color picker button (ColorItem) and the dict/array edit buttons are tiny,
    • icons in ImageChoiceItem / FileWidget are not scaled,
    • HTML tooltips / _repr_html_ use hardcoded 13px font and 8/12px padding,
    • the Python console widget keeps a fixed 10pt font.

Expected behavior

All UI elements should scale proportionally with the system display scaling factor and remain legible at any supported scale. The library should opt-in to high-DPI behavior on QApplication creation and replace hardcoded pixel values with font-metrics / QStyle.pixelMetric based equivalents.

Screenshots

Comparative captures at 100% vs 300% on the same DataSet dialog will be attached.

Installation information

  • guidata version: latest main
  • Qt binding: PyQt5 / PyQt6 / PySide6 (need to be specify when media is attached)
  • OS: Windows 10/11 (multi-DPI)

Additional context — Sub-tasks

SUB-1 · Bootstrap: enable HiDPI attributes in qapplication() (CRITICAL)

  • File: guidata/qthelpers.py (qapplication())
  • No call to Qt.AA_EnableHighDpiScaling, Qt.AA_UseHighDpiPixmaps, or setHighDpiScaleFactorRoundingPolicy(...).
  • Action: enable these (Qt-version aware) before QApplication is instantiated.
  • Expected outcome: this single change resolves an estimated 50% of visible symptoms downstream (PlotPy, PythonQwt, DataLab).

SUB-4 · DataSet item widgets — hardcoded pixel sizes (CRITICAL)

  • qtitemwidgets.py:865 — self.button.setMaximumWidth(32) (ColorItem)
  • qtitemwidgets.py:1365 — edit_button.setMaximumWidth(32) (Dict/Array edit)
  • qtitemwidgets.py:1116 — setIconSize(QSize(width, height)) (ImageChoiceItem)
  • qtitemwidgets.py:1507 — setIconSize(QSize(width, height)) (FileWidget)
  • qtwidgets.py:475 — QSpacerItem(20, 1)
  • qtwidgets.py:1071 — viewport width capped at 1024
  • Action: replace literal pixel values with QFontMetrics(font).horizontalAdvance("M") * N or style.pixelMetric(QStyle.PM_ButtonIconSize).

SUB-5 · HTML / _repr_html_ — hardcoded px (CRITICAL)

  • datatypes.py:92 — font-size: 13px;
  • datatypes.py:97 — padding: 8px 12px;
  • datatypes.py:1855-1879 — padding-left: 10px / 15px; in HTML tables
  • Action: convert to relative units (em, %, pt) so that Jupyter / tooltip rendering scales with the host font.

SUB-6 · Helpers and utility widgets (HIGH)

  • qthelpers.py:855 — font.setPointSize(20) in create_label
  • qthelpers.py:236, 242 — inline stylesheet with border: 1px solid / border-radius: 4px
  • widgets/console/init.py:67 — font.setPointSize(10)
  • widgets/importwizard.py:195 — setMaximumWidth(30)
  • widgets/arrayeditor/arrayeditor.py:204 — self.resize(600, 500)
  • widgets/iconbrowser.py:80, 147, 181
  • widgets/dataframeeditor.py:585

Audit findings — gap summary

  • Qt.AA_EnableHighDpiScaling: missing.
  • Qt.AA_UseHighDpiPixmaps: missing.
  • devicePixelRatio / logicalDpiX: never used.
  • No DPI-aware sizing helper exists in guidata.qthelpers.

Recommended order

SUB-1 first (quick win, unblocks downstream libraries), then SUB-4 and SUB-5 in parallel, then SUB-6.

Related issues

Other task are describe in the PlotPy issue and the PythonQwt issue (explained why there are missing SUB-X number)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions