0

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.

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by jrcagle
0

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=""):
        Frame.__init__(self,master)
        self.label = Label(self,text=text)
        self.button = Radiobutton(self,text='',variable=variable, value=value)
        self.variable = variable
        self.button.grid()
        self.label.grid()

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

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.

Jeff

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.