I made a character randomizer in tkinter that takes the user entry, then feeds it through random.shuffle with a button, then prints it on a LabelFrame, also saving it to a text file. I don't know where/how I would insert code to remove the spaces, commas and brackets. I've searched other questions but to no avail, I can't seem to implement other answers to my specific problem.
Here is some example code, thanks a bunch! I didn't want to flood the screen with all the code, this is my first post here, but if more is needed then I could just copy-paste it all.
e = Entry(root, bd=3, bg='white')
e.pack(fill=X, pady=3, padx=3)
def get_answer():
answer = list((e.get()))
global widget
widget = LabelFrame(frame2, text='Please
click Randomize', bd=0, width=500,
height=300, bg='white', font=150)
widget.pack(padx=3)
file_create = open('text.txt', 'w+',
encoding='utf-8')
for i in range(1):
random.shuffle(answer)
file_create.write(str(answer))
file_create.close()
button.config(state=tk.DISABLED)
def file_opener():
global m
widget.destroy()
f = open('text.txt', 'r', encoding='utf-8')
m = LabelFrame(frame2, width=500,
height=300, bd=0, bg='white', font=150,
text=f.read())
m.pack(expand=TRUE)
f.close()
button_3.config(state=tk.DISABLED)
Aucun commentaire:
Enregistrer un commentaire