From 9298658f46ac17c7fc8c3211d865d4700a4226e6 Mon Sep 17 00:00:00 2001
From: Julien Malik <julien.malik@c-s.fr>
Date: Sun, 19 Jun 2011 16:53:52 +0200
Subject: [PATCH] ENH: fix choice with no child parameters

---
 Code/Wrappers/PyQt/otbapp/widgets.py | 34 +++++++---------------------
 1 file changed, 8 insertions(+), 26 deletions(-)

diff --git a/Code/Wrappers/PyQt/otbapp/widgets.py b/Code/Wrappers/PyQt/otbapp/widgets.py
index 2d58ceac70..1d2dfb414d 100644
--- a/Code/Wrappers/PyQt/otbapp/widgets.py
+++ b/Code/Wrappers/PyQt/otbapp/widgets.py
@@ -103,36 +103,18 @@ class QParameterChoice(QParameterBase):
         
         stack = QtGui.QStackedWidget()
         
-        allparams = app.GetParametersKeys(True)
-        print str(allparams)
-        
-        subgroups = []
-        choicelist = []
-        for paramKey in allparams:
-            print 'paramKey ' + paramKey
-            if paramKey.startswith(self._paramKey):
-                choicelist.append(paramKey)
-                choiceSubParam = paramKey.partition(self._paramKey + '.')[2].partition('.')[0]
-                if choiceSubParam:
-                    print "choiceSubParam "+ choiceSubParam
-                    subgroups.append(choiceSubParam.partition('.')[0])
-                else:
-                    print "choiceSubParam None"
-                    subgroups.append(None)
-        
-        print 'choicelist ' + str(choicelist)
         for choice in zip(app.GetChoiceKeys(self._paramKey), app.GetChoiceNames(self._paramKey)):
             combo.addItem(choice[1], choice[0])
-            
-        for subgroup in subgroups:
-            if not subgroup:
-                continue
-            widget = QParameterGroup(self.GetModel(), self._paramKey + '.' + subgroup)
-            if widget:
+        
+        allparams = app.GetParametersKeys(True)
+        for choiceKey in app.GetChoiceKeys(self._paramKey):
+            a = [s for s in allparams if s.startswith(self._paramKey + '.' + choiceKey + '.')]
+            if not a:
+                stack.addWidget(QtGui.QWidget())
+            else:
+                widget = QParameterGroup(self.GetModel(), self._paramKey + '.' + choiceKey)
                 widget.CreateWidget()
                 stack.addWidget(widget)
-            else:
-                stack.addWidget(QtGui.QWidget())
 
         self.connect(combo, QtCore.SIGNAL("currentIndexChanged(int)"), self.SetValue)
         self.connect(combo, QtCore.SIGNAL("currentIndexChanged(int)"), stack.setCurrentIndex)
-- 
GitLab