The third parameter indicates the display type: QLineEdit.Normal, QLineEdit. Password, QLineEdit. NoEcho
1
value, ok = QInputDialog.getText(self, "Title", "Prompt information", QLineEdit.Normal, "This is the default value")
1.4 Input Multiple Text
1
value, ok = QInputDialog.getMultiLineText(self, "Title", "Prompt information", "The default \n My address is \n Guangzhou Panyu, Guangdong, China")
1.5 Input Options
1 2 3
# `1` Selects the selected items by default. True/False Indicates whether the list box can be edited. items = ["Spring", "Summer", "Fall", "Winter"] value, ok = QInputDialog.getItem(self, "Title", "Prompt information", items, 1, True)
Respectively after two buttons (separated with |, a total of 7 types of button, after see sample) and the default button (omit the default for the first button)
1
reply = QMessageBox.information(self, "Title", "This is a message.", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
2.2 Question QMessageBox
1
reply = QMessageBox.question(self, "Title", "Is this a question ?", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
2.3 Warning QMessageBox
1
reply = QMessageBox.warning(self, "Title", "This is a warning.", QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
directory = QFileDialog.getExistingDirectory(self, "Select a directory", "C:/") # The initial path
3.2 Singe File
1 2
# Set file extension filtering. Use a double semicolon interval file_, filetype = QFileDialog.getOpenFileName(self, "Select the file", "C:/", "All Files (*);;Text Files (*.txt)")
3.3 Multiple Files
1
files, ok = QFileDialog.getOpenFileNames(self, "Multiple files selection", "C:/", "All Files (*);;Text Files (*.txt)")
Ctrl button to select multiple files.
3.4 Save
1
file_, ok = QFileDialog.getSaveFileName(self, "File saving", "C:/", "All Files (*);;Text Files (*.txt)")
3.5 Save as
1
file_, ok = QFileDialog.getSaveFileName(self, "Save the file as", "C:/", "All Files (*);;Text Files (*.txt)")