Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62143
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'say,': 0.05; 'tkinter': 0.07; 'string': 0.09; 'ascii': 0.09; 'assuming': 0.09; 'buttons': 0.09; 'default.': 0.09; 'measure': 0.09; 'pixel': 0.09; 'pixels': 0.09; 'preferable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'screen.': 0.09; 'jan': 0.12; 'systems.': 0.12; 'assume': 0.14; 'windows': 0.15; 'command-line': 0.16; 'displayed.': 0.16; 'experiment.': 0.16; 'fancy': 0.16; 'public,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'subject:Tkinter': 0.16; 'unicode)': 0.16; 'wrote:': 0.18; 'possible,': 0.19; 'skip:f 30': 0.19; 'seems': 0.21; '>>>': 0.22; 'select': 0.22; 'import': 0.22; 'header:User- Agent:1': 0.23; 'case.': 0.24; 'question': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'character': 0.29; 'characters': 0.30; 'label': 0.30; "i'm": 0.30; "skip:' 10": 0.31; 'default,': 0.31; 'font': 0.31; 'work:': 0.31; 'probably': 0.32; 'know.': 0.32; 'option': 0.32; 'text': 0.33; 'display': 0.35; 'one,': 0.35; 'but': 0.35; 'version': 0.36; 'marks': 0.36; 'revert': 0.36; 'sequence': 0.36; 'method': 0.36; 'ahead': 0.38; 'question,': 0.38; 'whatever': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'length': 0.61; 'skip:t 30': 0.61; 'received:173': 0.61; 'email addr:gmail.com': 0.63; 'more': 0.64; 'covers': 0.68; 'default': 0.69; 'fonts': 0.84; 'received:fios.verizon.net': 0.84; "they'd": 0.84; 'graphical': 0.91; 'labels.': 0.93; 'subject:available': 0.93 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Terry Reedy <tjreedy@udel.edu> |
| Subject | Re: Determining whether a glyph is available in Tkinter |
| Date | Mon, 16 Dec 2013 22:58:06 -0500 |
| References | <f84fbcb9-e784-4a2a-9c27-d55136e3c7b2@googlegroups.com> <mailman.4233.1387222873.18130.python-list@python.org> <c2a0c7e1-4983-4187-b35f-8f7c0ae834e5@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | pool-173-75-254-207.phlapa.fios.verizon.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
| In-Reply-To | <c2a0c7e1-4983-4187-b35f-8f7c0ae834e5@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4255.1387252699.18130.python-list@python.org> (permalink) |
| Lines | 51 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1387252699 news.xs4all.nl 2860 [2001:888:2000:d::a6]:58197 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:62143 |
Show key headers only | View raw
On 12/16/2013 6:59 PM, wmcbrine@gmail.com wrote:
> I'm not going to control the font.
Tk widgets that display text must use *some* font. If you do not select
one, then you get the system-dependent default.
for k, v in tk.Text().configure().items(): print(k, v)
...
font ('font', 'font', 'Font', <font object: 'TkFixedFont'>, 'TkFixedFont')
TkTextFont may be preferable for your purposes, although on Windows both
might be Courier New.
> This is for a program that's
> distributed to the general public, for use on a wide variety of
> systems. But what I do in the current version is to use the ASCII
> label strings by default, and have a command-line option to select
> the "graphical" (non-ASCII Unicode) labels. What I want is to make
> the graphical labels the default, and have the program detect, at
> runtime, whether any of the glyphs used in the fancy labels would
> render as "\uNNNN" in whatever the default font for the buttons is,
> and automatically revert to the ASCII labels in that case.
I would not assume that the default covers more than ascii.
But to answer your question, this might work: fonts have a measure()
method that returns what the pixel length of a string would be if it
were to be displayed.
>>> import tkinter.font as tkf
>>> ft=tkf.Font(font='TkFixedFont')
>>> ft.metrics()
{'ascent': 17, 'descent': 5, 'fixed': 1, 'linespace': 22}
>>> ft.measure('a')
12
>>> ft.measure('\u9fff')
12
*If* the measure is, say, 50 or more for a character that would display
as \uNNNN, then you would know. Go ahead and experiment.
> I'm assuming this is possible, because Tkinter itself seems to know
> which glyphs are unavailable, or they'd probably be showing up as
> those boxed number characters or question marks instead of "\uNNNN".
I do not know whether it is tk itself or a system graphics call that
translates a sequence of codes to pixels on the screen.
--
Terry Jan Reedy
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Determining whether a glyph is available in Tkinter wmcbrine@gmail.com - 2013-12-16 09:32 -0800
Re: Determining whether a glyph is available in Tkinter Terry Reedy <tjreedy@udel.edu> - 2013-12-16 14:41 -0500
Re: Determining whether a glyph is available in Tkinter wmcbrine@gmail.com - 2013-12-16 15:59 -0800
Re: Determining whether a glyph is available in Tkinter Terry Reedy <tjreedy@udel.edu> - 2013-12-16 22:58 -0500
Re: Determining whether a glyph is available in Tkinter wmcbrine@gmail.com - 2013-12-19 15:10 -0800
Re: Determining whether a glyph is available in Tkinter wxjmfauth@gmail.com - 2013-12-20 01:18 -0800
csiph-web