[Tutor] Re: Tutor Digest, Vol 8, Issue 2

André Roberge andre.roberge at ns.sympatico.ca
Mon Oct 4 03:53:51 CEST 2004


I would like to know how dynamically change a label ('Open') in the file 
menu
below to ('Ouvrir') when the selected language is Francais/French ('fr')
in the Radiobutton choice.

Thanks in advance,

André Roberge
=======
from Tkinter import *
from tkFileDialog import askopenfilename

def onOpen():
    filename = askopenfilename()

def makemenu(self):
    top = Menu(self)
    self.config(menu=top)
    file = Menu(top)
    file.add_command(label='Open', command=onOpen)
    top.add_cascade(label='File', menu=file)

if __name__ == '__main__':
    root = Tk()
    makemenu(root)
    LANGUAGES = [
        ('English', 'en'),
        ('Francais', 'fr') ]
    v = StringVar()
    v.set('en')
    for text, language in LANGUAGES:
        lang = Radiobutton(root, text=text,
                        variable=v, value=language)
        lang.pack(anchor=W)
    root.mainloop()



More information about the Tutor mailing list