1

I am using Python Tkinter library to build my UI, and my question is as follow:

I want to display windows 8 touch keyboard when an entry is clicked. Currently the only way to type in the entry is to either use a physical keyboard, or have a built-in keyboard.

For example, I have the following:

addressInput = tk.Entry(self, font = "Verdana 20 ", justify="center")

Do i need to add a command to would force the keyboard to popup? If so, how would this work.

Any help would be greatly appreciated.

jon220
  • 131
  • 1
  • 4
  • 10
  • [This question](http://stackoverflow.com/questions/9988855/how-to-access-windows-on-screen-keyboard-accessory-through-python) shows how to open the on-screen keyboard. Additionally you should think about to bind a function the the `focus in` event of the Entry widget in order to call a function which then opens the on-screen keyboard. – albert Nov 27 '15 at 16:55

3 Answers3

1

Since I am working on a Mac I can not provide a complete sample on how to open the on-screen keyboard. This question should tell you how to do this.

However, the solution should be a FocusIn event binding to the Entry widget which is called if the given event was raised:

from tkinter import *

root = Tk()

def callback(event):
    # TODO: Open keyboard here and remove print statement
    print("focus in event raised, open keyboard")

frame = Frame(root, width=100, height=100)
frame.pack()

addressInput = Entry(frame, font = "Verdana 20 ", justify="center")
addressInput.bind("<FocusIn>", callback)
addressInput.pack()

root.mainloop()

Some general information about bindings and events can be found here.

Community
  • 1
  • 1
albert
  • 8,027
  • 10
  • 48
  • 84
  • thank you for your solution, and for the addition to the link. I do have two concerns 1) It would be nice if the keyboard exists once the entry has lost its focus 2) It triggers the operating system keyboard as a seperate window, and not as a top level popup within the app. This is because the app is run in full screen mode, and when the keyboard is triggered while the app is still in display the bottom windows start menu is shown since its focus is now on the keyboard as a seperate window which is not full screen – jon220 Nov 27 '15 at 17:55
  • Since I do not have a Windows machine, I am not able to test this more detailed. Sorry for this... – albert Nov 29 '15 at 12:53
1

Adding to above answer, this worked fine for me. Make sure, onboard is installed in your system.

import subprocess

def callback(event):
    pop = subprocess.Popen("exec " + "onboard", stdout= subprocess.PIPE, shell=True)
Shweta Chandel
  • 887
  • 7
  • 17
0

import subprocess subprocess.Popen("osk", stdout= subprocess.PIPE, shell=True)
will do the trick on windows 10

Gaurav
  • 41
  • 6