Builtins.AttributeError: 'str' object has no attribute 'tk' Не понимаю что за ошибка. Как мне исправить её(код ниже)?
from tkinter import *
from tkinter.filedialog import asksaveasfile
from keyboard import add_hotkey
from tkinter import filedialog as fd
from tkinter import messagebox
def chngl(laungnew):
global laung
laung = laungnew
def change_laung():
global laung
chglaung = Tk()
chglaung.title('Laungage')
chglaung.geometry('330x990')
rus = PhotoImage(file='Languages images\Rulang.png')
rusim = rus.subsample(330, 330)
ing = PhotoImage(file='Languages images\inglang.png')
ingim = ing.subsample(330, 330)
ger = PhotoImage(file='Languages images\gerlaung.png')
gerim = ger.subsample(330, 330)
ru = Button('Русский', image=rus, command= lambda: chglaung.destroy() and chngl('rus'))
ingl = Button('English', image=ing, command= lambda: chglaung.destroy() and chngl('eng'))
dutch = Button('Deutsh', image=ger, command= lambda: chglaung.destroy() and chngl('ger'))
laungs = [ru, ingl, dutch]
col = 330
for lame in laungs:
lame.grid(column=col-229, row=1)
col += 330
chglaung.mainloop()
def save_file():
with asksaveasfile(initialfile = 'Project.Macinton', defaultextension=".macinton0",filetypes=[("All Files","*.*"),("Macinton","*Macinton Classic*")]) as f:
for entry in comms:
f.write(entry.get()+'\n')
def open_helper():
messagebox.showinfo(title='Helper', message='ctrl + s: save file \nctrl + o: open file(open only in studio!) \nctrl + h: open helper \nctrl + r: run code \nMacinton 1 \nshift + c: change laungage')
def run_code():
takelist = []
for comlist in comms:
takelist.append(comlist.get())
strscode = 1
stringsare = 1
opened = 0
def open_file():
global opened, strscode, stringsare
opened = 1
with fd.askopenfile(mode='r') as reader:
global commas
commas = reader.readlines()
commasw = 1
for commasnames in commas:
newenter = Entry(windo, width=128)
newenter.grid(column=1, row=commasw)
newenter.insert(0, commasnames.strip())
newenter.bind('', newtake)
commasw += 1
strscode = commasw
stringsare = strscode
return opened, strscode, stringsare
Фрагменты кода надо размещать в виде текста и оборачивать тэгом code для корректного отображения. Удобно делать кнопкой </> Это обязательно, см.п.3.8 Регламента.
Сюда же относится traceback, ввод и вывод в консоли и другая структурированная текстовая инфа.