14

I'm using Tkinter ttk radio buttons, and have a peculiar issue. The last radio button created appears larger than the others at first. Once the mouse is placed over it, it snaps to the right size.

The issue looks like this:

enter image description here

And this is the code I'm using, in its entirety:

import tkinter
from tkinter import ttk

root = tkinter.Tk()

radioSelect = tkinter.IntVar()
radio1 = ttk.Radiobutton(root, text="A", variable=radioSelect, value=1)
radio2 = ttk.Radiobutton(root, text="B", variable=radioSelect, value=2)

radio1.grid()
radio2.grid()

root.mainloop()

This appears if I use grid or place, and it appears on checkboxes as well as radio buttons. The issue doesn't appear if I use the tkinter radio buttons, rather than the ttk ones, but I'd like to use the ttk ones because they look nicer.

I'm running Windows 7 64-bit, Python version

3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)]

I've searched but am unable to find anyone with a similar issue.

What's going on here?

UPDATE: This only occurs when using the "vista" theme, which is the default (at least on my machine). If another theme is specified, the issue goes away.

gfrung4
  • 1,658
  • 3
  • 14
  • 22
  • 1
    Seems to be OS related or tk/python implementation dependant. I just checked using python 3.4 on ubuntu 14.04 and don't see such behaviour. Everything seems to be ok for me. Can you provide more details about your setup, and more complete code. We cant just copy and paste your snippet to test this behaviour. – Marcin Feb 13 '15 at 01:38
  • 1
    I wrote a simpler example to avoid throwing hundreds of lines of code. It creates a window, adds two radio buttons, and shows it, and the issue occurs. I used grid in my example, but it happens with place as well. I also added my OS and Python version, if that helps. – gfrung4 Feb 13 '15 at 01:48
  • 1
    Yep. so now I can confirm its not a problem in Linux. Seems to be OS/python implementation dependent. Thus, I don't know how to solve it for windows, as I only use Linux. Sorry. – Marcin Feb 13 '15 at 01:59
  • 1
    I also attach gif showing how it works in linux [here](http://i.imgur.com/LYrjeHw.gif). – Marcin Feb 13 '15 at 02:01
  • btw: `root.grid()` does absolutely nothing. You don't need it. – Bryan Oakley Feb 13 '15 at 02:03
  • @BryanOakley Thanks! I've removed that line. I originally had the two radio buttons on a frame, which was on the window. I had to grid the frame. I realized it made the example simpler if I just put the radio buttons directly on the window, but forgot about the grid line in my edits... – gfrung4 Feb 13 '15 at 02:05
  • 3
    I observe the same issue when I disable display scaling on high DPI settings, like this `from ctypes import windll; windll.shcore.SetProcessDpiAwareness(1)`. However, the Minimum supported client for the feature is Windows 8.1 as stated in the MS documentation. – Max Jan 08 '19 at 22:21

1 Answers1

1

As some comment said, it must be OS related issue, i tested your code and everything is normal and working fine,unfortunately, after some long searches, i found out that there is no way to resize the button size.

ghazigamer
  • 100
  • 9