I was wondering if i could output something that the windows narrator can use to narrate my tkiner application.
import tkinter as tk
# create root window
root = tk.Tk()
root.title("Test")
lbl = tk.Label(root, text = "A label")
lbl.grid()
root.mainloop()
Taking this as a example, lets say a mouse is hovering over the label, the narraor will read, "A label".
There are methods for doing optical text recognition through pip libraries, but I was wondering if I could do ocr without downloading modules, and through the use of windows narrator.
You can use the
pywin32package, with SAPI SpVoice.I have bound the
<Enter>attribute to speak whenever you hover over the label. You could of course use different triggers if you so desire.If you want to generalise this solution such that all your labels are narrated, you could subclass the
tk.Label, like so