Browse Source

Schreiben des Inhalts der Highscore-Textdatei in das Highscore-Fenster in Tkinter

Kristin 7 years ago
parent
commit
95b5ecea1f
1 changed files with 14 additions and 0 deletions
  1. 14 0
      pingpong.py

+ 14 - 0
pingpong.py

@@ -124,6 +124,8 @@ neustart_button = Button(tk, text="Neues Spiel", command=restart_program)
124 124
 neustart_button.pack()
125 125
 start_button = Button(tk, text="Spiel starten", command=tk.quit)
126 126
 start_button.pack()
127
+#   Button(master, text='Liste', command=oeffnen).grid(row=3, column=3, sticky=W, pady=4)
128
+
127 129
 exit_button = Button(tk, text='Spiel beenden', command=tk.destroy)
128 130
 exit_button.pack()
129 131
 
@@ -155,8 +157,20 @@ def anzeige():
155 157
       master.title("Highscore-Liste")
156 158
       canvas = Canvas(master, width=200, height=400, bd=2, bg='white')
157 159
       canvas.pack()
160
+
161
+      blub = "Name                    Punkte" 
162
+      lese = open("highscore.txt", "r")                       #textdatei oeffnen
163
+      ausgeben = lese.read()                                  #textdatei lesen
164
+      lese.close()
165
+
166
+      label = canvas.create_text(5, 5, anchor=NW, text=blub)
167
+      tk.update()
168
+      label = canvas.create_text(5, 5, anchor=NW, text=ausgeben)
169
+
170
+
158 171
       mainloop()
159 172
 
173
+
160 174
    master = Tk()
161 175
    master.title("Namen eingeben")
162 176
    e1 = Entry(master)