2013-03-15 64 views
0

Baically我創建了一個簡單的數學遊戲增加,並使其顯示的問題是對還是錯,但我不能讓比分更新,也沒有人知道我怎樣才能得到這些問題刷新到另外一個問題,我想app.update:有誰知道如何有一個分數通過標籤

  self.a1button = Tkinter.Button(self, background="blue",foreground="white", text = (random_row.A1), command = self.QUESTION1) 
      self.a1button.grid(row = 9, column = 1, sticky = 'W') 

      self.label5 = Tkinter.Label(self, text = "Score:") 
      self.label5.grid(row = 14, column = 1, columnspan = 5, sticky = 'S') 

      self.label7 = Tkinter.Label(self, text = 0) 
      self.label7.grid(row = 14, column = 6, columnspan = 1, sticky = 'E') 

def QUESTION1(self): 

    if self.a1button['text'] == self.label6['text']: 
     tkMessageBox.showinfo("CORRECT", "WELL DONE") 
     label7 = +100 
     app.refresh 
    else: 
     tkMessageBox.showinfo("INCORRECT", "YOU FULLY GOT IT WRONG :/") 
     label7 = -100 
     app.refresh 

回答

2

您需要先讀標籤目前的成績,加上或減去100點,然後再次標籤:

score = int(self.label7.get()) 
score += 100 
self.label7.set(str(score)) 
app.refresh() 

請注意,您需要呼叫refresh方法,而不僅僅是引用它。

使用 - =減去。

相關問題