【发布时间】:2018-01-20 19:25:47
【问题描述】:
我有一个记事本。 所以在记事本中有一个叫做'bar'的栏。 在这个栏中有一个名为“视图”的视图级联菜单。 在这个视图菜单中有一个名为“语言”的语言级联菜单。 在这个语言级联菜单中有“English”、“Portuguese”和“Spanish”三个命令。
每个命令执行一个 def,每个命令都有各自的参数。
def lang(l):
global lan
if l=="English":
if lan!='English':
janela.title('Notepad')
file.entryconfigure('Abrir', label='Open')
file.entryconfigure('Salvar', label='Save')
file.entryconfigure('Salvar como', label='Save as')
view.entryconfigure('Idioma', label='Language')
help.entryconfigure('Sobre...', label='About...')
if lan=='Português':
bar.entryconfigure('Arquivo', label='File')
bar.entryconfigure('Exibir', label='View')
bar.entryconfigure('Ajuda', label='Help')
file.entryconfigure('Novo', label='New')
file.entryconfigure('Abrir Recente', label='Open Recent')
file.entryconfigure('Sair', label='Quit')
view.entryconfigure('Mostrar nome do arquivo', label='Show file name')
if lan=='Español':
bar.entryconfigure('Archivo', label='File')
bar.entryconfigure('Vista', label='View')
bar.entryconfigure('Ayuda', label='Help')
file.entryconfigure('Nuevo', label='New')
file.entryconfigure('Abrir Reciente', label='Open Recent')
file.entryconfigure('Salir', label='Quit')
view.entryconfigure('Mostrar nombre de archivo', label='Show file name')
lan="English"
titleshow(s=False)
if l=="Português":
if lan!='Português':
janela.title('Bloco de Notas')
if lan=='English':
bar.entryconfigure('File', label='Arquivo')
bar.entryconfigure('View', label='Exibir')
bar.entryconfigure('Help', label='Ajuda')
file.entryconfigure('New', label='Novo')
file.entryconfigure('Open', label='Abrir')
file.entryconfigure('Open Recent', label='Abrir Recente')
file.entryconfigure('Save', label='Salvar')
file.entryconfigure('Save as', label='Salvar como')
file.entryconfigure('Quit', label='Sair')
view.entryconfigure('Language', label='Idioma')
help.entryconfigure('About...', label='Sobre...')
view.entryconfigure('Show file name', label='Mostrar nome do arquivo')
if lan=='Español':
bar.entryconfigure('Archivo', label='Arquivo')
bar.entryconfigure('Vista', label='Exibir')
bar.entryconfigure('Ayuda', label='Ajuda')
file.entryconfigure('Nuevo', label='Novo')
file.entryconfigure('Abrir Reciente', label='Abrir Recente')
file.entryconfigure('Salir', label='Sair')
view.entryconfigure('Mostrar nombre de archivo', label='Mostrar nome do arquivo')
lan="Português"
titleshow(s=False)
if l=="Español":
if lan!='Español':
janela.title('Bloc de Notas')
if lan=='English':
bar.entryconfigure('File', label='Archivo')
bar.entryconfigure('View', label='Vista')
bar.entryconfigure('Help', label='Ayuda')
file.entryconfigure('New', label='Nuevo')
file.entryconfigure('Open', label='Abrir')
file.entryconfigure('Open Recent', label='Abrir Reciente')
file.entryconfigure('Save', label='Salvar')
file.entryconfigure('Save as', label='Salvar como')
file.entryconfigure('Quit', label='Salir')
view.entryconfigure('Show file name', label='Mostrar nombre de archivo')
view.entryconfigure('Language', label='Idioma')
help.entryconfigure('About...', label='Sobre...')
if lan=='Português':
bar.entryconfigure('Arquivo', label='Archivo')
bar.entryconfigure('Exibir', label='Vista')
bar.entryconfigure('Ajuda', label='Ayuda')
file.entryconfigure('Novo', label='Nuevo')
file.entryconfigure('Abrir Recente', label='Abrir Reciente')
file.entryconfigure('Sair', label='Salir')
view.entryconfigure('Mostrar nome do arquivo', label='Mostrar nombre de archivo')
lan="Español"
titleshow(s=False)
所有条形菜单都已翻译,但菜单中的标签不翻译, 并且出现标题中的错误。
IMAGE - View Menu and Language Menu
搜索,看起来“_io.TextIOWrapper”是文件对象,但这些菜单不是文件对象!我做错了什么?
(请耐心、礼貌)
【问题讨论】:
-
请提供minimal reproducible example,而不是一些代码。
-
这对我们来说太多代码了。你可以用十几行代码复制你的问题。
-
哦,对不起,每个代码块都是一样的,但 entryconfigure 的字符串不同。
标签: python tkinter menu attributes