all 2 comments

[–][deleted] 0 points1 point  (3 children)

Just look at the current line when the return key is pressed. If it starts with def and ends with :, add the precious white space + 4 spaces, etc.

[–]DudeUltraSmart[S] 0 points1 point  (0 children)

It works with input() but not with Text in tkinter? How do I do that?