Re: [Tutor] Python 3.7 Grids

2019-06-29 Thread boB Stepp
On Sat, Jun 29, 2019 at 2:02 AM David Merrick  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
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Python 3.7 Grids

2019-06-29 Thread Bob Gailer
On Jun 29, 2019 3:01 AM, "David Merrick"  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.

Unfortunately this list does not forward attachments. Either give us a link
to the code or even better if it's not terribly complicated paste it into
the reply. be sure to reply all so everyone on the tutor list will see your
reply.

> There are no viruses.

That's kind of like a Salesman saying "trust me".

Bob Gailer
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Python 3.7 Grids

2019-06-29 Thread David Merrick
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.

Any suggestions are welcome

-- 
Dave Merrick

TutorInvercargill

http://tutorinvercargill.co.nz

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email merrick...@gmail.com

Ph   03 216 2053

Cell 027 3089 169
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Python 3.7 Grids

2019-06-29 Thread David Merrick
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.

Unfortunately using Tinkter grids / frames can't determine between the two
demo cards.

The Relevant code is below

def showCardInitial(cardList):
cardsToPlay = []
length = len(cardList)

fileFaceDown = 'extracards/FACEDOWN.gif'
cardFaceDownCard = fileFaceDown.split('/')
cardFaceDownCard = cardFaceDownCard[1].split('.')[0]
photo = PhotoImage(file=fileFaceDown)
number = random.randrange(0,length)
fileFaceUp = cardList[number][2]
card = fileFaceUp.split('/')
card = card[1].split('.')[0]
w = Label(image=photo)
w.photo = photo
w.grid(row = 0,column = 0,padx = 10)

#print('cardListis ',cardList)

cardFile = cardList[1][2]
#print cardFile
photo = PhotoImage(file=cardFile)
cardToDisplay = Label(image=photo)
cardToDisplay.photo = photo
cardToDisplay.grid(row=0,column = 1,padx = 10)
#w.grid(row = row,column = count)
return

def determineCard():
global x
global y
print( "clicked at", x, y)
if(2 <= x and x <= 83) and (0 <= y and y <= 130):
print('Card One is Selected')
return

Any suggestions are welcome

-- 
Dave Merrick

TutorInvercargill

http://tutorinvercargill.co.nz

Daves Web Designs

Website http://www.daveswebdesigns.co.nz

Email merrick...@gmail.com

Ph   03 216 2053

Cell 027 3089 169
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor