+ 1

If i click on a button example" 1" and i want the result to be showed in the entry box/part of python tkinter . I need an eg

Python tkinter doubt i click on a button and i want the result to be showed on the entry box ex. if i click '1' and want 1 typed in the entry box. plz help me out with a function or a small code

20th Dec 2017, 2:43 PM
Abhishek 305
Abhishek 305 - avatar
4 Answers
+ 1
yes if i click button in a calculator 1 i want 1 typed in the entry
20th Dec 2017, 3:43 PM
Abhishek 305
Abhishek 305 - avatar
+ 1
thnx man šŸ‘
20th Dec 2017, 4:01 PM
Abhishek 305
Abhishek 305 - avatar
0
Do you want the button "writes" in some entry box?
20th Dec 2017, 3:41 PM
SebastiƔn Zapata
SebastiƔn Zapata - avatar
0
Entry widgets have a method called insert and remove. I don't know if they have more parameters but you pass two: position and a string. I don't have access to a Python to test before, but here is an example. # Python 2.7 , some things could change from Tkinter import * tk = Tk() E = Entry(tk) B = Button(tk, text="Example", command=lambda: E.insert("end", "some text)) E.pack(); B.pack() I read some people use "end" as the index, it could work (other option can be pass 1000) and why lambda? Because without it, the function is called the first time you run the program. If something not works I apologize, it would take me a time to get a pc with python :)
20th Dec 2017, 3:58 PM
SebastiƔn Zapata
SebastiƔn Zapata - avatar