本文整理汇总了Python中PySide.QtGui.QComboBox.insertItem方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.insertItem方法的具体用法?Python QComboBox.insertItem怎么用?Python QComboBox.insertItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QComboBox
的用法示例。
在下文中一共展示了QComboBox.insertItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AddAreaDlg
# 需要导入模块: from PySide.QtGui import QComboBox [as 别名]
# 或者: from PySide.QtGui.QComboBox import insertItem [as 别名]
class AddAreaDlg(QDialog):
def __init__(self, parent=None):
super(AddAreaDlg, self).__init__(parent)
self.setWindowTitle("New Relief Device Area")
name_label = QLabel("&Name:")
self.name_lineedit = QLineEdit()
self.name_lineedit.setMaxLength(200)
name_label.setBuddy(self.name_lineedit)
location_label = QLabel("&Location:")
self.location_combobox = QComboBox()
self.location_combobox.setEditable(True)
location_label.setBuddy(self.location_combobox)
self.browse_button = QPushButton("&Browse...")
button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
layout = QGridLayout()
layout.addWidget(name_label, 0, 0)
layout.addWidget(self.name_lineedit, 0, 1)
layout.addWidget(location_label, 1, 0)
layout.addWidget(self.location_combobox, 1, 1)
layout.addWidget(self.browse_button, 1, 2)
#layout.addWidget(QFrame.HLine, 2, 0)
layout.addWidget(button_box, 2, 1)
self.setLayout(layout)
self.browse_button.clicked.connect(self.browseFiles)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
def browseFiles(self):
self.dirname = QFileDialog.getExistingDirectory(self, "Select file location", options=QFileDialog.ShowDirsOnly)
self.location_combobox.insertItem(0, self.dirname)
self.location_combobox.setCurrentIndex(0)
def accept(self):
if len(self.name_lineedit.text().strip()) == 0:
QMessageBox.warning(self, "Error: Relief Device Area Name Blank", "The relief device area must be given a name.", QMessageBox.Ok)
self.name_lineedit.setFocus()
return
if len(self.location_combobox.currentText().strip()) == 0:
QMessageBox.warning(self, "Error: Location Blank", "You must save the relief device area file to a valid directory.", QMessageBox.Ok)
self.location_combobox.setFocus()
return
if not os.path.exists(self.location_combobox.currentText().replace("\\", "/")):
QMessageBox.warning(self, "Error: Directory Does Not Exist", "The specified directory does not exist.", QMessageBox.Ok)
self.location_combobox.setFocus()
return
if os.path.isfile(self.location_combobox.currentText().replace("\\", "/") + "/" + self.name_lineedit.text() + ".rda"):
if QMessageBox.question(self, "File Already Exists",
"The file {0} already exists at {1}. Are you sure you want to proceed and overwrite this file?".format(self.name_lineedit.text() + ".rda",
self.location_combobox.currentText().replace("\\", "/")), QMessageBox.Yes|QMessageBox.No) == QMessageBox.No:
self.name_lineedit.setFocus()
return
QDialog.accept(self)
def returnVals(self):
return self.name_lineedit.text(), self.location_combobox.currentText().replace("\\", "/") + "/"