Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python:有没有一种方法可以使输入字段具有默认值?_Python_Tkinter_Tkinter Entry - Fatal编程技术网

Python:有没有一种方法可以使输入字段具有默认值?

Python:有没有一种方法可以使输入字段具有默认值?,python,tkinter,tkinter-entry,Python,Tkinter,Tkinter Entry,有没有办法在GUI中设置一个默认文本显示的文本框 我希望文本框将有“请设置您想要的文件路径…” 但是,当我运行它时,它是空的 我的代码如下: path=StringVar() textEntry=Entry(master,textvariable=path,text='Please set the path of the file you want...') textEntry.pack() -或- 有用的文件: 这应该演示如何做您想做的事情: import Tkinter

有没有办法在GUI中设置一个默认文本显示的文本框

我希望文本框将有“请设置您想要的文件路径…” 但是,当我运行它时,它是空的

我的代码如下:

  path=StringVar()
  textEntry=Entry(master,textvariable=path,text='Please set the path of the file you want...')
  textEntry.pack()
-或-

有用的文件:


这应该演示如何做您想做的事情:

import Tkinter as tk

root = tk.Tk()

entry = tk.Entry(root, width=40)
entry.pack()
# Put text in the entrybox with the insert method.
# The 0 means "at the begining".
entry.insert(0, 'Please set the path of the file you want...')

text = tk.Text(root, width=45, height=5)
text.pack()
# Textboxes also have an insert.
# However, since they have a height and a width, you need to
# put 0.0 to spcify the beginning.  That is basically the same as
# x=0, y=0.
text.insert(0.0, 'Please set the path of the file you want...')

root.mainloop()
textEntry.insert(0, "Please set the path of the file you want...")
import Tkinter as tk

root = tk.Tk()

entry = tk.Entry(root, width=40)
entry.pack()
# Put text in the entrybox with the insert method.
# The 0 means "at the begining".
entry.insert(0, 'Please set the path of the file you want...')

text = tk.Text(root, width=45, height=5)
text.pack()
# Textboxes also have an insert.
# However, since they have a height and a width, you need to
# put 0.0 to spcify the beginning.  That is basically the same as
# x=0, y=0.
text.insert(0.0, 'Please set the path of the file you want...')

root.mainloop()