Python Forum
tkinter - Make circle for radio button bigger
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.)
Reply
#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.
Recommended Tutorials:
Reply
#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)
Reply
#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.
Reply
#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!
Reply
#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.
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to open a popup window in tkinter with entry,label and button lunacy90 1 810 Sep-01-2023, 12:07 AM
Last Post: lunacy90
  Tkinter button images not showing up lunacy90 7 1,466 Aug-31-2023, 06:39 PM
Last Post: deanhystad
Bug tkinter.TclError: bad window path name "!button" V1ber 2 725 Aug-14-2023, 02:46 PM
Last Post: V1ber
  Looping over radio buttons garynewport 8 2,160 Jan-10-2023, 10:56 AM
Last Post: garynewport
  make all text in Right to left alignment in tkinter widgets jalal0034 1 1,257 Sep-27-2022, 06:42 PM
Last Post: Larz60+
  How to plot seaborn heatmap on top of a background circle SriRajesh 0 1,367 Jul-09-2022, 04:00 AM
Last Post: SriRajesh
  drawing moving circle on line with python barrai 1 3,033 Feb-25-2022, 03:33 PM
Last Post: BashBedlam
  Making a plot with secondary y-axis bigger snkm 0 1,094 Feb-10-2022, 09:40 AM
Last Post: snkm
  Closing Threads and the chrome window it spawned from Tkinter close button law 0 1,670 Jan-08-2022, 12:13 PM
Last Post: law
  tkinter auto press button kucingkembar 2 3,084 Dec-24-2021, 01:23 PM
Last Post: kucingkembar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020