summaryrefslogtreecommitdiff
path: root/src/configuration/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/configuration/test.py')
-rw-r--r--src/configuration/test.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/configuration/test.py b/src/configuration/test.py
new file mode 100644
index 00000000..4dd9f39d
--- /dev/null
+++ b/src/configuration/test.py
@@ -0,0 +1,61 @@
+'''
+Created on 04-Feb-2015
+
+@author: fahim
+'''
+import sys
+from PyQt4 import QtGui, QtCore
+
+
+class MainWindow(QtGui.QMainWindow):
+
+ def __init__(self, *args):
+ apply(QtGui.QMainWindow.__init__, (self, ) + args)
+ self.setCaption("Adding and deleting widgets")
+ self.setName("main window")
+ self.mainWidget=QtGui.QWidget(self)
+ self.setCentralWidget(self.mainWidget)
+ self.mainLayout=QtGui.QVBoxLayout(self.mainWidget, 5, 5, "main")
+ self.buttonLayout=QtGui.QHBoxLayout(self.mainLayout, 5, "button")
+ self.widgetLayout=QtGui.QVBoxLayout(self.mainLayout, 5, "widget")
+
+ self.bnAdd=QtGui.QPushButton("Add widget", self.mainWidget, "add")
+ self.connect(self.bnAdd, QtCore.SIGNAL("clicked()"),
+ self.slotAddWidget)
+
+ self.bnRemove=QtGui.QPushButton("Remove widget",
+ self.mainWidget, "remove")
+ self.connect(self.bnRemove, QtCore.SIGNAL("clicked()"),
+ self.slotRemoveWidget)
+
+ self.buttonLayout.addWidget(self.bnAdd)
+ self.buttonLayout.addWidget(self.bnRemove)
+
+ self.buttons = []
+
+ def slotAddWidget(self):
+ widget=QtGui.QPushButton("test", self.mainWidget)
+ self.widgetLayout.addWidget(widget)
+ self.buttons.append(widget)
+ widget.show()
+
+ def slotRemoveWidget(self):
+ self.widgetLayout.parent().removeChild(self.widgetLayout)
+ self.widgetLayout=QtGui.QVBoxLayout(self.mainLayout, 5, "widget")
+ self.buttons[-1].parent().removeChild(self.buttons[-1])
+ del self.buttons[-1:]
+
+
+def main(args):
+ app=QtGui.QApplication(args)
+ win=MainWindow()
+ win.show()
+ app.connect(app, QtCore.SIGNAL("lastWindowClosed()")
+ , app
+ ,QtCore.SLOT("quit()")
+ )
+ app.exec_loop()
+
+if __name__=="__main__":
+ main(sys.argv)
+