python - 文本叠加在文本框中

标签 python python-2.7 tkinter

我有几个文本框想要放入我的程序中。对于每一个,我都希望有文本来解释要输入的内容。我在更复杂的非 Python 程序中见过它们。

而不是做类似的事情:

from Tkinter import *

top = Tk()
L1 = Label(top, text="User Name")
L1.pack( side = LEFT)
E1 = Entry(top, bd =5)

E1.pack(side = RIGHT)

top.mainloop()

我宁愿这样:Like This

tkinter 中有类似的东西吗?感谢您的帮助。

最佳答案

你可以这样做:

top = Tk()
E1 = Entry(top, bd =5)
E1.insert(0, "User Name")
E1.pack(side = RIGHT)
top.mainloop()

see here for more info .

关于python - 文本叠加在文本框中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18092223/

相关文章:

python - 使用 SURF 和 FLANN 比较图像与图像数据库

python - 在 Python Anywhere 托管服务器中触发 OpenCV 脚本时找不到相机

python-2.7 - 在忽略特定键的数据框中减去值

python - 尝试检查行数是否相同;我正确使用 izip 吗?

python-3.x - Python3-tk 已经安装,但是 python3.7 找不到模块 tkinter

python - 机器学习随机森林

python - 为什么 python 会改变这个列表中的值?

Python Pip 安装版本错误

python - 按下按钮不返回 Tkinter 中的 Line2D 对象

python - 使用 tkinter + sqlite3 时出错