2

Tl;dr: How (Where can we get information) do we troubleshoot Tkinter at this system presentation layer? Surely the maintainers of Tkinter would have documented a guide somewhere. Any thoughts what could be causing this "wtf?" experience?

TAKE NOTE! To support future troubleshooting events, the objective is to understand the root cause so it can reproduced elsewhere, and then apply the fix.

PROBLEM:
The Checkbutton widget does not update, when clicking on the checkbox, on this specific Kubuntu KDE Plasma 5.18 machine configuration.
Tkinter_Checkbox_VisualIssue

INVESTIGATIONS:
This issue did not occur in the following environments:

  1. Windows 8.1,
  2. VirtualBox with LiveCD Kubuntu 20.04 (Plasma 5.18),
  3. VirtualBox with LiveCD Kubuntu 20.10 (Plasma 5.19),
  4. Kubuntu 20.04 (XFCE on original machine).

Tests with other GUI frameworks works correctly.

  1. Kivy
  2. GTK version 3
  3. wxPython

NEXT STEPS:

  1. Search results does not really provide guides or issues related to this specific.
  2. Also ask advice on the python org discuss platform.
  3. Try to create a TCL test version.

SOURCE CODE FOR TEST:

from tkinter import *
class MyGUI:
    def __init__(self, window):
        self.var = IntVar()
        self.c = Checkbutton(window,
                             text="Enable Tab",
                             variable=self.var,
                             command=self.cb)
        self.c.pack()

    def cb(self):
        print("self.var is", self.var.get())

if __name__ == "__main__":
    root = Tk()
    gui = MyGUI(root)
    root.mainloop()

OUTPUT:

>self.var is 1  
>self.var is 0  
>self.var is 1

SYSTEM SPECS:
Operating System: Kubuntu 20.04
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8
Kernel Version: 5.4.0-58-generic
OS Type: 64-bit
Processors: Intel i3 4 Core M350 2.27GHz
Memory: 7,6 GiB of RAM
Python 3.8.5
Tcl/Tk version 8.6

4

1 回答 1

0

答案、解决方案和结论

根本原因是与“ Breeze Dark ”相关的“ KDE Plasma Color Schemes ”的“ Window Text ”颜色导致 Tkinter Checkbutton 不是 100% 可见,因为文本颜色与复选框背景非常相似。

Tkinter_KDEPlasma_BreezeDark_wtxt_Issue

解决方案/解决方法
建议在构建应用程序 GUI 时考虑样式(主题),以通过使用户能够在一定程度上更改 GUI 来改善用户体验。在这种情况下,似乎 Tkinter 正在使用旨在用于其他目的的系统设置值。

最快的解决方法是至少导入 tkinter.ttk (Python3)。

    from tkinter import *
    from tkinter.ttk import *

Tkinter_KDEPlasma_BreezeDark_wtxt_Issue_solution

结论
我猜随着更多信息的出现,这将得到更新。 对于上面的问题,幸运的是问题相对简单,应该是错误确认清单的一部分。但是,调试要复杂得多、模糊,或者说是一门黑暗的艺术。以下是一些支持故障排除和调查 Tkinter 相关问题的指导。

  1. 由于 Tkinter 是 Tcl/tk 解释器的包装器,因此事情变得棘手。Tkinter 源代码位于GitHub 上
  2. 似乎起点是通过Tcl Developer Xchange工作。来自相当活跃的社区的良好参考和资源。
于 2020-12-20T18:02:18.083 回答