Flashpoint avatar Flashpoint committed 592576d

Version 2 of the OWCustomSet.py widget

Comments (0)

Files changed (1)

_bioinformatics/widgets/prototypes/OWCustomSets.py

        
         # The preview field        
         box = OWGUI.widgetBox(self.controlArea, "Available Gene Sets")
-        self.preview_view = QPlainTextEdit()
-        self.preview_view.setReadOnly(True)
-        self.preview_view.setWordWrapMode(0)
- 
+        self.preview_view = QTreeWidget()
+        self.preview_view.setAllColumnsShowFocus(1)
+        self.preview_view.setColumnCount(3)
+        self.preview_view.setHeaderLabels(["Name", "# of Genes", "Genes"])
+
+        self.preview_view.header().setStretchLastSection(True)
+        self.preview_view.header().setClickable(True)
+        self.preview_view.header().setSortIndicatorShown(True)
+        self.preview_view.setSortingEnabled(True)
+
         # The geneset table
         ma = self.mainArea
 
         ma.layout().addWidget(self.preview_view)
         box.layout().addWidget(self.listView)
 
-
         self.listView.setAllColumnsShowFocus(1)
         self.listView.setColumnCount(2)
         self.listView.setHeaderLabels(["Name", "Import time"])
 
         self.listView.header().setStretchLastSection(True)
-#        self.listView.header().setClickable(True)
-#        self.listView.header().setSortIndicatorShown(True)
-#        self.listView.setSortingEnabled(True)
 
         self.listView.setSelectionMode(QAbstractItemView.SingleSelection)
         self.listView.setSelectionBehavior(QAbstractItemView.SelectRows)
                     the_file = os.path.join(local_path(), geneset) 
                     sets = pickle.load(open(the_file, "rb"))
                     break
-            geneset_count = 0
             for geneset in sets:
-                final_text += geneset.id + " (%d genes)\n" % len(geneset.genes)
-                final_text += ", ".join([geneset.genes.pop() for i in range(5)]) + ", ...\n\n"
-                geneset_count += 1
-                if geneset_count == 5:
-                    break
-            final_text += "..."
-            self.preview_view.setPlainText(final_text)
+                item = QTreeWidgetItem(self.preview_view)
+                item.setText(0, geneset.id)
+                item.setData(1, Qt.DisplayRole, len(geneset.genes))
+                item.setText(2, ", ".join([geneset.genes.pop() for i in range(5)]) + ", ...")
         else:
             self.preview_view.clear()
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.