[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnumed-devel] Re: [wxPython-users] How to make font sizes platform inde
From: |
Richard Terry |
Subject: |
[Gnumed-devel] Re: [wxPython-users] How to make font sizes platform independant |
Date: |
Tue, 22 Mar 2005 15:20:09 +1100 |
User-agent: |
KMail/1.5.4 |
On Mon, 21 Mar 2005 10:26 pm, you wrote:
I did eventually get the code implemented:
fontsize = int(12*(72.0/wx.WindowDC(self).GetPPI()[0]))
which Chris Barker (He's an oceanographer on the wxPython list who is pretty
cluey) suggested.
Wondered what your thoughts on this were - I enclose his comments from a
previous posting about the problem of platform independant font size.
Richard
================================================
It's due to the fact that you specify font sizes in points, then that is
translated into some pixel size according to what the system thinks the
Pixels Per Inch (PPI) of the screen is. Different systems have different
PPI, but worst than that, different systems with exactly the same actual
PPI can report different PPI, since there is no way to really know (What
is the PPI of a projector projected onto a 2 meter screen?)
Personally, I think this is pretty wacky, as everything else gets
defined in pixel units, so there is incompatibility. I'd love if it was
all or nothing: define everything is either pixels or physical units. If
physical units, you'd need everything to be a scalable vector format,
but I think only OS-X supports this at the moment (if even it does).
Anyway, my work around is to query the system PPI with
wx.DC.GetPPI()
Then use that to re-scale all the fonts in my code so that I'm
specifying font sizes in pixels, rather than points:
PointsPerPixels = 72.0 / wx.DC.GetPPI()
self.patient_selector.SetFont(wxFont(int(12 * PointsPerPixels), wxSWISS,
wxNORMAL, wxBOLD, False, ''))
This should result in a font about 12 points high on all systems.
It's a pain, I know.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
=====================================
> > Sorry Chris, I get the concept but don't understand the syntax. I put
> > this line into a file:
> >
> > PointsPerPixel = 72/wx.DC.GetPPI()
> > print PointsPerPixel
> >
> > And get this error message:
> >
> > File "gmImmunize_AU.py", line 194, in InitGui_VaccinationsList
> > PointsPerPixel = 72/wx.DC.GetPPI()
> > TypeError: unbound method GetPPI() must be called with DC instance as
> > first argument (got nothing instead)
> >
> > Can you be ultra-specific and concrete.
>
> wx.DC.GetPPI () is a method (a function attached to a class)
> A real object must exist before you can call it, in this case,
> an object of the type wx.DC
>
> DCs (device context) are a Windows concept, basically the 'driver' through
> which programs write to the screen. This dates back to the MS-DOS/Windows
> 3.1 days when the computer had so little RAM only 2-3 DCs could exist, all
> programs had to share them.
>
> To make a DC, call wx.ClientDC (widget)
> where widget is normally the widget you what to draw on
> (in this case its irrelevant which one of course, but you
> still need to do this)
>
>
> Ian
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnumed-devel] Re: [wxPython-users] How to make font sizes platform independant,
Richard Terry <=