tk/tkinter radiobutton in grid bug?

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Fri Jul 12 12:28:02 EDT 2002


On Friday 12 Jul 2002 3:11 pm, Edward K. Ream wrote:
> Hi,
>
> If b is a radiobutton, b.select() (b -select) does not work when b is
> embedded in a grid, and works just fine when packed.  In either case,
> the radio buttons work, but in the grid case the proper button is not
> initially selected.  None of the various alternatives to b.select work
> either.
>
> Is this a known bug?  I have a dim memory of this being discussed
> somewhere...Does anyone know a workaround that still uses grids (I'd
> like to embed the radiobuttons in a labeled frame, and grids are the
> only way I know to do that.)
>
Edward,

This _seems_ to work do you have an example that does not?


import Tkinter
root=Tkinter.Tk()
variable=Tkinter.StringVar()
l=Tkinter.Label(root, text='On or Off?').grid(row=0, col=0)
rb1=Tkinter. Radiobutton(root, variable=variable, value='On', text='On')
rb1.grid(row=0, col=1)
rb2=Tkinter. Radiobutton(root, variable=variable, value='Off', text='Off')
rb2.grid(row=0, col=2)
rb2.select()

root.mainloop()

Regards
Martin







More information about the Python-list mailing list