python-3.x - 如何在 Tkinter、Python 3.8 中创建文本 wiget
问题描述
我想在窗口中制作一个文本wiget,但看到了这个回溯:
Traceback (most recent call last):
File "D:/хрень на питоне/experement3.py", line 18, in <module>
vl=Text(root, width = 20, heigth = 100 , wrap = WORD)
File "C:\Users\Людмилп\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3554, in __init__
Widget.__init__(self, master, 'text', cnf, kw)
File "C:\Users\Людмилп\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2567, in __init__
self.tk.call(
_tkinter.TclError: unknown option "-heigth"
我的代码如下所示:
from tkinter import *
root=Tk()
root.geometry('400x300')
app=Frame(root)
app.grid(row=2,column=0,sticky=S)
bt=Button(app,text='''
First button
''')
bt.grid()
app1=Frame(root)
app1.grid(row=2,column=1,sticky=S)
bt1=Button(app1,text='''
Second button
''')
bt1.grid()
vlf=Frame(root)
vlf.grid(row=0,column=3)
vl=Text(root, width = 20, heigth = 100 , wrap = WORD)
vl.grid()
root.mainloop()
可能出了什么问题?
解决方案
请仔细阅读您的错误消息,因为它们几乎包含有用的信息。在这种情况下,它会告诉您在第 18 行初始化 Text 小部件的位置,您给它一个选项“heigth”,它不能接受。这是因为您只是通过切换“t”和“h”而拼错了“height”,这可能会发生并且只是人类。
PS:你的英文还不错,别担心。^^
推荐阅读
- javascript - 根据错误状态更改元素的颜色代码
- json - xkcd api,如何阅读解释?
- android - Android Studio Manifest Merger 失败并出现多个错误
- php - 使用更改选择选项的新请求刷新页面
- javascript - 如何点击表格标签内的锚标签
- python - “UnicodeDecodeError:utf-8”试图做“python manage.py runserver”
- .net-core - 提高性能功能
用于反思 - ios - 使用 UIRotationGestureRecognizer 将弧度转换为度数?
- reporting-services - 订阅状态:报告处理过程中发生错误
- c# - WPF 设计器 (xdesproc) 和 x64 目标