Changeset 1925:7c31d7eb40ec in orange-bioinformatics for orangecontrib/bio/widgets/OWSelectGenes.py


Ignore:
Timestamp:
12/03/13 13:47:18 (5 months ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
Message:

Added "Import from text file" action.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orangecontrib/bio/widgets/OWSelectGenes.py

    r1922 r1925  
    11import sys 
     2import os 
    23import re 
    34import unicodedata 
     
    1617    QToolButton, QItemSelectionModel, QPlainTextDocumentLayout, QTextDocument, 
    1718    QRadioButton, QButtonGroup, QStyleOptionButton, QMenu, QDialog, 
    18     QStackedWidget, QComboBox 
     19    QStackedWidget, QComboBox, QFileDialog 
    1920) 
    2021 
     
    289290        action.triggered.connect(self.importGeneSet) 
    290291 
    291 #         addmenu.addAction("Import names from text file...") 
     292        action = addmenu.addAction("Import names from text file...") 
     293        action.triggered.connect(self.importFromFile) 
     294 
    292295        addaction.setMenu(addmenu) 
    293296 
     
    829832            self.entryField.moveCursor(QTextCursor.End) 
    830833 
     834    def importFromFile(self): 
     835        filename = QFileDialog.getOpenFileName( 
     836            self, "Open File", os.path.expanduser("~/")) 
     837 
     838        if filename: 
     839            filename = unicode(filename) 
     840            with open(filename, "rU") as f: 
     841                text = f.read() 
     842            self.entryField.appendPlainText(text) 
     843            self.entryField.setFocus() 
     844            self.entryField.moveCursor(QTextCursor.End) 
     845 
    831846    def _onSelectedSaveSlotChanged(self): 
    832847        item = self._selectedSaveSlot() 
Note: See TracChangeset for help on using the changeset viewer.