2
미리 정의 된 목록에서 버튼을 선택하기보다 텍스트 입력을 지원하는 Qt4 (실제로는 PyQt4)에 메시지 상자를 표시하는 쉽고 깨끗한 방법이 있습니까? 이러한 대화 상자를 표시하기위한 사용자 정의 클래스를 작성하여이 작업을 수행 할 수는 있지만 (부분적으로는 수행 할 수는 있지만) 더 깨끗한 방법이 아닙니까?Qt는 텍스트 입력이있는 메시지 상자를 보여줍니다.
편집 : 루카 칼론에게 감사의 말을 전합니다. 그러나 단지의 경우 다른 사람이 필요합니다, 나는 그것에 대해
from PyQt4.QtGui import QInputDialog
#This code works only inside a method of a widget or window as self must refer to a
#valid widget or window to get the correct modality, although we can give None instead
(text,truth)=QInputDialog.getText(self,"Get text","User name",QLineEdit.Normal,"NoName")
if truth:
#The user has accepted the edit, he/she has clicked OK
print text
else:
#The user has not accepted the edit, he/she has clicked Cancel
print "No change"
편집 해 주셔서 감사합니다. – James