Skip to content

Window position uses inconsistent coordinate units on Windows with display scaling #1809

@alemariani

Description

@alemariani

python: 3.13
pywebview: 6.1
platform: Windows 11

I noticed an inconsistency when setting and reading the window position on Windows with display scaling enabled.

  • When setting the window position, the display scale factor appears to be taken into account.
  • When reading the window position, the returned coordinates appear to be in physical pixels.

This makes the reported window coordinates inconsistent and difficult to use reliably.

Steps to reproduce:

  1. Use the example from: https://pywebview.flowrl.com/examples/move_window.html
  2. Add an extra print statement to log new_x and new_y.
  3. Run the example on a Windows 11 system with display scaling enabled.

This is the output I get:

Window coordinates are (375, 375)
Window dimensions are (996x738)
Primary screen: 2560x1440
new_x, new_y: (1464, 602)
Window coordinates are now (1830, 752)

This is my display setting

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions