2011-11-19 5 views
1

내가 오류를 받고 있어요 '버튼'개체가 어떤 속성 '설정을'이 없습니다.AttributeError는 Tkinter를

다음은 코드의 중요한 부분입니다 :

class Cell: 
    def show_word(self): 
      """ Shows the word behind the cell """ 
      if self.hidden == True: 
       self.hidden = False 
      else: 
       self.hidden = True 

      self.button.set(str(self)) 

class Memory(Frame): 
    def create_widgets(self): 
     """ Create widgets to display the Memory game """ 
     # instruction text 
     Label(self, 
       text = "- The Memory Game -", 
       font = ("Helvetica", 12, "bold"), 
      ).grid(row = 0, column = 0, columnspan = 7) 

     # buttons to show the words 
     column = 0 
     row = 1 
     the_pairs = self.readShuffle() 
     for index in range(36): 
      temp = Button(self, 
        text = the_pairs[index], 
        width = "7", 
        height = "2", 
        relief = GROOVE, 
        command = lambda x = index: Cell.show_word(the_pairs[x]) 
        ) 
      temp.grid(row = row, column = column, padx = 1, pady = 1) 
      column += 1 
      the_pairs[index].button = temp 
      if column == 6: 
       column = 0 
       row += 1 

답변

4

Button 년대는 더 set 속성이 없습니다. 만든

self.button["text"] = str(self) 

self.button.config(text=str(self)) 

사용 중 하나

+0

고맙습니다 그것을 :
의 Tkinter 위젯 속성은이 두 가지 다른 스타일로 설정되어 D – Amazon

관련 문제