944,166 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Unsolved
  • Views: 2189
  • Python RSS
Mar 8th, 2007
0

Radiobutton text placement

Expand Post »
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.
Similar Threads
aot
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
aot is offline Offline
83 posts
since Feb 2007
Mar 8th, 2007
0

Re: Radiobutton text placement

What module do you use to get a radiobutton?
Reputation Points: 407
Solved Threads: 36
Posting Virtuoso
Lardmeister is offline Offline
1,701 posts
since Mar 2007
Mar 8th, 2007
0

Re: Radiobutton text placement

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:

Python Syntax (Toggle Plain Text)
  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
Reputation Points: 92
Solved Threads: 156
Practically a Master Poster
jrcagle is offline Offline
608 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: Save number to a file
Next Thread in Python Forum Timeline: how to access dropdown list entries in python psp site





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC