Tkinter Radiobutton:图像在 OSX 上像素化但在 Ubuntu 上工作正常

Tkinter Radiobutton: Image pixelated on OSX but works fine in Ubuntu

我实现了一个单选按钮网格,每个单选按钮都有一个独特的图像。

我在下面包含了相关的代码行:

photo[i] = ImageTk.PhotoImage(file=image_file)
button[i] = Radiobutton(frame, variable=var, value=i+1, indicatoron=0, image=photo[i], selectcolor='#808080')
button[i].pack(side=LEFT)

OSX 上的图像看起来非常像素化,如下所示:

相同的代码在 ubuntu 上工作得很好(没有可见的像素化)。以下为原图:

问题出在tcl tk的系统版本上here

If you are using macOS 10.6 or later, the Apple-supplied Tcl/Tk 8.5 has serious bugs that can cause application crashes. If you wish to use IDLE or Tkinter, do not use the Apple-supplied Pythons. Instead, install and use a newer version of Python from python.org or a third-party distributor that supplies or links with a newer version of Tcl/Tk.

这甚至导致我的单选按钮体验模糊。

If you are using a Python from any current python.org Python installer for macOS (3.9.0+, 3.8.0+, or 3.7.2+), no further action is needed to use IDLE or tkinter. A built-in version of Tcl/Tk 8.6 will be used.

我 运行 我的代码使用 IDLE,效果很好!虽然我仍然无法更改Apple提供的错误系统tcl tk。