Hi,

Le 19/10/2012 06:48, Jae-Joon Lee a écrit :
> Figuring out the dpi of the screen, I have no clue at this moment.
> Maybe this is something a gui expert can answer.
I'm certainly not a gui expert, but as a PyQt user, I know screen
resolution is indeed Python-accessible with PyQt. (I guess other
toolkits provide their own methods)

I've made a quick script that prints the screen X and Y resolution
(requires PyQt). Reference links to PyQt API docs are included.


In my case, it's 96 dpi, and that what I use in my matplotlibrc file for
the "figure.dpi" property. But I use a higher value (say 150) for
"savefig.dpi" so that I get better resolution when saving PNG images.

I agree with Nikolaus that the dpi value for displaying figures would be
better get by the software, if possible. Maybe a property like
figure.dpi='auto' should activate such a behavior. But this would
require many code duplicates, one for each gui toolkit.


Best,
Pierre
#!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
Diplay the Screen resolution information from PyQt

References
-----------
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qapplication.html#desktop
http://qt-project.org/doc/qt-4.8/qapplication.html#desktop

http://lists.trolltech.com/qt-interest/2008-08/thread00258-0.html

Pierre Haessig — October 2012
"""
import sys
from PyQt4.QtGui import QApplication

app = QApplication(sys.argv)
desktop_widget = app.desktop()
print('Screen resolution:')
print('%d x %d DPI' % (desktop_widget.physicalDpiX(),
                       desktop_widget.physicalDpiY() ))

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to