2

I can get the screen resolution in with

wx.DisplaySize()

but I don't see a method which gives me the DPI.

Kit
  • 30,365
  • 39
  • 105
  • 149

2 Answers2

2

An easier solution may be:

import wx
app = wx.App(0)
print wx.ScreenDC().GetPPI()

I tested it on Windows XP and it indeed prints (96, 96) with the default DPI-setting and (120, 120) with 120 DPI-setting.

Frank Niessink
  • 1,611
  • 12
  • 24
  • This prints 96 on a monitor that definitely is higher than 96. Qt works for me: https://stackoverflow.com/questions/54271887/calculate-screen-dpi – eric Jan 22 '19 at 03:34
0

I don't think there is any such function in wxPython, what you can do instead is, by using ctypes call win32api function GetDeviceCaps and get LOGPIXELSX/LOGPIXELSY

Anurag Uniyal
  • 85,954
  • 40
  • 175
  • 219