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 QDialog, \
22 QLineEdit, QPushButton, QApplication, \
23 QScrollArea, QVBoxLayout, QGroupBox, QHBoxLayout, \
24 QBoxLayout, QMessageBox
25 from PyQt5.QtCore
import pyqtSignal, Qt
26 from visualstates.gui.util.editablestringwidget
import EditableStringWidget
31 librariesChanged = pyqtSignal(list)
35 self.setWindowTitle(name)
36 self.setMinimumHeight(500)
37 self.setMinimumWidth(500)
41 self.addButton.setMinimumWidth(100)
44 verticalLayout = QVBoxLayout()
45 self.setLayout(verticalLayout)
46 scrollArea = QScrollArea()
47 scrollArea.setMinimumHeight(400)
48 scrollArea.setWidgetResizable(
True)
49 scrollArea.setStyleSheet(
'QScrollArea {border: 0;}')
50 verticalLayout.addWidget(scrollArea)
51 groupBox = QGroupBox(
"Libraries")
52 scrollArea.setWidget(groupBox)
54 self.groupLayout.setDirection(QBoxLayout.TopToBottom)
55 self.groupLayout.setAlignment(Qt.AlignTop)
59 rowLayout = QHBoxLayout()
60 self.groupLayout.addLayout(rowLayout)
63 self.addButton.clicked.connect(self.
addClicked)
75 self.groupLayout.removeWidget(libRow)
78 self.libraries.remove(libraryName)
79 self.librariesChanged.emit(self.
libraries)
81 def updated(self, oldLibraryName, newLibraryName):
91 self.librariesChanged.emit(self.
libraries)
94 libraryInp = self.libraryNameEdit.text().strip()
96 QMessageBox.information(self,
"Library Present",
"Library already present in the list")
99 self.libraries.append(self.libraryNameEdit.text())
100 self.librariesChanged.emit(self.
libraries)
102 self.libraryNameEdit.setText(
'')
105 libRow = EditableStringWidget(libraryName)
107 libRow.removed.connect(self.
removed)
108 libRow.updated.connect(self.
updated)
109 self.groupLayout.addWidget(libRow)
111 if __name__ ==
'__main__':
112 app = QApplication(sys.argv)
def updated(self, oldLibraryName, newLibraryName)
def addLibraryItem(self, libraryName)
def removed(self, libraryName)
def __init__(self, name, libraries)