Python 3.7.1 // Tk version 8.6 // pywinauto-0.6.8 // PyCharm Community Edition 2020.1 x64
The objective is to have the button send keys to the window in the background. Issue appears due to the presence of pywinauto. If inactive:
from tkinter import *
# from pywinauto.keyboard import send_keys
def left_click(event):
# send_keys('%{TAB}')
# send_keys('{{}ENTER{}}')
print("hello")
root = Tk()
label1 = Label(root, text="Other")
label1.grid(row=0, sticky=E)
bt1_label1 = Button(root, text="Button_1", bg="red")
bt1_label1.grid(row=0, column=1)
bt1_label1.bind("<Button-1>", left_click)
root.mainloop()
Return when manually closing the tkinter window is:
hello
Process finished with exit code 0
If pywinauto is active (uncommented):
from tkinter import *
from pywinauto.keyboard import send_keys
def left_click(event):
# send_keys('%{TAB}')
# send_keys('{{}ENTER{}}')
print("hello")
root = Tk()
label1 = Label(root, text="Other")
label1.grid(row=0, sticky=E)
bt1_label1 = Button(root, text="Button_1", bg="red")
bt1_label1.grid(row=0, column=1)
bt1_label1.bind("<Button-1>", left_click)
root.mainloop()
Return when manually closing the tkinter window is:
hello
Process finished with exit code -1073740771 (0xC000041D)
Any ideas why this happens?
User contributions licensed under CC BY-SA 3.0