简体   繁体   English

获取_tkinter.TclError:tkinter中的未知选项“-relief”错误

[英]getting _tkinter.TclError: unknown option "-relief" error in tkinter

I'm trying to make a simple calculator but when I try to configure my entry with 'relief' method it is showing the error _tkinter.TclError: unknown option "-relief" .我正在尝试制作一个简单的计算器,但是当我尝试使用 'relief' 方法配置我的条目时,它显示错误_tkinter.TclError: unknown option "-relief"

I don't know why this is showing this error我不知道为什么会显示此错误

import tkinter as tk
from tkinter import ttk

win = tk.Tk()
win.geometry('400x400')
win.title('Simple Calculator')
win.configure(bg='Peach puff')
value = tk.StringVar()
entry = ttk.Entry(win, font=('Helvetica', 35, 'bold'), justify='right', textvariable=value, relief=tk.SUNKEN)
entry.pack(padx=30, pady=15, side='top', fill='both')

def spin():
    pass

button_images = {'one': tk.PhotoImage(file=r'C:\Users\hruthik\Desktop\Pics\numbers\one.png')}
b_one = ttk.Button(win, image=button_images['one'], command=spin, borderwidth=0)
b_one.pack(pady=20)
win.resizable(False, False)
win.mainloop()

The ttk package widgets have different options than the standard tkinter widgets. ttk包小部件具有与标准tkinter小部件不同的选项。 For example, the ttk.Entry widget has no option for relief, and the ttk.Button widget has no option for borderwidth.例如, ttk.Entry小部件没有救济选项,而ttk.Button小部件没有边框宽度选项。 Try using the tk.Entry and tk.Button widgets instead, if you want to specify these options如果您想指定这些选项,请尝试使用tk.Entrytk.Button小部件

import tkinter as tk
from tkinter import ttk

win = tk.Tk()
win.geometry('400x400')
win.title('Simple Calculator')
win.configure(bg='Peach puff')
value = tk.StringVar()
entry = tk.Entry(win, font=('Helvetica', 35, 'bold'), justify='right', textvariable=value, relief=tk.SUNKEN)
entry.pack(padx=30, pady=15, side='top', fill='both')


def spin():
    pass


button_images = {'one': tk.PhotoImage(file=r'C:\Users\hruthik\Desktop\Pics\numbers\one.png')}
b_one = tk.Button(win, image=button_images['one'], command=spin, borderwidth=0)
b_one.pack(pady=20)
win.resizable(False, False)
win.mainloop()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM