So the score submitting system works like these:
1.game is finished
2.press s to submit score
3.tkinter inputbox pops up
4.enter your name and click submit
5.input is processed and displayed on screen
I do not have any problem with score submitting system itself but sometimes when tkinter pops up within pygame window mouse becomes frozen and only way to submit score is alt+esc but I can't expect user to do that.Sure I could set pygame window position at beginning and then set tkinter window position somewhere else but what if user moves window?
if event.key==pygame.K_s:
subbox=Tkinter.Tk()
subbox.geometry("+0+0")
subbox_label=Tkinter.Label(subbox,text="Type your name:")
subbox_label.pack()
subbox_entry=Tkinter.Entry(subbox)
subbox_entry.pack()
def savescore(player_score):
player_score=str(player_score)
print player_score
print subbox_entry.get()
player_name=subbox_entry.get()
namefile=open("name.txt","a")
namefile.write(player_name)
namefile.write("\n")
scorefile=open("score.txt","a")
scorefile.write(player_score)
scorefile.write("\n")
subbox.destroy()
namefile.close()
scorefile.close()
display_leaderboard()#this is function that sorts names and score and displays leaderboard
subbox_button=Tkinter.Button(text="Click",command=lambda:savescore(score))
subbox_button.pack()
subbox.mainloop()

New Topic/Question
Reply


MultiQuote



|