[Tutor] Disabling a frame in Tkinter

John Fouhy john at fouhy.net
Fri Jan 6 00:03:18 CET 2006

On 06/01/06, Hans Dushanthakumar <Hans.Dushanthakumar at navman.com> wrote:
> Hi,
>    Is there any way to disable an entire frame (and all its included
> widgets) in Tkinter. It does not seem to support state=DISABLED.

Not that I'm aware of...  You could try maybe something like this (untested):

def setState(widget, state=DISABLED):
  except TclError:   # not sure what exception will be raised
  for child in widget.children:
    setState(child, state=state)

> Another Tkinter question: In a listbox, how do I intially set a
> "selected" item? What I want to do here is have the 1st item in a
> listbox selected (ie highlighted) when the appln is run.

Have a look at Fredrik Lundh's Introduction to Tkinter.  You can use
.selection_clear() to clear the selection and .selection_set(index) to
select an item. So, .selection_set(0) will select the first item (just
make sure the listbox isn't empty).


More information about the Tutor mailing list