I want to have radiobuttons with text that is displayed underneath the actual buttons. Is there a way to do this (within the contents of the Radiobutton widget, that is, not resorting to labels)?

I know this question is ridiculously simple, but I haven't been able to find anything in the documentation about it, and none of the options seem to relate to the placement of the text.

I haven't been able to find a way to do that in Tkinter yet. Lemme know if you find a solution.

Of course, you could create your own class. Here's a cheesy little attempt:

from Tkinter import *

class ComboButton(Frame):

    def __init__(self, master,text='',variable=None, value=""):
        self.label = Label(self,text=text)
        self.button = Radiobutton(self,text='',variable=variable, value=value)
        self.variable = variable

mainw = Tk()
v = StringVar()
mainw.f = ComboButton(mainw,"Option 1", value="Option 1",variable=v)

This class has the added bonus that the control variable is *gasp* part of the radiobutton object! Who could have thought of such an innovation?!?! </sarcasm>

(answer: one of my students, who was disgusted that he had to use dictionaries to keep track of the control variables for radiobutton and checkbutton widgets).

Anyways, this is just a sketch ... a real implementation would allow the user to pass all of the relevant properties for the radiobutton and the label.


This article has been dead for over six months. Start a new discussion instead.