I went through the topics here at stack overflow, but could not understand anything. (yes, I've seen that the answer has been answered, but really couldnt understand.)
So, here's the thing. I'm building small application that will pair couples from a group for a tournament we're having. I successfully built the algorithm that pair the players, and I've decided to make this a bit more approachable to everyone and started looking at ktinker.
I've managed to get my application to show something like this:
Title
info
info
info
info
info
Button
The button suppose to re-run the whole thing (next round) and it works. I've managed to get it with the appropriate title, and even added a new button at the end of the screen. the only problem I'm having is that I want to get rid of all the text above. destroy it and just draw on a new page.
Now, the code:
from tkinter import *
root = Tk()
root.title("Tournament")
root.geomerty("50x180")
app = Frame(root)
app.grid()
run_application() # my pairings
#inside the code i'm pairing the players and then:
for players in player_paired:
label=Label(app, text=players[0]+' vs. '+players[1] # its a tuple
label.grid()
button=Button(app,text="Next Round", command=run_application)
button.grid()
#end of run_application
root.mainloop()
So, I've tried adding to the beginning of my "run_application" the next rows:
app.destroy()
app = Frame(root)
app.grid()
and got "UnboundLocalError: local variable 'app' referenced before assignment"
Would anyone help? i can't figure this out. (If able to write example, it would help a lot)
Ofek.