Radiobutton text placement

Reply

Join Date: Feb 2007
Posts: 77
Reputation: aot is an unknown quantity at this point 
Solved Threads: 1
aot's Avatar
aot aot is offline Offline
Junior Poster in Training

Radiobutton text placement

 
0
  #1
Mar 8th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 1,521
Reputation: Lardmeister is an unknown quantity at this point 
Solved Threads: 22
Lardmeister's Avatar
Lardmeister Lardmeister is offline Offline
Posting Virtuoso

Re: Radiobutton text placement

 
0
  #2
Mar 8th, 2007
What module do you use to get a radiobutton?
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 608
Reputation: jrcagle is on a distinguished road 
Solved Threads: 150
jrcagle jrcagle is offline Offline
Practically a Master Poster

Re: Radiobutton text placement

 
0
  #3
Mar 8th, 2007
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:

  1. from Tkinter import *
  2.  
  3. class ComboButton(Frame):
  4.  
  5. def __init__(self, master,text='',variable=None, value=""):
  6. Frame.__init__(self,master)
  7. self.label = Label(self,text=text)
  8. self.button = Radiobutton(self,text='',variable=variable, value=value)
  9. self.variable = variable
  10. self.button.grid()
  11. self.label.grid()
  12.  
  13. mainw = Tk()
  14. v = StringVar()
  15. mainw.f = ComboButton(mainw,"Option 1", value="Option 1",variable=v)
  16. mainw.f.grid()
  17. 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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC