| | |
Radiobutton text placement
![]() |
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 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.
•
•
Join Date: Jul 2006
Posts: 608
Reputation:
Solved Threads: 150
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:
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
Of course, you could create your own class. Here's a cheesy little attempt:
Python Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- connect to text file database (Visual Basic 4 / 5 / 6)
- Give your Search Position a BOOST! Get 10000+ Text Links Leading to your Website! (Ad Space for Sale)
- LinksDealing.com : The best non-reciprocal text links promotion network (Relevant Link Exchanges)
- My Website (Website Reviews)
- Apache mod_rewrite with Google Ads (Linux Servers and Apache)
Other Threads in the Python Forum
- Previous Thread: Save number to a file
- Next Thread: Need help with caesar cipher
| Thread Tools | Search this Thread |
abrupt alarm ansi anti approximation assignment avogadro backend beginner binary bluetooth calculator character cmd code customdialog cx-freeze data decimals dictionaries dictionary directory dynamic error examples exe file float format function gnu graphics gui halp heads homework http ideas import input java launcher leftmouse line linux list lists loop module mouse number numbers output parsing path pointer port prime programming progressbar projects push py2exe pygame pyglet pyqt python random recursion schedule screensaverloopinactive script scrolledtext sqlite statistics string strings sudokusolver sum table terminal text thread threading time tlapse tricks tuple tutorial twoup ubuntu unicode urllib urllib2 variable ventrilo wikipedia write wxpython xlib






