Anglais
I would like to calculate by retrieving data in a textbox but it gives me an error:
Traceback (most recent call last):
File "C:/Users/#####/Desktop/Python/Calculateur_U_R_I/App_main.py", line 43, in <module>
exe_button = Button(height=1, width=20, text='Exécuter', command=Calc())
File "C:/Users/#####/Desktop/Python/Calculateur_U_R_I/App_main.py", line 15, in Calc
result = text_label_1.get * text_label_2
TypeError: unsupported operand type(s) for *: 'method' and 'Text'
Process finished with exit code 1
And the code is :
import tkinter
from tkinter import *
from tkinter import Text
help(tkinter.Text.get)
window = Tk()
window.minsize(1200, 400)
def Calc():
result = text_label_1.get * text_label_2
print(str(result))
text_label_1: Text = Text(window, height=1, width=10)
text_label_1.grid(row=0, column=2)
text_label_2 = Text(window, height=1, width=10)
text_label_2.grid(row=0, column=4)
name_label_1 = Label(window, height=1, width=10, text='Tension')
name_label_1.grid(row=0, column=0)
name_label_2 = Label(window, height=1, width=10, text=' = ')
name_label_2.grid(row=0, column=1)
name_label_3 = Label(window, height=1, width=10, text=' * ')
name_label_3.grid(row=0, column=3)
name_label_4 = Label(window, height=1, width=10, text=' = ')
name_label_4.grid(row=0, column=5)
name_label_5 = Label(window, height=1, width=10)
name_label_5.grid(row=0, column=6)
exe_button = Button(height=1, width=20, text='Exécuter', command=Calc())
exe_button.grid(row=1, column=5)
window.mainloop()
Ok but what is the index1 ?
Traceback (most recent call last):
File "C:/Users/#####/Desktop/Python/Calculateur_U_R_I/App_main.py", line 47, in <module>
exe_button = Button(height=1, width=20, text='Exécuter', command=Calc())
File "C:/Users/#####/Desktop/Python/Calculateur_U_R_I/App_main.py", line 17, in Calc
r = int(text_label_1.get())
TypeError: get() missing 1 required positional argument: 'index1'