Skip to content
Advertisement

How to get the coordinate of a checkbox created by tkinter package on a screen

I created a graphical user interface that has 3 checkboxes by using the Checkbox class given in tkinter package. I want to retrieve the screen coordinate of each checkbox. I have been trying to use pyautogui.position() to retrieve the coordianates. However, those values seem wrong because when I used those coordinates for the pyautogui engine to click on the box, it did not click. Also it seems that the window contained the checkboxes does not let me to check the boxes, when I was debugging it. What would be other possible ways that I can fix these problems?

JavaScript

Advertisement

Answer

Here is a quick example of how to get the coordinates and click the checkbutton (simply use .winfo_rootx() and .winfo_rooty()):

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement