Tkinter Option (Radio) Buttons

Keith Murphy kpmurphy at my-deja.com
Mon Jul 10 14:54:03 EDT 2000


In article <Haoa5.50544$dF.2046832 at news1.rdc1.il.home.com>,
  "dsavitsk" <dsavitsk at e-coli.net> wrote:
> If i have 3 option buttons created like in Interface() below I am able
to
> use Value() to determine which button is selected,  Is there a bit of
code
> that i could add to Value() to disable certain buttons (i don't need
the
> if...elif's, just how to disable an option of my choosing.) or a
better way
> to do this.
>
> >>> def Value():
> ...    global CnType
> ...    print CnType.get()
>
> >>> def Interface():
> ...     CnType = IntVar()
> ...     CnType.set(0)
> ...     fm = Frame()
> ...     optTp = Radiobutton(fm5, text='Button 0', variable=CnType,
value=0)
> ...     optTp.grid(row=0, column=0, sticky=W)
> ...     optTp = Radiobutton(fm5, text='Button 1', variable=CnType,
value=1)
> ...     optTp.grid(row=0, column=1, sticky=W)
> ...     optTp = Radiobutton(fm5, text='Button 2', variable=CnType,
value=2)
> ...     optTp.grid(row=0, column=2, sticky=W)
> ...     fm5.pack(side=TOP)
>
> thanks
> doug
>
>

i know that the attribute 'state' can be NORMAL or DISABLED.  try giving
each item a unique name, and then use the following command:

button_1.apply(state=DISABLED)

hope this helps :)
-->keith


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list