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

Reply via email to