07-28-2025, 03:36 AM
I've tried using QM or LA to control a Tkinter GUI button via UI automation in Python, but it always fails. Has anyone successfully used UI automation to interact with Tkinter GUIs this way?
python code:
import tkinter as tk
def on_click():
label.config(text="test ok!")
root = tk.Tk()
root.title("MyTkWindow")
root.geometry("300x200")
entry = tk.Entry(root, name="myentry")
entry.pack(pady=10)
btn = tk.Button(root, text="Button", name="mybutton", command=on_click)
btn.pack(pady=10)
label = tk.Label(root, text="", name="mylabel")
label.pack(pady=10)
root.mainloop()
python code:
import tkinter as tk
def on_click():
label.config(text="test ok!")
root = tk.Tk()
root.title("MyTkWindow")
root.geometry("300x200")
entry = tk.Entry(root, name="myentry")
entry.pack(pady=10)
btn = tk.Button(root, text="Button", name="mybutton", command=on_click)
btn.pack(pady=10)
label = tk.Label(root, text="", name="mylabel")
label.pack(pady=10)
root.mainloop()
