Python '_io.TextIOWrapper';对象没有属性';entryconfigure';
我有一个记事本。 所以在记事本中有一个叫做“bar”的条。 在此栏中有一个名为“视图”的视图级联菜单。 此视图菜单中有一个称为“语言”的语言级联菜单。 在该语言级联菜单中,有3个用于“英语”、“葡萄牙语”和“西班牙语”的命令 每个命令执行一个def,每个def都有各自的参数Python '_io.TextIOWrapper';对象没有属性';entryconfigure';,python,tkinter,menu,attributes,Python,Tkinter,Menu,Attributes,我有一个记事本。 所以在记事本中有一个叫做“bar”的条。 在此栏中有一个名为“视图”的视图级联菜单。 此视图菜单中有一个称为“语言”的语言级联菜单。 在该语言级联菜单中,有3个用于“英语”、“葡萄牙语”和“西班牙语”的命令 每个命令执行一个def,每个def都有各自的参数 def lang(l): global lan if l=="English": if lan!='English': janela.title('Notepad')
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)
所有的酒吧菜单都会被翻译,但菜单中的标签不会被翻译,
标题中出现错误
搜索,看起来像是文件的对象,但这些菜单不是文件对象!我做错了什么
(请耐心和礼貌)哦,对不起,伙计们,每个代码块都是相同的,但是entryconfigure的字符串不同 首先,从这一点开始:
if l=="English":[...]
if l=="Português":[...]
if l=="Español":[...]
在这些代码中,有这样一个:
if lan!='Português':
janela.title('Bloco de Notas')
在这里,我设置了一个条件,在记事本没有可供选择的代码时执行所有这段代码
(例如,当记事本使用英语,并且您选择再次更改为英语时,将执行代码NOT NOT)
我还翻译了记事本的标题
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=='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')
如果当前语言是其他语言之一,则会执行大量“.entryconfigures”以将当前文本更改为新文本(如果您知道更好、更有效的方法,请告诉我)
每段代码有两个,最后更改语言的全局变量。(这些titleshow函数只是我创建的一个函数,用于管理标题中的文件名)
查看一段代码的更好视图:
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)
但是,条形菜单中的层叠菜单不起作用…请提供一个与某些代码相对应的示例。对于我们来说,这些代码太多了。你可以用十几行代码来重复你的问题。哦,对不起,伙计们,好吧,每个代码块都是相同的,但是entryconfigure的字符串不同。
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)