我正在开发一个项目,要求我在Tkinter Label小部件中为某些文本加下划线.我知道可以使用下划线方法,但我似乎只能根据参数强调小部件的1个字符.即
p = Label(root, text=" Test Label", bg='blue', fg='white', underline=0)
change underline to 0, and it underlines the first character, 1 the second etc
Run Code Online (Sandbox Code Playgroud)
我需要能够强化小部件中的所有文本,我确信这是可能的,但是如何?
我在Windows 7上使用Python 2.6.
我创建了一个代码来显示我的问题。看起来像这样:
userNameID = tkinter.Label(root, text="Name/ID")
userNameID.place(x=640, y=320, anchor="e")
userNameID = tkinter.Label(root, text="Password")
userNameID.place(x=640, y=360, anchor="e")
entButton = tkinter.Button(root, text="Enter", command=enterPrint)
entButton.place(x=640, y=400, anchor="w")
Run Code Online (Sandbox Code Playgroud)
问题是我在中心的一个尺寸上对齐了一些文本,在另一侧对齐了一个按钮。我想知道文本的西北锚的位置,以确保所有内容与中心的距离均相同,并且仍然对齐。