2 Copyright (C) 1997-2017 JDERobot Developers Team 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2 of the License, or 7 (at your option) any later version. 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU Library General Public License for more details. 14 You should have received a copy of the GNU General Public License 15 along with this program; if not, see <http://www.gnu.org/licenses/>. 17 Authors : Okan Asik (asik.okan@gmail.com) 21 from PyQt5.QtWidgets
import QWidget, QVBoxLayout, QGroupBox, QComboBox, QHBoxLayout, QPushButton, \
22 QApplication, QLabel, QScrollArea, QBoxLayout, QMessageBox
23 from PyQt5.QtCore
import Qt
24 from visualstates.configs.rospackage
import getAllPackages
37 layout = QVBoxLayout()
38 self.setLayout(layout)
40 buildDependenciesScroll = QScrollArea()
41 buildDependenciesScroll.setMinimumHeight(200)
42 buildDependenciesScroll.setWidgetResizable(
True)
43 buildDependenciesScroll.setStyleSheet(
'QScrollArea {border: 0;}')
44 layout.addWidget(buildDependenciesScroll)
46 buildDependenciesBox = QGroupBox(
'Build Dependencies')
47 buildDependenciesScroll.setWidget(buildDependenciesBox)
49 self.buildLayout.setDirection(QBoxLayout.TopToBottom)
50 self.buildLayout.setAlignment(Qt.AlignTop)
53 buildRowLayout = QHBoxLayout()
54 self.buildLayout.addLayout(buildRowLayout)
56 self.buildDependenciesCb.setEditable(
True)
58 buildAddButton = QPushButton(
'Add')
59 buildAddButton.setMaximumWidth(80)
60 buildAddButton.setObjectName(
'build')
62 buildRowLayout.addWidget(buildAddButton)
64 runDependenciesScroll = QScrollArea()
65 runDependenciesScroll.setMinimumHeight(200)
66 runDependenciesScroll.setWidgetResizable(
True)
67 runDependenciesScroll.setStyleSheet(
'QScrollArea { border: 0;}')
68 layout.addWidget(runDependenciesScroll)
70 runDependenciesBox = QGroupBox(
'Run Dependencies')
71 runDependenciesScroll.setWidget(runDependenciesBox)
73 self.runLayout.setDirection(QBoxLayout.TopToBottom)
74 self.runLayout.setAlignment(Qt.AlignTop)
75 runDependenciesBox.setLayout(self.
runLayout)
77 runRowLayout = QHBoxLayout()
78 self.runLayout.addLayout(runRowLayout)
80 self.runDependenciesCb.setEditable(
True)
82 runAddButton = QPushButton(
'Add')
83 runAddButton.setMaximumWidth(80)
84 runAddButton.setObjectName(
'run')
86 runRowLayout.addWidget(runAddButton)
90 packages = sorted(packages)
92 self.runDependenciesCb.addItem(pkg)
93 self.buildDependenciesCb.addItem(pkg)
100 removeCallback =
None 101 dependenciesUI =
None 102 if self.sender().objectName() ==
'build':
104 dependency = self.buildDependenciesCb.currentText()
105 if len(dependency) > 0:
107 QMessageBox.information(self,
"Dependency present",
108 "This dependency is already present in the Build Dependencies list")
112 self.buildDependencies.append(dependency)
113 elif self.sender().objectName() ==
'run':
115 dependency = self.runDependenciesCb.currentText()
116 if len(dependency) > 0:
118 QMessageBox.information(self,
"Dependency present",
119 "This dependency is already present in the Run Dependencies list")
123 self.runDependencies.append(dependency)
125 if dependenciesUI
is not None:
130 rowLayout = QHBoxLayout()
131 dep[
'layout'] = rowLayout
132 layout.addLayout(rowLayout)
133 label = QLabel(dependency)
134 label.setStyleSheet(
'QLabel { border: 1px solid black; }')
136 removeBtn = QPushButton(
'Remove')
137 removeBtn.setMaximumWidth(80)
138 removeBtn.clicked.connect(removeCallback)
139 removeBtn.setObjectName(dependency)
140 dep[
'btn'] = removeBtn
141 rowLayout.addWidget(label)
142 rowLayout.addWidget(removeBtn)
143 dependenciesUI.append(dep)
147 for runDep
in dependenciesUI:
148 if runDep[
'label'].text() == dep:
152 if removeItem
is not None:
153 dependenciesUI.remove(removeItem)
154 removeItem[
'label'].deleteLater()
155 removeItem[
'btn'].deleteLater()
156 removeItem[
'layout'].deleteLater()
159 dep = self.sender().objectName()
160 self.runDependencies.remove(dep)
164 dep = self.sender().objectName()
165 self.buildDependencies.remove(dep)
171 depUI[
'label'].deleteLater()
172 depUI[
'btn'].deleteLater()
173 depUI[
'layout'].deleteLater()
176 depUI[
'label'].deleteLater()
177 depUI[
'btn'].deleteLater()
178 depUI[
'layout'].deleteLater()
188 if __name__ ==
'__main__':
189 app = QApplication(sys.argv)
def removeRunDependency(self)
def removeDep(self, dep, dependenciesUI)
def addDependencyUIs(self, layout, dependency, dependenciesUI, removeCallback)
def __init__(self, config)
def removeBuildDependency(self)
def drawDependenciesUI(self)