1

デフォルトのテキスト表示を持つ GUI にテキスト ボックスを表示する方法はありますか?

テキストボックスに「必要なファイルのパスを設定してください...」と表示されますが、実行すると空白になります...

私のコードは次のとおりです。

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

2 に答える 2

1

これは、あなたが望むことを行う方法を示しているはずです:

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()
于 2013-07-25T13:55:39.443 に答える
1
path.set("Please set the path of the file you want...")

-また-

textEntry.insert(0, "Please set the path of the file you want...")

役立つドキュメント:

于 2013-07-25T13:53:42.220 に答える