Задать вопрос
@greinerIva

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

commslist = ['mint**', 'take#s%', 'take#n%', 'equals', 'plus', 'minus', 'multiply', 'divide', 'times$do%']
laung = ''

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


takenew = 1
comms = []

def newtake(event):
global strscode, stringsare, windo, newenter, takenew
if strscode == 1:
comms.append(newenter)
newenter = Entry(windo, width=128)
newenter.grid(column=1, row=stringsare+1)
comms.append(newenter)
stringsare += 1
strscode += 1
newenter.bind('', newtake)
return stringsare, strscode

windo = Tk()
windo.title('Macinton 1')
windo.geometry('2048x1024')

help = Button(windo, text='Open helper', command=open_helper)
help.grid(column=10, row=1)

run = Button(windo, text='RUN', command=run_code)
run.grid(column=11, row=1)

add_hotkey('ctrl + h', open_helper, args=())
add_hotkey('ctrl + s', save_file, args=())
add_hotkey('ctrl + o', open_file, args=())
add_hotkey('shift + c', change_laung, args=())

newenter = Entry(windo, width=128)
newenter.grid(column=1, row=stringsare)
newenter.bind("", newtake)
windo.mainloop()
  • Вопрос задан
  • 39 просмотров
Подписаться 1 Средний 3 комментария
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы