2011-08-09 26 views
1

我添加了一個按鈕:如何禁用Pmw.ButtonBox中的特定按鈕?

def addButtons(self): 
    self.buttonBox = Pmw.ButtonBox(self.dataFrame, 
      labelpos = 'nw', 
      label_text = '', 
      frame_borderwidth = 1, 
      frame_relief = 'groove') 
    self.buttonBox.pack() 
    self.buttonBox.place(relx=.75, rely=.750, anchor=W) 

    # Add some buttons to the ButtonBox. 
    self.buttonBox.add('Login', command = self.login) 

    # Set the default button (the one executed when <Return> is hit). 
    self.buttonBox.setdefault('Login') 
    self.dataFrame.bind('<Return>', self._processReturnKey) 
    self.dataFrame.focus_set() 

現在,我想禁用登錄按鈕,當用戶按下它。我怎樣才能做到這一點?我找到了簡單按鈕的答案,但是此按鈕位於按鈕框中。

回答

2

根據pmw.ButtonBox documentationadd方法返回對創建按鈕的引用。所以,只需保存它返回的引用,然後像配置其他任何按鈕一樣配置該按鈕即可。