Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'elif': 0.04; 'inserts': 0.07; 'tkinter': 0.07; 'command-line': 0.09; 'def': 0.10; 'dec': 0.15; 'weird': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:Entry': 0.16; 'subject:Unicode': 0.16; 'sure.': 0.16; 'syntax,': 0.16; 'wrote:': 0.17; 'widget': 0.17; 'seems': 0.23; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; "i'm": 0.29; 'to:addr:python- list': 0.33; 'entry': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'received:209.85.220': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'why': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; '30,': 0.62; 'more': 0.63; 'charset:windows-1252': 0.65; 'not:': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=KG6FpRuytz9rhJhOPwK217d39mRhtQZjsXVTbA60uMM=; b=ojG866W3rcCds1ZZZSbmuaioEN3rBDr1qNNCY0IyvFSj3yyAGsrb0J79vLmP1Hsy0Q W+ODosa4NISEkXwcOcAI1Z6g4sbAeMfZLwFJaL5GgfdBsxLSizfo4WjGplhOamu8wZoH zM4LjAYRP3z6yRiu8pzpiQjQa5FlQ/CmfIHOSfO78MeA+KZVhoYfI4CrleAwinGO8bxu tCm9HTXMwDsbmgGKe48InVroylAWPbL/tM7s2ZYG28djBeZ/Ub0dRbLrqIuijkn6jmSj j5UX8s4J80bZi3fB3h+2FbYUXiu1ngyYwYIEs/aXwjV0Ug3ZEKhE9rzHmD/HfwIbaK/5 03Kw== MIME-Version: 1.0 In-Reply-To: <50df2439$0$6948$e4fe514c@news.xs4all.nl> References: <50df2439$0$6948$e4fe514c@news.xs4all.nl> Date: Sun, 30 Dec 2012 04:23:07 +1100 Subject: Re: Inserting Unicode chars in Entry widget From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356801796 news.xs4all.nl 6893 [2001:888:2000:d::a6]:33524 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35759 On Sun, Dec 30, 2012 at 4:11 AM, Irmen de Jong wro= te: > b1=3DButton(f, text=3D'char1', command=3Dlambda b=3D1: insert_char(b)) > b2=3DButton(f, text=3D'char2', command=3Dlambda b=3D2: insert_char(b)) > ...etc.. > > def insert_char(b): > if b=3D=3D1: > entrywidget.insert(0, u"\u20ac") # inserts =80 in the entry wid= get e > elif b=3D=3D2: > entrywidget.insert(0, ...some other char...) > ... I'm not familiar with tkinter syntax, but why not: b1=3DButton(f, text=3D'char1', command=3Dlambda: insert_char(1)) b2=3DButton(f, text=3D'char2', command=3Dlambda: insert_char(2)) or even: b1=3DButton(f, text=3D'char1', command=3Dlambda: insert_char(u"\u20ac")) b2=3DButton(f, text=3D'char2', command=3Dlambda: insert_char("... some othe= r char...")) Seems weird to multiplex like that, but if there's a good reason for it, sure. I'm more of a GTK person than tkinter, and more of a command-line guy than either of the above. ChrisA