2013-07-25 2 views
1

GUI에 기본 텍스트 디스플레이가있는 텍스트 상자가있는 방법이 있습니까? 다음과 같이 비어 ...Python : Entry 필드의 기본값을 갖는 방법이 있습니까?

내 코드는 -

나는 텍스트 상자 그러나, 나는 그것을 실행할 때 "당신이 원하는 파일의 경로 ...을 설정하십시오"해야합니다 싶어 :

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

답변

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() 
1
path.set("Please set the path of the file you want...") 

- 또는

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

USEF UL 설명서 :

관련 문제