Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert something at the end of a entry in tkinter?

def inserter(entryblock, num):
    entryblock.insert(-1, num)

I am making a calculator and whenever I click the number buttons on the calculator, it always inserts them at the beginning but I want to insert them to the end of the entry. How do I insert them at the right instead of the left?

like image 903
Crystallean Avatar asked Dec 21 '25 08:12

Crystallean


1 Answers

The first argument to insert is the index at which to insert the text. Most often this is the index 0 (zero) to represent the beginning of the entry widget. The entry widget also supports the string literal "end" which represents the index immediately after the last character.

entryblock.insert("end", num)

For the canonical description of all supported indexes, see the section titled Indices in the tcl/tk man page for the Entry widget.

like image 114
Bryan Oakley Avatar answered Dec 22 '25 20:12

Bryan Oakley



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!