[pyzo] 23/68: Improved sorting for numbers in workspace (fixes #428)

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Sep 28 09:47:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch debian/master
in repository pyzo.

commit 9f87b9cf2db7e23ff26dd7c4717175308e411cb1
Author: Almar Klein <almar.klein at gmail.com>
Date:   Sun Sep 4 11:09:30 2016 +0200

    Improved sorting for numbers in workspace (fixes #428)
---
 pyzo/tools/pyzoWorkspace.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/pyzo/tools/pyzoWorkspace.py b/pyzo/tools/pyzoWorkspace.py
index c5d18c1..db510de 100644
--- a/pyzo/tools/pyzoWorkspace.py
+++ b/pyzo/tools/pyzoWorkspace.py
@@ -135,6 +135,15 @@ class WorkspaceProxy(QtCore.QObject):
         self.haveNewData.emit()
     
 
+class WorkspaceItem(QtGui.QTreeWidgetItem):
+    
+    def __lt__(self, otherItem):
+        column = self.treeWidget().sortColumn()
+        try:
+            return float( self.text(column).strip('[]') ) > float( otherItem.text(column).strip('[]') )
+        except ValueError:
+            return self.text(column) > otherItem.text(column)
+
 
 class WorkspaceTree(QtGui.QTreeWidget):
     """ WorkspaceTree
@@ -267,7 +276,7 @@ class WorkspaceTree(QtGui.QTreeWidget):
                 continue
             
             # Create item
-            item = QtGui.QTreeWidgetItem(parts, 0)
+            item = WorkspaceItem(parts, 0)
             self.addTopLevelItem(item)
             
             # Set tooltip

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyzo.git



More information about the debian-science-commits mailing list