tkinter text width

Eric Brunel eric_brunel at despammed.com
Fri Apr 29 03:57:58 EDT 2005


On Thu, 28 Apr 2005 16:14:02 GMT, Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:

> On Thu, 28 Apr 2005 10:36:18 +0200, "Eric Brunel"
> <eric_brunel at despammed.com> declaimed the following in comp.lang.python:
>
>> This is the case on all platforms, but far more sensible on Windows: Windows attempts to be "clever" and corrects the font size you give depending on your screen resolution so that a 12 point font is supposed to be actually 12/72 inches *on screen* (obviously ignoring the fact that this is almost never
>
> 	Pardon? Since when has Windows attempted to scale fonts for
> screen display based on screen resolution?
>
> 	The older Macs were fixed at 72 pixels per inch -- with the
> result that the /only/ way to increase the resolution was to physically
> change to a larger monitor. This is why they were so popular for DTP --
> the on-screen view WAS the same size as the printed view.
>
> 	Windows display properties defaults to an /assumed/ 96 pixels
> per inch regardless of the screen resolution (right-click the desktop
> background, properties, Settings/Advanced, General). This is why
> changing to a low-resolution (like the recovery mode screen on W98) on a
> large monitor results in such a pixilated, large-character, display.
>
> 	I'm currently running a 20" flat-panel at 1600x1200. It also
> appears to be about 12" vertical display region, making for
> 100pixels/inch. If I set it to 800x600, it would be running at 50pixels
> per inch -- even though Windows is still assuming 96ppi for rendering. A
> 12pt typeface would be just under 1/8" on normal, but 1/4" on the low
> resolution setting.

Sorry for that: my mistake. Anyway, the problem remains; the ouput for the "tk scaling" command on Windows and Linux is as follows:

[Windows]
% tk scaling
1.33202228777

[Linux]
% tk scaling
1.04285347703

(all of this tested with tcl/tk 8.3 - Windows is Win2k, Linux is an old Mandrake 8.0).

So this means that when you ask for a 12 point font, Windows will give you a 12 * 1.33202228777 = 16 screen pixels font and Linux a 12 * 1.04285347703 = 12 or 13 screen pixels font, depending on how the size is rounded. But the dimensions you set for all widgets are in screen pixels, unless explicitely given in another unit. So either you do a "tk scaling 1" at the beginning of all your apps, or you specify all widget diemnsions as '100p' instead of just 100 for example. If you don't do either, all your texts will look really bigger on Windows than on Linux.
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in 'U(17zX(%,5.zmz5(17;8(%,5.Z65\\'*9--56l7+-'])"



More information about the Python-list mailing list