|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2014 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to select from a list. |
|
8 """ |
|
9 |
|
10 from PyQt5.QtWidgets import QDialog |
|
11 |
|
12 from .Ui_GitListDialog import Ui_GitListDialog |
|
13 |
|
14 |
|
15 class GitListDialog(QDialog, Ui_GitListDialog): |
|
16 """ |
|
17 Class implementing a dialog to select from a list. |
|
18 """ |
|
19 def __init__(self, selections, parent=None): |
|
20 """ |
|
21 Constructor |
|
22 |
|
23 @param selections list of entries to select from (list of string) |
|
24 @param parent reference to the parent widget (QWidget) |
|
25 """ |
|
26 super().__init__(parent) |
|
27 self.setupUi(self) |
|
28 |
|
29 self.selectionList.addItems(selections) |
|
30 |
|
31 def getSelection(self): |
|
32 """ |
|
33 Public method to return the selected entries. |
|
34 |
|
35 @return list of selected entries (list of string) |
|
36 """ |
|
37 selection = [] |
|
38 for itm in self.selectionList.selectedItems(): |
|
39 selection.append(itm.text()) |
|
40 |
|
41 return selection |