Bottom Page

Thread Rating:
  • 2 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 tkinter - Make circle for radio button bigger
#1
Running Python 3.6.  Using tkinter for GUI.

How can I make the circle for a radio button bigger?  I'm referring to the circle that the user clicks.  I can use padx and pady to put more space on the sides and above/below a radio button but that does not make the circle bigger.

On my 15 inch, 1920x1080 laptop screen, the circle is rather small and requires careful mouse cursor control to tick the small circle.  I want to make the circle twice the default diameter.

Here's some sample code in case it is necessary to answer my question:  

# ===== Right Frame and its contents =====
rightFrame = Frame(root, width=200, height = 600)
rightFrame.grid(row=0, column=1, padx=10, pady=2)

var = IntVar()

R2 = Radiobutton(rightFrame, text="0.2", font=(None, 16), variable=var, value=2, command=sel, padx=40).pack( anchor = W )
(There are 9 radio buttons but did not list them all since they are similar.)
Quote
#2
I might be wrong, but i dont think there is an option to change the size of the default radio button itself. However you can use images, and then just scale them to your required size.
Quote
#3
No easy way that I know of. You can look at the ttk code for RadioButton,
you can probably modify it there. It's also possible (I don't know this, but may be possible) that
you can do it using pmw. You'll have to read the docs to see if it's possible. see: http://pmw.sourceforge.net/doc/index.html

(pmw now runs on python 3)
Quote
#4
(Mar-07-2017, 03:50 AM)metulburr Wrote: I might be wrong, but i dont think there is an option to change the size of the default radio button itself. However you can use images, and then just scale them to your required size.

A bit more work than it's worth for my current program. 

But for future use, do you mean to overlay the current radio circle with an image?  Would I then have to write code to put a black dot in the image to show it was clicked, and also clear any other radio button's circle that was previously clicked?  Also have the code move the circle images to track the window in case the user moves the window?  And have code to manage all of that?

Or is there a simple way to do what you suggested that would work like the default radio button's circle?

Thanks for the help.

(Mar-07-2017, 04:00 AM)Larz60+ Wrote: No easy way that I know of. You can look at the ttk code for RadioButton,
you can probably modify it there. It's also possible (I don't know this, but may be possible) that
you can do it using pmw. You'll have to read the docs to see if it's possible. see: http://pmw.sourceforge.net/doc/index.html

(pmw now runs on python 3)

I did stumble on the ttk explanations for the RadioButton during my Googling.  Did not see an option there to change the size of the clickable circle.

Sounds like getting the circle to be bigger will be a challenging effort.  Maybe someday after I get more proficient with Python and tkinter.

Thanks for the help.
Quote
#5
You're probable not going to. This is something you will have to roll on your own.
see: https://python-forum.io/Thread-Tkinter-V...calculator #7 for some pmw code,
and same thread for what the output looks like in #8
Sorry, I didn't need a different radio button.
I'ts doable but you have to be the do'er!
Quote
#6
Quote:A bit more work than it's worth for my current program.  

But for future use, do you mean to overlay the current radio circle with an image?  Would I then have to write code to put a black dot in the image to show it was clicked, and also clear any other radio button's circle that was previously clicked?  Also have the code move the circle images to track the window in case the user moves the window?  And have code to manage all of that?

Or is there a simple way to do what you suggested that would work like the default radio button's circle?
The easiest method is to have an image with an empty circle for unselected, and another image with a circle in it, for selected. And just swap between those 2 images for selected/unselected. Just use GIMP or similar to create the 2 images to perfection. There is no code for adding a dot then. Ill often use this method in pygame where there are no GUI tools whatsoever by default. 

At this point you just need the code...which again the easiest solution would be to use tkinter.RadioButton if it has the option to insert custom images. Again i dont think it does to do the bubbles themselves.....but Ill let you research into that. At worst case you would have to sub class Radiobutton to change the default bubbles, or roll out your own completely.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  User input to calculate Area or Radius of Circle DustinKlent 3 212 Nov-10-2019, 08:46 AM
Last Post: Gribouillis
  packet radio communication EmpireAndrew 1 158 Nov-01-2019, 06:35 PM
Last Post: micseydel
  Function assigned at a button in tkinter riccardoob 9 379 Oct-06-2019, 11:14 AM
Last Post: riccardoob
  calculate circle sector Bloody_geek 2 297 Sep-11-2019, 08:54 PM
Last Post: Larz60+
  circle node with horizontal line in python graphviz mandana 0 353 May-05-2019, 10:39 AM
Last Post: mandana
  tkinter button executes button before being clicked SheeppOSU 1 362 Apr-01-2019, 10:51 PM
Last Post: Yoriz
  Internet radio script ahim 3 811 Jul-14-2018, 06:13 PM
Last Post: ahim
  Buttons or Radio Buttons on Tkinter Treeview draems 0 1,145 Oct-31-2017, 04:06 AM
Last Post: draems
  Help with circle and motion wigigx 4 1,362 Aug-29-2017, 09:49 PM
Last Post: sparkz_alot
  Python/Tkinter button color changing Crawford3 7 34,828 Aug-10-2017, 02:07 PM
Last Post: DeaD_EyE

Forum Jump:


Users browsing this thread: 1 Guest(s)