Python Forum
tkinter - Make circle for radio button bigger - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: tkinter - Make circle for radio button bigger (/thread-2313.html)



tkinter - Make circle for radio button bigger - Raptor88 - Mar-07-2017

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.)


RE: tkinter - Make circle for radio button bigger - metulburr - Mar-07-2017

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.


RE: tkinter - Make circle for radio button bigger - Larz60+ - Mar-07-2017

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)


RE: tkinter - Make circle for radio button bigger - Raptor88 - Mar-07-2017

(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.


RE: tkinter - Make circle for radio button bigger - Larz60+ - Mar-07-2017

You're probable not going to. This is something you will have to roll on your own.
see: https://python-forum.io/Thread-Tkinter-VS-PyQt?highlight=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!


RE: tkinter - Make circle for radio button bigger - metulburr - Mar-07-2017

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.