samedi 5 septembre 2020

im a beginner in python and i want to make an absent number teammate randomizer program with tkinter

import random

from tkinter import *

win = Tk()
win.geometry("700x600")
win.title("pengocok keberuntungan")

isi = Entry(win,width=25,font =("arial",25))
isi.pack()

isi2 = Text(win,width=56,height=25,font=("arial",10))
isi2.pack()

mylist = (list(range(1,35)))
b =  random.sample(mylist,34)
print (b)

def acak():
    for i in b:
        pass

        isi.delete(0,END)
        isi.insert(END,i)
        isi2.insert(END,isi.get()+"\n")


acak_tombol = Button (win,text = "di acak",command =acak)
acak_tombol.pack(pady=20)

win.mainloop()

My problem is when I click the button it already randomize all my 34 friends instantly. What I want is that every time I click the "acak" button, 1 of my randomized classmates gets inserted into the textbox and can't be doubled until all my 34 friends get their teammate. By the way, how do I link that absent number with my 34 classmates? So what will pop up when the "acak" button is pressed is my friend's name and absent number is inserted into the text box one by one, not instantly like my problem.




Aucun commentaire:

Enregistrer un commentaire