[英]Why do I get 'unknown option “-Text”' with my tkinter Label?
I'm trying to create login window using the Python.我正在尝试使用 Python 创建登录窗口。 Unfortunately, I got an error while create the frame of Login.
不幸的是,我在创建登录框架时出错。 By the way, I'm very new on python.
顺便说一句,我对python很陌生。
when I tried to run it, this is the error showed.当我尝试运行它时,这是显示的错误。
"D:\Project\Python Sample\Scripts\python.exe" "D:/Project/La Solei/Main.py"
Traceback (most recent call last):
File "D:/Project/La Solei/Main.py", line 23, in <module>
obj= Login(root)
File "D:/Project/La Solei/Main.py", line 19, in __init__
title=Label(Frame_login, Text="Login Here", font=("Impact", 35, "bold"), fg="#CD853F", bg="White").place(x=90,y=30)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\tkinter\__init__.py", line 2766, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python37_64\lib\tkinter\__init__.py", line 2299, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: unknown option "-Text"
Process finished with exit code 1
from tkinter import *
from PIL import ImageTk
class Login:
def __init__(self, root):
self.root = root
self.root.title("LaSolieSystem")
self.root.geometry("1199x700+100+50")
self.root.resizable(False, False)
#Background
self.bg=ImageTk.PhotoImage(file="images/Main_image.jpg")
self.bg_image=Label(self.root, image=self.bg).place(x=0, y=0, relwidth=1, relheight=1)
#Loginframe
Frame_login = Frame(self.root, bg="#FFDB58")
Frame_login.place(x=600, y=50, width=500, height=600)
#Title & Subtitle
title=Label(Frame_login, Text="Login Here", font=("Impact", 35, "bold"), fg="#CD853F", bg="White").place(x=90,y=30)
root = Tk()
obj= Login(root)
root.mainloop()
Parameter names in python usually start with lower case. python中的参数名称通常以小写开头。 You need to change
Text=...
to text=...
in the Label parameters.您需要在 Label 参数中将
Text=...
更改为text=...
。
title = Label(Frame_login, text="Login Here", font=("Impact", 35, "bold"), fg="#CD853F", bg="White").place(x=90,y=30)
https://docs.python.org/3/library/tkinter.ttk.html#label-options https://docs.python.org/3/library/tkinter.ttk.html#label-options
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.