Showing posts with label sensible. Show all posts
Showing posts with label sensible. Show all posts

Tuesday, July 14, 2009

Make widgets Enable and/or Disable in pygtk

Many a times while you are working pygtk, You would like to make some widgets like buttons, checkboxes etc etc.. to be disabled for a action to complete, And again would like to enable it, after the action is complete. This simple function is all you would need to accomplish this.


def make_sensitive(state, widget_list):
   """
   Enables/disables widgets
   state: either True or False, True to Enable, False to Disable
   widget_list: A list of widgets that you want to enable or disable collectively.
   """
   s = state and 1 or 0
   for w in widget_list:
      w.set_sensitive(s)