Question

I am using Tkinter to create an application which requires a 0-9 numerical keypad to be built in to the UI. I plan to do this with 10 button widgets which enter the relevant number(s) into the currently selected Entry widget. I do not want to use one of the pre-made on-screen keyboards (e.g. Matchbox-keyboard) that are available, it needs to be bespoke to the application. So essentially - how do I simulate key-press events using on-screen buttons to enter values into entry fields without taking the focus off the entry field?

Was it helpful?

Solution

You don't need to simulate keypresses if all you want to do is insert the numbers into the entry widget. Just have the buttons directly insert their value into the entry widget with the entry widget insert method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top