[Tutor] Python 3.7 Grids

boB Stepp robertvstepp at gmail.com
Sun Jun 30 00:35:55 EDT 2019


On Sat, Jun 29, 2019 at 2:02 AM David Merrick <merrickdav at gmail.com> wrote:
>
> Hi Looking for a way to use the determine the position of a card in a grid
> using the mouse click event in Python. Code is attached. There are no
> viruses.
>
> Unfortunately using Tinkter grids / frames can't determine between the two
> demo cards.

As Bob Gailer mentioned this is a text only list which does not allow
attachments, so I cannot see what you are actually attempting with
your code.  But with what you said, two thoughts come to my mind:

1) You can embed each card image on a button widget and if such a
button is clicked have the button's callback function respond
accordingly.

2) tkinter allows you to know the size of your window and can report
back what the cursor's current position is.  If you ensure that your
cards take up a known coordinate space in the window, when a mouse
click event happens you can write code to determine if the cursor fell
within either card's known coordinate space.

Hope this gives you some idea of how to tackle your problem.

-- 
boB


More information about the Tutor mailing list