1 回答
TA贡献1828条经验 获得超4个赞
将结果与数组中的项目进行比较。
advBasicOptions = ("Basic", "Advanced")
selection, okPressed = QInputDialog.getItem(self, "Select Basic or Advanced", "", advBasicOptions, 0, False)
if selection == advBasicOptions[0]:
print('Basic')
if selection == advBasicOptions[1]:
print('advanced')
注意:我可能建议将这两个if语句放在一个封闭if okPressed块中,因为可能会选择Cancel或任何非确定选项。
如果您需要稍后存储它,只需将其保存到 self 上的实例变量中:
advBasicOptions = ("Basic", "Advanced")
self.selection, okPressed = QInputDialog.getItem(self, "Select Basic or Advanced", "", advBasicOptions, 0, False)
if self.selection == advBasicOptions[0]:
print('Basic')
if self.selection == advBasicOptions[1]:
print('advanced')
我希望这回答了你的问题
添加回答
举报