Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Christian Gollwitzer Newsgroups: comp.lang.python Subject: Re: apostrophe not considered with tkinter's wordstart and wordend Date: Thu, 22 Jan 2015 23:26:15 +0100 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: <655cce0d-2db3-4a0d-ab3d-64d5db5e1634@googlegroups.com> <714d9211-9b50-4e62-a7dd-25ff94a32d8a@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Thu, 22 Jan 2015 22:25:44 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="52ac7a71250a76d941bcb5c514e0f16a"; logging-data="1198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/THKj3HjfHRnkJVxF6Qp8n2FD8BKiwznI=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: Cancel-Lock: sha1:3wsyq958Lk2tebxsG9SAbAbukcc= Xref: csiph.com comp.lang.python:84283 Am 05.01.15 um 14:20 schrieb Rick Johnson: > *GASP*! Of course all this could be avoided if those short- > sighted TK folks would have allowed the programmer to define > the pattern! > > ಠ_ಠ Well, it turns out you actually can. We don't have Guido's time machine, but still there is a configuration option in Tk, albeit a very obscure one: you have to set the global Tcl variables tcl_wordchars and tcl_nonwordchars after loading Tk to a regexp which defines the word boundaries: http://wiki.tcl.tk/1655 Strangely, there is a different preset for Windows and X11. The Windows preset - consider everything besides space as part of the word - makes more sense to me than the Unix default, which only counts letters, numbers and underscores as part of the word. To set the Windows preset, do this: tk.eval('set tcl_wordchars {\S}'); tk.eval('set tcl_nonwordchars {\s}'); (untested in Python, only tested directly from a wish shell) Christian