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.

What module do you use to get a radiobutton?

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.


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.