I have the function:
StoreItems = random.sample(set(['sword','pickaxe','toothpick','hammer','torch','saw']), 5)
#Selects 5 Random strings from the list. ^
XBASE, YBASE, DISTANCE = 300, 320, 50
for i, word in enumerate(StoreItems):
canvas.create_text(
(XBASE, YBASE + i * DISTANCE),
text=word, activefill="Medium Turquoise", anchor=W, fill="White", font=('Anarchistic',40), tags=word)
canvas.tag_bind('sword', '<ButtonPress-1>', BuySword)
canvas.tag_bind('pickaxe', '<ButtonPress-1>', BuyPick)
canvas.tag_bind('toothpick', '<ButtonPress-1>', BuyTooth)
canvas.tag_bind('hammer', '<ButtonPress-1>', BuyHammer)
canvas.tag_bind('torch', '<ButtonPress-1>', BuyTorch)
canvas.tag_bind('saw', '<ButtonPress-1>', BuySaw)
Which randomly selects from the list: StoreItems[] and puts 5 of them on my canvas in a random order. If I wanted my tag binds to create text next to them how would I do that?
I have the event functions:
def BuySword(event):
if 'sword' in StoreItems:
sword = canvas.create_text((420,350), text="test", fill="White", font=('Anarchistic',40))
But I want the location of this created text to follow the random placement of the corresponding word from my list.