|
|
@@ -18,7 +18,7 @@ from path import Path
|
|
|
|
|
|
Ui_window, _ = uic.loadUiType(Path(__file__).parent / 'select_list_dialog.ui')
|
|
|
|
|
|
-def exec_(input_list):
|
|
|
+def exec_(*args, **kwargs):
|
|
|
|
|
|
app = QApplication(sys.argv)
|
|
|
|
|
|
@@ -30,17 +30,20 @@ def exec_(input_list):
|
|
|
SYS_HOOK(typ, value, trace)
|
|
|
sys.excepthook = error_handler
|
|
|
|
|
|
- dlg = SelectListDialog(input_list)
|
|
|
+ dlg = SelectListDialog(*args, **kwargs)
|
|
|
dlg.show()
|
|
|
- app.exec_()
|
|
|
-
|
|
|
- return dlg.selection()
|
|
|
+ r = dlg.exec_()
|
|
|
+ if r:
|
|
|
+ return dlg.selection()
|
|
|
+ else:
|
|
|
+ return []
|
|
|
|
|
|
class SelectListDialog(QDialog):
|
|
|
|
|
|
- def __init__(self, input_list, title="Sélectionner les lignes"):
|
|
|
+ def __init__(self, input_list, modifier=lambda x: x, title="Sélectionner les lignes"):
|
|
|
super (SelectListDialog, self).__init__()
|
|
|
self.input_list = input_list
|
|
|
+ self.modifier = modifier
|
|
|
self.title = title
|
|
|
self.createWidgets()
|
|
|
|
|
|
@@ -53,9 +56,9 @@ class SelectListDialog(QDialog):
|
|
|
self.ui.lbl_title.setText(self.title)
|
|
|
|
|
|
index = 0
|
|
|
- for nomChantier in self.input_list:
|
|
|
+ for item in self.input_list:
|
|
|
self.ui.tbl_selection.insertRow(index)
|
|
|
- self.ui.tbl_selection.setItem(index, 0, QTableWidgetItem(" {}".format(nomChantier)))
|
|
|
+ self.ui.tbl_selection.setItem(index, 0, QTableWidgetItem(str(self.modifier(item))))
|
|
|
index += 1
|
|
|
self.ui.tbl_selection.sortItems(0, Qt.AscendingOrder)
|
|
|
|