Commits

Aleš Erjavec committed 7c31d7e

Added "Import from text file" action.

  • Participants
  • Parent commits 67818b3

Comments (0)

Files changed (1)

File orangecontrib/bio/widgets/OWSelectGenes.py

 import sys
+import os
 import re
 import unicodedata
 import operator
     QStyleOptionViewItemV4, QPalette, QColor, QApplication, QAction,
     QToolButton, QItemSelectionModel, QPlainTextDocumentLayout, QTextDocument,
     QRadioButton, QButtonGroup, QStyleOptionButton, QMenu, QDialog,
-    QStackedWidget, QComboBox
+    QStackedWidget, QComboBox, QFileDialog
 )
 
 from PyQt4.QtCore import Qt, QEvent, QVariant, QThread
         action = addmenu.addAction("Import names from gene sets...")
         action.triggered.connect(self.importGeneSet)
 
-#         addmenu.addAction("Import names from text file...")
+        action = addmenu.addAction("Import names from text file...")
+        action.triggered.connect(self.importFromFile)
+
         addaction.setMenu(addmenu)
 
         def button(action, popupMode=None):
             self.entryField.setFocus()
             self.entryField.moveCursor(QTextCursor.End)
 
+    def importFromFile(self):
+        filename = QFileDialog.getOpenFileName(
+            self, "Open File", os.path.expanduser("~/"))
+
+        if filename:
+            filename = unicode(filename)
+            with open(filename, "rU") as f:
+                text = f.read()
+            self.entryField.appendPlainText(text)
+            self.entryField.setFocus()
+            self.entryField.moveCursor(QTextCursor.End)
+
     def _onSelectedSaveSlotChanged(self):
         item = self._selectedSaveSlot()
         if item: