Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14389

tkinter: how to use after method

$
0
0

Hey I am new to python and am using tkinter for my gui. I am having trouble using the frame.after method.
The goal is to make a random letter appear every 5 seconds.

Here is my code:

import randomimport timefrom tkinter import *root = Tk()w = Label(root, text="GAME")w.pack()frame = Frame(root, width=300, height=300)frame.pack()L1 = Label(root, text="User Name")L1.pack(side=LEFT)E1 = Entry(root, bd =5)E1.pack(side=LEFT)tiles_letter = ['a', 'b', 'c', 'd', 'e']while len(tiles_letter) > 0:    rand = random.choice(tiles_letter)    tile_frame = Label(frame, text=rand)    tile_frame.pack()    frame.after(500)    tiles_letter.remove(rand)  # remove that tile from list of tilesroot.mainloop()

Can someone please help me?
The problem is definitely frame.after(500),I'm not sure if it is correct to use frame and I don't know what which argument follows the 500 parameter.

Thanks


Viewing all articles
Browse latest Browse all 14389

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>