Ошибка в Tkinter
from tkinter import *
from tkinter import messagebox
root = Tk()
root.resizable(width = False, height = False)
root.geometry('300x250')
root.title('Test')
root.wm_attributes('-alpha', 0.9)
root['bg'] = '#ccc'
root.iconbitmap('D:/programming/Python/shorter.ico')
def conn():
UT = user_text.get()
field.insert(0.0, f'{UT}\n')
_test = Label(
text = '',
font = 'Comfortaa 20',
fg = '#3d3d42',
bg = '#878787',
)
_text = Label(
text = '',
font = 'Comfortaa 16',
fg = '#3d3d42',
bg = '#ccc',
)
_input = Entry(root,
font = 'Consolas 15',
fg = '#eff5c9',
bg = '#48494f',
relief = 'solid',
justify = 'center',
)
enter = Button(
text = 'ввод',
font = 'Consolas 12',
fg = '#eff5c9',
bg = '#48494f',
relief = 'solid',
command = conn,
)
global field
field = Text(root,
width = 25,
height = 10,
command = conn,
)
_test.pack()
_text.pack()
_input.pack()
enter.pack(pady = 3)
field.pack(pady = 3)
enter.bind('<Button-1>', conn)
root.mainloop()
Я хочу сделать так, чтобы текст, который я ввожу, при нажатии на кпопку, выводился в поле ниже, но при запуске кода мне выдает такую ошибку:
File "D:\programming\Python\shorter.py", line 69, in <module>
field = Text(root,
File "C:\Users\dimas\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 3559, in __init__
Widget.__init__(self, master, 'text', cnf, kw)
File "C:\Users\dimas\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 2572, in __init__
self.tk.call(
_tkinter.TclError: unknown option "-command"
Ответы (1 шт):
Автор решения: GrAnd
→ Ссылка
Вообще-то из текста ошибки можно сделать вывод, что в строке field = Text(root,... (т.е. вот в этом месте):
field = Text(root,
width = 25,
height = 10,
command = conn,
)
у виджета Text нет такого параметра как command, который вы ему зачем-то передаёте.