How to change the attributes for all objects inside a list in python(3)?


I am new to python and unfamiliar with manipulating python lists. I have a list of tkinter widgets, more specifically buttons, which have been added to my list btnList by using:



Normally to change an object's attribute value (the state attribute for example) one would use:



which would set the state attribute of both buttons to disabled,

Is there a way to change attributes for all of the objects contained in the list? for example setting the state of each button to disabled?


Simply loop over your list:

for button in btnList: button.configure(state='disabled')

button will be assigned each button from your list in turn letting you call the configure() method on it.


There are a fair number of ways to express this, including some one-liners, but I think a simple for loop is the cleanest:

for button in btnList: button.configure(state='disabled')


  • Custom AlertDialog not showing
  • How do I keep a wx.html.HtmlWindow at the same position during resize (without flicker)?
  • CS3 Flash - Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found
  • How to consume ajax returned json data in DataTables and have a form in each row
  • Shorting long if statement
  • Capture image from webcam and save in folder using PHP and JavaScript
  • Prevent CSS Hover Transition on mouseup
  • repeating animation with Timer
  • Set User Control's default event
  • How to check if DIV element is disabled using jquery
  • Yii2: Using Kartik Depdrop Widget?
  • CoreData basics – to-many relationship array data
  • Client side validation mvc dropdown
  • How can I reset dropdown data if modal closed on vue component?
  • Should a web service response include empty values?
  • Pass array from parent template to child template
  • Jquery Mobile pageLoading() Method how does it work?
  • How to make R's read_csv2() recognise the text characters properly
  • How to getText() from the input field of an angularjs Application
  • Combining two different ActiveRecord collections into one
  • How do I configure context broker accept post requests from my remote sensor?
  • Implementation of State Monad
  • Automatically associate new Sonar project with custom quality profile and quality gate
  • wxPython: displaying multiple widgets in same frame
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • WPF - CanExecute dosn't fire when raising Commands from a UserControl
  • How do I pass the string value parameter of the selected list item from an auto-populated dropdown l
  • HTML download movie download link
  • swift auto completion not working in Xcode6-Beta
  • Calling of Constructors in a Java
  • Traverse Array and Display in markup
  • Transpose CSV data with awk (pivot transformation)
  • How to delete a row from a dynamic generate table using jquery?
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • How do I configure my settings file to work with unit tests?
  • Is it possible to post an object from jquery to bottle.py?
  • Is there any way to bind data to data.frame by some index?
  • How to get NHibernate ISession to cache entity not retrieved by primary key