小编dap*_*dap的帖子

python - _tkinter.TclError:ttk.Frame 的未知选项“-bg”

我想用 2 个选项卡在我的 GUI 中制作带有颜色的背景,我遇到了这个问题,也许有一些建议?

这是代码:

colors = ["Blue", "Gold", "Red"]

def radCall():
    radSel=radVar.get()
    if radSel == 0: tab1.configure(bg=colors[0])
    elif radSel == 1: tab1.configure(bg=colors[1])
    elif radSel == 2: tab1.configure(bg=colors[2])

radVar = tk.IntVar()
radVar.set(99)

for col in range(3):
    curRad = tk.Radiobutton(mighty, text=colors[col], variable=radVar, 
                            value=col, command=radCall)
    curRad.grid(column=col, row=13, sticky=tk.W)
Run Code Online (Sandbox Code Playgroud)

这是问题所在:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\HP\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1892, in __call__                           >C:/Users/HP/
    return self.func(*args)                                        top/Kuliah/Se
  File "c:\Users\HP\Desktop\Kuliah\Semester 2\Information TechnologI_jualbeli_Day\Python\week5\Informasi Jual Beli\GUI_jualbeli_Dazan.py", line 277, in radCall
if radSel == …
Run Code Online (Sandbox Code Playgroud)

python tkinter

2
推荐指数
1
解决办法
86
查看次数

标签 统计

python ×1

tkinter ×1