On Wed, Feb 27, 2013 at 07:51:57AM -0800, James Paige wrote: > On Wed, Feb 27, 2013 at 04:08:08PM +0100, Mathieu Dubois wrote: > > Hello, > > > > I'm working on a program (written by someone else) to use PyGame to > > display some images for use in a psychological experiment. I am new to > > PyGame. > > > > For the experiment we need to display circles of a given physical size > > (let's that the diameter must be 30mm). Currently the program seems to > > do the conversion with a hardcoded value. > > > > I wanted to know if it possible to compute this value automatically. > > > > If I understand correctly, I need to know the physical size of the > > screen and the resolution. Knowing the resolution is simple with PyGame > > but how can I access the screen size? > > > > The program should be multi-platform. > > > > Any advice? > > > > Thanks in advance, > > Mathieu > > Sadly, I believe this is nearly impossible to do in a reliable an > automated way. This is not just for pygame, but any program. > > If you need to support monitors that connect with a VGA cable, then I > believe it is completely impossible. (if someone knows otherwise, please > correct me!) > > If the monitor is identified by the operating system, you can get the > DPI, but this information can't be trusted. DPI settings are seldom > guaranteed to be accurate. They might be correct, they might be > incorrect, they might be intentionally misconfigured to manipulate font > sizes, or other such ridiculous things. > > If you want something simple and cross-platform, I would suggest > displaying a calibration screen where you can hold a physical ruler up > to the screen while spinning the mouse wheel until the on-screen ruler > matches the physical ruler, and then save that constant in a config > file, or something like that. > > (Again, if anybody knows any tricks to do this automatically, please > speak up and correct me, but I will be shocked if there is a > single cross-platform way) >
Oh, one more thought! This question got me curious, and after some googling, I saw a nifty suggestion on stackoverflow. In addition to displaying a ruler, your calibration screen could also display photos of some common coins, since whoever is doing the calibration might have an easier time locating a coin than locating a ruler. --- James
