Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35759

Re: Inserting Unicode chars in Entry widget

References <df4d0902-c40a-42de-8a6c-b997460313a9@googlegroups.com> <50df2439$0$6948$e4fe514c@news.xs4all.nl>
Date 2012-12-30 04:23 +1100
Subject Re: Inserting Unicode chars in Entry widget
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1432.1356801796.29569.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Dec 30, 2012 at 4:11 AM, Irmen de Jong <irmen.NOSPAM@xs4all.nl> wrote:
> b1=Button(f, text='char1', command=lambda b=1: insert_char(b))
> b2=Button(f, text='char2', command=lambda b=2: insert_char(b))
> ...etc..
>
> def insert_char(b):
>     if b==1:
>         entrywidget.insert(0, u"\u20ac")   # inserts € in the entry widget e
>     elif b==2:
>         entrywidget.insert(0, ...some other char...)
>     ...

I'm not familiar with tkinter syntax, but why not:

b1=Button(f, text='char1', command=lambda: insert_char(1))
b2=Button(f, text='char2', command=lambda: insert_char(2))

or even:

b1=Button(f, text='char1', command=lambda: insert_char(u"\u20ac"))
b2=Button(f, text='char2', command=lambda: insert_char("... some other
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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Inserting Unicode chars in Entry widget Alan Graham <alan.l.graham@gmail.com> - 2012-12-29 08:43 -0800
  Re: Inserting Unicode chars in Entry widget Chris Angelico <rosuav@gmail.com> - 2012-12-30 03:58 +1100
  Re: Inserting Unicode chars in Entry widget Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2012-12-29 18:11 +0100
    Re: Inserting Unicode chars in Entry widget Chris Angelico <rosuav@gmail.com> - 2012-12-30 04:23 +1100
      Re: Inserting Unicode chars in Entry widget Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2012-12-29 20:15 +0100

csiph-web