hoffstadt / hoffstadt/DearPyGui

x_pos doesn't work on viewport with high-res display (Windows)

Open
#2,362 0 comments 0 reactions 0 assignees View on GitHub
state: pending type: bug
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## Version of Dear PyGui

Version: 1.11.1
Operating System: Windows 10 (10.0.19045).

## My Issue/Question

When UI scaling is set to 200% in Windows, DPG viewport sticks to the left edge of the screen no matter what `x_pos` is specified for the viewport.

Reported in this Discord thread:
https://discord.com/channels/736279277242417272/1142953321821372550/1259654875193802864

Probably caused by `get_horizontal_shift` in `mvViewport_win32.cpp`: it seems to be unaware that `GetWindowRect` is affected by DPI scaling, whereas `DwmGetWindowAttribute` is not. Therefore DPI scaling probably affects the overall result, though I don't see how it can produce large enough offset.

Another hypothesis is that `GetWindowRect` fails for some reason, and `window_rectangle` remains uninitialized, which yields random garbage in the return value.

## To Reproduce

_TBD_

Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

## Expected behavior

`x_pos` placing the viewport at the specified position.

## Screenshots/Video

_TBD_

## Standalone, minimal, complete and verifiable example

_TBD_

```python
# Here's some code anyone can copy and paste to reproduce your issue
import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()

with dpg.window(label="tutorial"):
dpg.add_button(label="Press me")

more_code_to_explain_my_issue()

dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.