Re: How to change menu text with Tkinter?

2006-10-01 Thread Scott David Daniels
Phil Schmidt wrote:
 Eric Brunel wrote:
 But Marc's answer still applies: it's a lot of work for something that
 will usually be configured once. So requiring to restart the tool when the
 UI language changes should be acceptable.
 
 Thanks for the example, that helps.
 
 I agree with you and Marc regarding the language configuration method.
 The requirements aren't mine however - my customer wants the language
 selectable at runtime, so I'm kind of stuck with that.

You might also explain to the customer that of any menu elements are
ordered alphabetically, the result of changing the language will be
jarring to the user, as well as expensive to implement.

--Scott David Daniels
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list


How to change menu text with Tkinter?

2006-09-27 Thread Phil Schmidt
I am making a little Tkinter GUI app that needs to be in several
languages (english, french, etc.), adjustable at runtime via a menu
pick to select the language. The only way I can see to change text in
the menus entries is to destroy them and recreate them usiing different
labels. This seems very clunky though, and there must be a better way.
Can anyone offer any pointers or a short example for how to do this?

Thanks,
Phil

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to change menu text with Tkinter?

2006-09-27 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Phil Schmidt
wrote:

 I am making a little Tkinter GUI app that needs to be in several
 languages (english, french, etc.), adjustable at runtime via a menu
 pick to select the language. The only way I can see to change text in
 the menus entries is to destroy them and recreate them usiing different
 labels. This seems very clunky though, and there must be a better way.
 Can anyone offer any pointers or a short example for how to do this?

Do you really need this at runtime or is it enough to store the language
in a config file and ask the user to restart the application?  Then using
the `gettext` module is a good way.  Maybe in combination with the
`locale` module so you can use the language of the operating system as
default if the user doesn't choose one explicitly.

Ciao,
Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to change menu text with Tkinter?

2006-09-27 Thread Rob Wolfe

Phil Schmidt wrote:
 I am making a little Tkinter GUI app that needs to be in several
 languages (english, french, etc.), adjustable at runtime via a menu
 pick to select the language. The only way I can see to change text in
 the menus entries is to destroy them and recreate them usiing different
 labels. This seems very clunky though, and there must be a better way.
 Can anyone offer any pointers or a short example for how to do this?

Try this:

menu.entryconfig(index, label=new_name)

HTH,
Rob

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to change menu text with Tkinter?

2006-09-27 Thread Eric Brunel
On Wed, 27 Sep 2006 15:29:32 +0200, Phil Schmidt  
[EMAIL PROTECTED] wrote:

 I am making a little Tkinter GUI app that needs to be in several
 languages (english, french, etc.), adjustable at runtime via a menu
 pick to select the language. The only way I can see to change text in
 the menus entries is to destroy them and recreate them usiing different
 labels. This seems very clunky though, and there must be a better way.
 Can anyone offer any pointers or a short example for how to do this?

Here is a way:

--
 from Tkinter import *

root = Tk()
mb = Menu(root)
root.configure(menu=mb)
fm = Menu(mb)
mb.add_cascade(label='File', menu=fm)

def chlg():
   mb.entryconfigure(1, label='Fichier')
   fm.entryconfigure(1, label='Changer de langue')
   fm.entryconfigure(2, label='Quitter')

fm.add_command(label='Change language', command=chlg)
fm.add_command(label='Quit', command=root.quit)

root.mainloop()
--

Note that the entry indices start at 1 because of the 'tearoff' entry that  
is always created in a menu. If you specify the option tearoff=0 when  
creating the menus, indices will start ot 0.

But Marc's answer still applies: it's a lot of work for something that  
will usually be configured once. So requiring to restart the tool when the  
UI language changes should be acceptable.

 Thanks,
 Phil

HTH
-- 
python -c print ''.join([chr(154 - ord(c)) for c in  
'U(17zX(%,5.zmz5(17l8(%,5.Z*(93-965$l7+-'])
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to change menu text with Tkinter?

2006-09-27 Thread Phil Schmidt

Eric Brunel wrote:



 But Marc's answer still applies: it's a lot of work for something that
 will usually be configured once. So requiring to restart the tool when the
 UI language changes should be acceptable.


Thanks for the example, that helps.

I agree with you and Marc regarding the language configuration method.
The requirements aren't mine however - my customer wants the language
selectable at runtime, so I'm kind of stuck with that.

Phil

-- 
http://mail.python.org/mailman/listinfo/python-list