コード例 #1
0
ファイル: dicteditor.py プロジェクト: cheesinglee/spyder
 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return QVariant()
     value = self.get_value(index)
     if index.column() == 3 and self.remote:
         value = value['view']
     display = value_to_display(value,
                            truncate=index.column() == 3 and self.truncate,
                            minmax=self.minmax,
                            collvalue=self.collvalue or index.column() != 3)
     if role == Qt.DisplayRole:
         return QVariant(display)
     elif role == Qt.EditRole:
         return QVariant(value_to_display(value))
     elif role == Qt.TextAlignmentRole:
         if index.column() == 3:
             if len(display.splitlines()) < 3:
                 return QVariant(int(Qt.AlignLeft|Qt.AlignVCenter))
             else:
                 return QVariant(int(Qt.AlignLeft|Qt.AlignTop))
         else:
             return QVariant(int(Qt.AlignLeft|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole:
         return QVariant( self.get_bgcolor(index) )
     elif role == Qt.FontRole:
         if index.column() < 3:
             return QVariant(get_font('dicteditor_header'))
         else:
             return QVariant(get_font('dicteditor'))
     return QVariant()
コード例 #2
0
 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return QVariant()
     value = self.get_value(index)
     if index.column() == 3 and self.remote:
         value = value['view']
     display = value_to_display(value,
                                truncate=index.column() == 3
                                and self.truncate,
                                minmax=self.minmax,
                                collvalue=self.collvalue
                                or index.column() != 3)
     if role == Qt.DisplayRole:
         return QVariant(display)
     elif role == Qt.EditRole:
         return QVariant(value_to_display(value))
     elif role == Qt.TextAlignmentRole:
         if index.column() == 3:
             if len(display.splitlines()) < 3:
                 return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
             else:
                 return QVariant(int(Qt.AlignLeft | Qt.AlignTop))
         else:
             return QVariant(int(Qt.AlignLeft | Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole:
         return QVariant(self.get_bgcolor(index))
     elif role == Qt.FontRole:
         if index.column() < 3:
             return QVariant(get_font('dicteditor_header'))
         else:
             return QVariant(get_font('dicteditor'))
     return QVariant()
コード例 #3
0
 def createEditor(self, parent, option, index):
     """Overriding method createEditor"""
     if index.column() < 3:
         return None
     value = self.get_value(index)
     key = index.model().get_key(index)
     readonly = isinstance(value, tuple) or self.parent().readonly
     #---editor = DictEditor
     if isinstance(value, (list, tuple, dict)) and not self.inplace:
         editor = DictEditor(value,
                             key,
                             icon=self.parent().windowIcon(),
                             readonly=readonly)
         if editor.exec_() and not readonly:
             self.set_value(index, editor.get_copy())
         return None
     #---editor = ArrayEditor
     elif isinstance(value, ndarray) and ndarray is not FakeObject \
                                     and not self.inplace:
         if value.size == 0:
             return None
         editor = ArrayEditor(parent)
         if editor.setup_and_check(value, title=key, readonly=readonly):
             if editor.exec_():
                 # Only necessary for child class RemoteDictDelegate:
                 # (ArrayEditor does not make a copy of value)
                 self.set_value(index, value)
         return None
     #---editor = QDateTimeEdit
     elif isinstance(value, datetime.datetime) and not self.inplace:
         editor = QDateTimeEdit(value, parent)
         editor.setCalendarPopup(True)
         editor.setFont(get_font('dicteditor'))
         self.connect(editor, SIGNAL("returnPressed()"),
                      self.commitAndCloseEditor)
         return editor
     #---editor = QDateEdit
     elif isinstance(value, datetime.date) and not self.inplace:
         editor = QDateEdit(value, parent)
         editor.setCalendarPopup(True)
         editor.setFont(get_font('dicteditor'))
         self.connect(editor, SIGNAL("returnPressed()"),
                      self.commitAndCloseEditor)
         return editor
     #---editor = QTextEdit
     elif isinstance(value, (str, unicode)) and len(value) > 40:
         editor = TextEditor(value, key)
         if editor.exec_() and not readonly:
             conv = str if isinstance(value, str) else unicode
             self.set_value(index, conv(editor.get_copy()))
         return None
     #---editor = QLineEdit
     else:
         editor = QLineEdit(parent)
         editor.setFont(get_font('dicteditor'))
         editor.setAlignment(Qt.AlignLeft)
         self.connect(editor, SIGNAL("returnPressed()"),
                      self.commitAndCloseEditor)
         return editor
コード例 #4
0
ファイル: qtebase.py プロジェクト: vipmath/luminoso
 def setup(self):
     """Configure QTextEdit"""
     # Calltips
     self.calltip_size = CONF.get('shell_appearance', 'calltips/size')
     self.calltip_font = get_font('shell_appearance', 'calltips')
     # Completion
     self.completion_size = CONF.get('shell_appearance', 'completion/size')
     self.completion_font = get_font('shell_appearance', 'completion')
コード例 #5
0
ファイル: dicteditor.py プロジェクト: Brainsciences/luminoso
 def createEditor(self, parent, option, index):
     """Overriding method createEditor"""
     if index.column()<3:
         return None
     value = self.get_value(index)
     key = index.model().get_key(index)
     readonly = isinstance(value, tuple) or self.parent().readonly
     #---editor = DictEditor
     if isinstance(value, (list, tuple, dict)) and not self.inplace:
         editor = DictEditor(value, key, icon=self.parent().windowIcon(),
                             readonly=readonly)
         if editor.exec_() and not readonly:
             self.set_value(index, editor.get_copy())
         return None
     #---editor = ArrayEditor
     elif isinstance(value, ndarray) and ndarray is not FakeObject \
                                     and not self.inplace:
         if value.size == 0:
             return None
         editor = ArrayEditor(parent)
         if editor.setup_and_check(value, title=key, readonly=readonly):
             if editor.exec_():
                 # Only necessary for child class RemoteDictDelegate:
                 # (ArrayEditor does not make a copy of value)
                 self.set_value(index, value)
         return None
     #---editor = QDateTimeEdit
     elif isinstance(value, datetime.datetime) and not self.inplace:
         editor = QDateTimeEdit(value, parent)
         editor.setCalendarPopup(True)
         editor.setFont(get_font('dicteditor'))
         self.connect(editor, SIGNAL("returnPressed()"),
                      self.commitAndCloseEditor)
         return editor
     #---editor = QDateEdit
     elif isinstance(value, datetime.date) and not self.inplace:
         editor = QDateEdit(value, parent)
         editor.setCalendarPopup(True)
         editor.setFont(get_font('dicteditor'))
         self.connect(editor, SIGNAL("returnPressed()"),
                      self.commitAndCloseEditor)
         return editor
     #---editor = QTextEdit
     elif isinstance(value, (str, unicode)) and len(value)>40:
         editor = TextEditor(value, key)
         if editor.exec_() and not readonly:
             conv = str if isinstance(value, str) else unicode
             self.set_value(index, conv(editor.get_copy()))
         return None
     #---editor = QLineEdit
     else:
         editor = QLineEdit(parent)
         editor.setFont(get_font('dicteditor'))
         editor.setAlignment(Qt.AlignLeft)
         self.connect(editor, SIGNAL("returnPressed()"),
                      self.commitAndCloseEditor)
         return editor
コード例 #6
0
ファイル: qtebase.py プロジェクト: cheesinglee/spyder
 def setup(self):
     """Configure QPlainTextEdit"""
     # Calltips
     self.calltip_size = CONF.get('shell_appearance', 'calltips/size')
     self.calltip_font = get_font('shell_appearance', 'calltips')
     # Completion
     size = CONF.get('shell_appearance', 'completion/size')
     font = get_font('shell_appearance', 'completion')
     self.completion_widget.setup_appearance(size, font)
コード例 #7
0
ファイル: shell.py プロジェクト: jromang/retina-old
    def __init__(self, parent, history_filename, debug=False, profile=False):
        """
        parent : specifies the parent widget
        """
        ConsoleBaseWidget.__init__(self, parent)
                
        # Prompt position: tuple (line, index)
        self.current_prompt_pos = None
        self.new_input_line = True
        
        # History
        self.histidx = None
        self.hist_wholeline = False
        assert isinstance(history_filename, (str, unicode))
        self.history_filename = history_filename
        self.history = self.load_history()
        
        # Session
        self.historylog_filename = CONF.get('main', 'historylog_filename',
                                            get_conf_path('history.log'))
        
        # Context menu
        self.menu = None
        self.setup_context_menu()

        # Debug mode
        self.debug = debug

        # Simple profiling test
        self.profile = profile
        
        # Buffer to increase performance of write/flush operations
        self.__buffer = []
        self.__timestamp = 0.0
        self.__flushtimer = QTimer(self)
        self.__flushtimer.setSingleShot(True)
        self.connect(self.__flushtimer, SIGNAL('timeout()'), self.flush)

        # Give focus to widget
        self.setFocus()
                
        # Calltips
        calltip_size = CONF.get('shell_appearance', 'calltips/size')
        calltip_font = get_font('shell_appearance', 'calltips')
        self.setup_calltips(calltip_size, calltip_font)
        
        # Completion
        completion_size = CONF.get('shell_appearance', 'completion/size')
        completion_font = get_font('shell_appearance', 'completion')
        self.completion_widget.setup_appearance(completion_size,
                                                completion_font)
        # Cursor width
        self.setCursorWidth( CONF.get('shell_appearance', 'cursor/width') )
コード例 #8
0
ファイル: pylintgui.py プロジェクト: Brainsciences/luminoso
 def change_font(self):
     """Change font"""
     font, valid = QFontDialog.getFont(get_font(self.ID), self,
                               translate("Pylint", "Select a new font"))
     if valid:
         self.set_font(font)
         set_font(font, self.ID)
コード例 #9
0
ファイル: console.py プロジェクト: cheesinglee/spyder
 def change_font(self):
     """Change console font"""
     font, valid = QFontDialog.getFont(get_font(self.ID),
                    self, self.tr("Select a new font"))
     if valid:
         self.shell.set_font(font)
         set_font(font, self.ID)
コード例 #10
0
    def __init__(self, text, title='', font=None, parent=None,
                 readonly=False, size=(400, 300)):
        super(TextEditor, self).__init__(parent)
        
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        # Text edit
        self.edit = QTextEdit(parent)
        self.edit.setReadOnly(readonly)
        self.edit.setPlainText(text)
        if font is None:
            font = get_font('texteditor')
        self.edit.setFont(font)
        self.layout.addWidget(self.edit)

        # Buttons configuration
        buttons = QDialogButtonBox.Ok
        if not readonly:
            buttons = buttons | QDialogButtonBox.Cancel
        bbox = QDialogButtonBox(buttons)
        self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
        self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
        self.layout.addWidget(bbox)
        
        # Make the dialog act as a window
        self.setWindowFlags(Qt.Window)
        
        self.setWindowIcon(get_icon('edit.png'))
        self.setWindowTitle(self.tr("Text editor") + \
                            "%s" % (" - "+str(title) if str(title) else ""))
        self.resize(size[0], size[1])
コード例 #11
0
ファイル: __init__.py プロジェクト: Brainsciences/luminoso
 def change_font(self):
     """Change console font"""
     font, valid = QFontDialog.getFont(get_font(self.ID), self,
                                   translate("Editor", "Select a new font"))
     if valid:
         self.editor.set_font(font)
         set_font(font, self.ID)
コード例 #12
0
ファイル: console.py プロジェクト: vipmath/luminoso
 def change_font(self):
     """Change console font"""
     font, valid = QFontDialog.getFont(get_font(self.ID), self,
                                       self.tr("Select a new font"))
     if valid:
         self.shell.set_font(font)
         set_font(font, self.ID)
コード例 #13
0
ファイル: __init__.py プロジェクト: Brainsciences/luminoso
    def __init__(self, parent):
        PluginWidget.__init__(self, parent)

        # Read-only editor
        self.editor = QsciEditor(self)
        self.editor.setup_editor(linenumbers=False, language='py',
                                 code_folding=True)
        self.connect(self.editor, SIGNAL("focus_changed()"),
                     lambda: self.emit(SIGNAL("focus_changed()")))
        self.editor.setReadOnly(True)
        self.editor.set_font( get_font(self.ID) )
        self.editor.toggle_wrap_mode( CONF.get(self.ID, 'wrap') )
        
        # Add entries to read-only editor context-menu
        font_action = create_action(self, translate("Editor", "&Font..."), None,
                                    'font.png',
                                    translate("Editor", "Set font style"),
                                    triggered=self.change_font)
        wrap_action = create_action(self, translate("Editor", "Wrap lines"),
                                    toggled=self.toggle_wrap_mode)
        wrap_action.setChecked( CONF.get(self.ID, 'wrap') )
        self.editor.readonly_menu.addSeparator()
        add_actions(self.editor.readonly_menu, (font_action, wrap_action))
        
        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.set_editor(self.editor)
        self.find_widget.hide()
コード例 #14
0
ファイル: pylintgui.py プロジェクト: vipmath/luminoso
    def __init__(self, parent=None):
        PylintWidget.__init__(self,
                              parent=parent,
                              max_entries=CONF.get(self.ID, 'max_entries'))
        PluginMixin.__init__(self, parent)

        self.set_font(get_font(self.ID))
コード例 #15
0
ファイル: pylintgui.py プロジェクト: vipmath/luminoso
 def change_font(self):
     """Change font"""
     font, valid = QFontDialog.getFont(
         get_font(self.ID), self, translate("Pylint", "Select a new font"))
     if valid:
         self.set_font(font)
         set_font(font, self.ID)
コード例 #16
0
ファイル: history.py プロジェクト: cheesinglee/spyder
    def add_history(self, filename):
        """
        Add new history tab
        Slot for SIGNAL('add_history(QString)') emitted by shell instance
        """
        filename = encoding.to_unicode(filename)
        if filename in self.filenames:
            return
        editor = CodeEditor(self)
        if osp.splitext(filename)[1] == '.py':
            language = 'py'
            icon = get_icon('python.png')
        else:
            language = 'bat'
            icon = get_icon('cmdprompt.png')
        editor.setup_editor(linenumbers=False, language=language,
                            code_folding=True, scrollflagarea=False)
        self.connect(editor, SIGNAL("focus_changed()"),
                     lambda: self.emit(SIGNAL("focus_changed()")))
        editor.setReadOnly(True)
        editor.set_font( get_font(self.ID) )
        editor.toggle_wrap_mode( CONF.get(self.ID, 'wrap') )

        text, _ = encoding.read(filename)
        editor.set_text(text)
        editor.set_cursor_position('eof')
        
        self.editors.append(editor)
        self.filenames.append(filename)
        self.icons.append(icon)
        index = self.tabwidget.addTab(editor, osp.basename(filename))
        self.find_widget.set_editor(editor)
        self.tabwidget.setTabToolTip(index, filename)
        self.tabwidget.setTabIcon(index, icon)
        self.tabwidget.setCurrentIndex(index)
コード例 #17
0
ファイル: inspector.py プロジェクト: jromang/retina-old
 def change_font(self):
     """Change console font"""
     font, valid = QFontDialog.getFont(get_font(self.CONF_SECTION), self,
                                   _("Select a new font"))
     if valid:
         self.set_plain_text_font(font)
         set_font(font, self.CONF_SECTION)
コード例 #18
0
ファイル: externalconsole.py プロジェクト: vipmath/luminoso
 def change_font(self):
     """Change console font"""
     font, valid = QFontDialog.getFont(get_font(self.ID), self,
                                       self.tr("Select a new font"))
     if valid:
         for index in range(self.tabwidget.count()):
             self.tabwidget.widget(index).shell.set_font(font)
         set_font(font, self.ID)
コード例 #19
0
 def change_font(self):
     """Change console font"""
     font, valid = QFontDialog.getFont(get_font(self.ID),
                    self, self.tr("Select a new font"))
     if valid:
         for index in range(self.tabwidget.count()):
             self.tabwidget.widget(index).shell.set_font(font)
         set_font(font, self.ID)
コード例 #20
0
ファイル: history.py プロジェクト: vipmath/luminoso
 def change_font(self):
     """Change console font"""
     font, valid = QFontDialog.getFont(get_font(self.ID), self,
                                       self.tr("Select a new font"))
     if valid:
         for editor in self.editors:
             editor.set_font(font)
         set_font(font, self.ID)
コード例 #21
0
ファイル: history.py プロジェクト: cheesinglee/spyder
 def change_font(self):
     """Change console font"""
     font, valid = QFontDialog.getFont(get_font(self.ID),
                    self, self.tr("Select a new font"))
     if valid:
         for editor in self.editors:
             editor.set_font(font)
         set_font(font, self.ID)
コード例 #22
0
    def __init__(self, parent=None, path=None):
        ExplorerWidget.__init__(self, parent=parent, path=path,
                            name_filters=CONF.get(self.ID, 'name_filters'),
                            valid_types=CONF.get(self.ID, 'valid_filetypes'),
                            show_all=CONF.get(self.ID, 'show_all'),
                            show_toolbar=CONF.get(self.ID, 'show_toolbar'),
                            show_icontext=CONF.get(self.ID, 'show_icontext'))
        PluginMixin.__init__(self, parent)

        self.set_font(get_font(self.ID))
        
        self.connect(self, SIGNAL("open_file(QString)"), self.open_file)
コード例 #23
0
ファイル: explorer.py プロジェクト: cheesinglee/spyder
    def __init__(self, parent=None):
        ExplorerWidget.__init__(self, parent=parent,
                            path=CONF.get(self.ID, 'path', None),
                            name_filters=CONF.get(self.ID, 'name_filters'),
                            valid_types=CONF.get(self.ID, 'valid_filetypes'),
                            show_all=CONF.get(self.ID, 'show_all'),
                            show_toolbar=CONF.get(self.ID, 'show_toolbar'),
                            show_icontext=CONF.get(self.ID, 'show_icontext'))
        SpyderPluginMixin.__init__(self, parent)

        self.editor_valid_types = None
        
        self.set_font(get_font(self.ID))
        
        self.connect(self, SIGNAL("open_file(QString)"), self.open_file)
コード例 #24
0
 def headerData(self, section, orientation, role=Qt.DisplayRole):
     """Overriding method headerData"""
     if role != Qt.DisplayRole:
         if role == Qt.FontRole:
             return QVariant(get_font('dicteditor_header'))
         else:
             return QVariant()
     i_column = int(section)
     if orientation == Qt.Horizontal:
         headers = (self.header0, translate("DictEditor", "Type"),
                    translate("DictEditor",
                              "Size"), translate("DictEditor", "Value"))
         return QVariant(headers[i_column])
     else:
         return QVariant()
コード例 #25
0
ファイル: arrayeditor.py プロジェクト: vipmath/luminoso
 def createEditor(self, parent, option, index):
     """Create editor widget"""
     model = index.model()
     if model._data.dtype.name == "bool":
         value = not model.get_value(index)
         model.setData(index, QVariant(value))
         return
     else:
         editor = QLineEdit(parent)
         editor.setFont(get_font('arrayeditor'))
         editor.setAlignment(Qt.AlignCenter)
         if is_number(self.dtype):
             editor.setValidator(QDoubleValidator(editor))
         self.connect(editor, SIGNAL("returnPressed()"),
                      self.commitAndCloseEditor)
         return editor
コード例 #26
0
ファイル: arrayeditor.py プロジェクト: cheesinglee/spyder
 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return QVariant()
     value = self.get_value(index)
     if role == Qt.DisplayRole:
         return QVariant(self._format % value)
     elif role == Qt.TextAlignmentRole:
         return QVariant(int(Qt.AlignCenter|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole and self.bgcolor_enabled:
         hue = self.hue0+self.dhue*(self.vmax-value)/(self.vmax-self.vmin)
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
         return QVariant(color)
     elif role == Qt.FontRole:
         return QVariant(get_font('arrayeditor'))
     return QVariant()
コード例 #27
0
ファイル: arrayeditor.py プロジェクト: cheesinglee/spyder
 def createEditor(self, parent, option, index):
     """Create editor widget"""
     model = index.model()
     if model._data.dtype.name == "bool":
         value = not model.get_value(index)
         model.setData(index, QVariant(value))
         return
     else:
         editor = QLineEdit(parent)
         editor.setFont(get_font('arrayeditor'))
         editor.setAlignment(Qt.AlignCenter)
         if is_number(self.dtype):
             editor.setValidator(QDoubleValidator(editor))
         self.connect(editor, SIGNAL("returnPressed()"),
                      self.commitAndCloseEditor)
         return editor
コード例 #28
0
ファイル: explorer.py プロジェクト: Sandy4321/luminoso
    def __init__(self, parent=None, path=None):
        ExplorerWidget.__init__(
            self,
            parent=parent,
            path=path,
            name_filters=CONF.get(self.ID, "name_filters"),
            valid_types=CONF.get(self.ID, "valid_filetypes"),
            show_all=CONF.get(self.ID, "show_all"),
            show_toolbar=CONF.get(self.ID, "show_toolbar"),
            show_icontext=CONF.get(self.ID, "show_icontext"),
        )
        PluginMixin.__init__(self, parent)

        self.set_font(get_font(self.ID))

        self.connect(self, SIGNAL("open_file(QString)"), self.open_file)
コード例 #29
0
ファイル: dicteditor.py プロジェクト: cheesinglee/spyder
 def headerData(self, section, orientation, role=Qt.DisplayRole):
     """Overriding method headerData"""
     if role != Qt.DisplayRole:
         if role == Qt.FontRole:
             return QVariant(get_font('dicteditor_header'))
         else:
             return QVariant()
     i_column = int(section)
     if orientation == Qt.Horizontal:
         headers = (self.header0,
                    translate("DictEditor", "Type"),
                    translate("DictEditor", "Size"),
                    translate("DictEditor", "Value"))
         return QVariant( headers[i_column] )
     else:
         return QVariant()
コード例 #30
0
ファイル: arrayeditor.py プロジェクト: vipmath/luminoso
 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return QVariant()
     value = self.get_value(index)
     if role == Qt.DisplayRole:
         return QVariant(self._format % value)
     elif role == Qt.TextAlignmentRole:
         return QVariant(int(Qt.AlignCenter | Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole and self.bgcolor_enabled:
         hue = self.hue0 + self.dhue * (self.vmax - value) / (self.vmax -
                                                              self.vmin)
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
         return QVariant(color)
     elif role == Qt.FontRole:
         return QVariant(get_font('arrayeditor'))
     return QVariant()
コード例 #31
0
ファイル: projectexplorer.py プロジェクト: cheesinglee/spyder
    def __init__(self, parent=None):
        self.new_project_action = None
        include = CONF.get(self.ID, 'include', '.')
        exclude = CONF.get(self.ID, 'exclude', r'\.pyc$|\.pyo$|\.orig$|^\.')
        show_all = CONF.get(self.ID, 'show_all', False)
        ProjectExplorerWidget.__init__(self, parent=parent, include=include,
                                       exclude=exclude, show_all=show_all)
        SpyderPluginMixin.__init__(self, parent)

        self.editor_valid_types = None

        self.set_font(get_font(self.ID))
        
        if osp.isfile(self.DATAPATH):
            self.load_config()

        self.connect(self, SIGNAL("open_file(QString)"), self.open_file)
コード例 #32
0
ファイル: workspace.py プロジェクト: Brainsciences/luminoso
 def __init__(self, parent):
     self.interpreter = None
     self.namespace = None
     self.filename = None
     truncate = CONF.get(self.ID, 'truncate')
     inplace = CONF.get(self.ID, 'inplace')
     minmax = CONF.get(self.ID, 'minmax')
     collvalue = CONF.get(self.ID, 'collvalue')
     DictEditorTableView.__init__(self, parent, None, names=True,
                                  truncate=truncate, inplace=inplace,
                                  minmax=minmax, collvalue=collvalue)
     PluginMixin.__init__(self, parent)
     
     self.setup_io()
     self.load_temp_namespace()
     
     self.setFont(get_font(self.ID))
コード例 #33
0
ファイル: console.py プロジェクト: vipmath/luminoso
    def __init__(self,
                 parent=None,
                 namespace=None,
                 commands=None,
                 message="",
                 debug=False,
                 exitfunc=None,
                 profile=False):
        # Shell
        self.shell = InteractiveShell(parent, namespace, commands, message,
                                      get_font(self.ID), debug, exitfunc,
                                      profile)
        self.connect(
            self.shell, SIGNAL('status(QString)'),
            lambda msg: self.emit(SIGNAL('show_message(QString,int)'), msg, 0))
        self.connect(self.shell, SIGNAL("go_to_error(QString)"),
                     self.go_to_error)
        self.connect(self.shell, SIGNAL("focus_changed()"),
                     lambda: self.emit(SIGNAL("focus_changed()")))
        # Redirecting some SIGNALs:
        self.connect(
            self.shell, SIGNAL('redirect_stdio(bool)'),
            lambda state: self.emit(SIGNAL('redirect_stdio(bool)'), state))

        PluginWidget.__init__(self, parent)

        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.set_editor(self.shell)
        self.find_widget.hide()

        # Main layout
        layout = QVBoxLayout()
        layout.addWidget(self.shell)
        layout.addWidget(self.find_widget)
        self.setLayout(layout)

        # Parameters
        self.shell.toggle_wrap_mode(CONF.get(self.ID, 'wrap'))

        self.connect(self, SIGNAL("executing_command(bool)"),
                     self.change_cursor)

        # Accepting drops
        self.setAcceptDrops(True)
コード例 #34
0
ファイル: texteditor.py プロジェクト: jromang/retina-old
    def __init__(self, text, title='', font=None, parent=None,
                 readonly=False, size=(400, 300)):
        QDialog.__init__(self, parent)
        
        # Destroying the C++ object right after closing the dialog box,
        # otherwise it may be garbage-collected in another QThread
        # (e.g. the editor's analysis thread in Spyder), thus leading to
        # a segmentation fault on UNIX or an application crash on Windows
        self.setAttribute(Qt.WA_DeleteOnClose)
        
        self.text = None
        
        self._conv = str if isinstance(text, str) else unicode
        
        self.layout = QVBoxLayout()
        self.setLayout(self.layout)

        # Text edit
        self.edit = QTextEdit(parent)
        self.connect(self.edit, SIGNAL('textChanged()'), self.text_changed)
        self.edit.setReadOnly(readonly)
        self.edit.setPlainText(text)
        if font is None:
            font = get_font('texteditor')
        self.edit.setFont(font)
        self.layout.addWidget(self.edit)

        # Buttons configuration
        buttons = QDialogButtonBox.Ok
        if not readonly:
            buttons = buttons | QDialogButtonBox.Cancel
        bbox = QDialogButtonBox(buttons)
        self.connect(bbox, SIGNAL("accepted()"), SLOT("accept()"))
        self.connect(bbox, SIGNAL("rejected()"), SLOT("reject()"))
        self.layout.addWidget(bbox)
        
        # Make the dialog act as a window
        self.setWindowFlags(Qt.Window)
        
        self.setWindowIcon(get_icon('edit.png'))
        self.setWindowTitle(_("Text editor") + \
                            "%s" % (" - "+str(title) if str(title) else ""))
        self.resize(size[0], size[1])
コード例 #35
0
 def setup(self):
     """Configure Scintilla"""
     # UTF-8
     self.setUtf8(True)
     
     # Indentation
     self.setAutoIndent(True)
     self.setIndentationsUseTabs(False)
     self.setIndentationWidth(4)
     self.setTabIndents(True)
     self.setBackspaceUnindents(True)
     self.setTabWidth(4)
     
     # Enable brace matching
     self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
     self.setMatchedBraceBackgroundColor(Qt.yellow)
     
     # Calltips
     self.calltip_size = CONF.get('shell_appearance', 'calltips/size')
     self.calltip_font = get_font('shell_appearance', 'calltips')
コード例 #36
0
ファイル: qscibase.py プロジェクト: cheesinglee/spyder
 def setup(self):
     """Configure Scintilla"""
     # UTF-8
     self.setUtf8(True)
     
     # Indentation
     self.setAutoIndent(True)
     self.setIndentationsUseTabs(False)
     self.setIndentationWidth(4)
     self.setTabIndents(True)
     self.setBackspaceUnindents(True)
     self.setTabWidth(4)
     
     # Enable brace matching
     self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
     self.setMatchedBraceBackgroundColor(Qt.yellow)
     
     # Calltips
     self.calltip_size = CONF.get('shell_appearance', 'calltips/size')
     self.calltip_font = get_font('shell_appearance', 'calltips')
コード例 #37
0
ファイル: console.py プロジェクト: Brainsciences/luminoso
    def __init__(self, parent=None, namespace=None, commands=None, message="",
                 debug=False, exitfunc=None, profile=False):
        # Shell
        self.shell = InteractiveShell(parent, namespace, commands, message,
                                      get_font(self.ID),
                                      debug, exitfunc, profile)
        self.connect(self.shell, SIGNAL('status(QString)'),
                     lambda msg:
                     self.emit(SIGNAL('show_message(QString,int)'), msg, 0))
        self.connect(self.shell, SIGNAL("go_to_error(QString)"),
                     self.go_to_error)
        self.connect(self.shell, SIGNAL("focus_changed()"),
                     lambda: self.emit(SIGNAL("focus_changed()")))
        # Redirecting some SIGNALs:
        self.connect(self.shell, SIGNAL('redirect_stdio(bool)'),
                     lambda state: self.emit(SIGNAL('redirect_stdio(bool)'),
                                             state))
        
        PluginWidget.__init__(self, parent)
        
        # Find/replace widget
        self.find_widget = FindReplace(self)
        self.find_widget.set_editor(self.shell)
        self.find_widget.hide()

        # Main layout
        layout = QVBoxLayout()
        layout.addWidget(self.shell)
        layout.addWidget(self.find_widget)
        self.setLayout(layout)
        
        # Parameters
        self.shell.toggle_wrap_mode( CONF.get(self.ID, 'wrap') )
        
        self.connect(self, SIGNAL("executing_command(bool)"),
                     self.change_cursor)
            
        # Accepting drops
        self.setAcceptDrops(True)
コード例 #38
0
ファイル: workspace.py プロジェクト: vipmath/luminoso
    def __init__(self, parent):
        self.interpreter = None
        self.namespace = None
        self.filename = None
        truncate = CONF.get(self.ID, 'truncate')
        inplace = CONF.get(self.ID, 'inplace')
        minmax = CONF.get(self.ID, 'minmax')
        collvalue = CONF.get(self.ID, 'collvalue')
        DictEditorTableView.__init__(self,
                                     parent,
                                     None,
                                     names=True,
                                     truncate=truncate,
                                     inplace=inplace,
                                     minmax=minmax,
                                     collvalue=collvalue)
        PluginMixin.__init__(self, parent)

        self.setup_io()
        self.load_temp_namespace()

        self.setFont(get_font(self.ID))
コード例 #39
0
ファイル: arrayeditor.py プロジェクト: jromang/retina-old
 def data(self, index, role=Qt.DisplayRole):
     """Cell content"""
     if not index.isValid():
         return to_qvariant()
     value = self.get_value(index)
     if role == Qt.DisplayRole:
         if value is np.ma.masked:
             return ''
         else:
             return to_qvariant(self._format % value)
     elif role == Qt.TextAlignmentRole:
         return to_qvariant(int(Qt.AlignCenter|Qt.AlignVCenter))
     elif role == Qt.BackgroundColorRole and self.bgcolor_enabled\
          and value is not np.ma.masked:
         hue = self.hue0+\
               self.dhue*(self.vmax-self.color_func(value))\
               /(self.vmax-self.vmin)
         hue = float(np.abs(hue))
         color = QColor.fromHsvF(hue, self.sat, self.val, self.alp)
         return to_qvariant(color)
     elif role == Qt.FontRole:
         return to_qvariant(get_font('arrayeditor'))
     return to_qvariant()
コード例 #40
0
ファイル: history.py プロジェクト: vipmath/luminoso
    def add_history(self, filename):
        """
        Add new history tab
        Slot for SIGNAL('add_history(QString)') emitted by shell instance
        """
        filename = encoding.to_unicode(filename)
        if filename in self.filenames:
            return
        editor = QsciEditor(self)
        if osp.splitext(filename)[1] == '.py':
            language = 'py'
            icon = get_icon('python.png')
        else:
            language = 'bat'
            icon = get_icon('cmdprompt.png')
        editor.setup_editor(linenumbers=False,
                            language=language,
                            code_folding=True)
        self.connect(editor, SIGNAL("focus_changed()"),
                     lambda: self.emit(SIGNAL("focus_changed()")))
        editor.setReadOnly(True)
        editor.set_font(get_font(self.ID))
        editor.toggle_wrap_mode(CONF.get(self.ID, 'wrap'))

        text, _ = encoding.read(filename)
        editor.set_text(text)
        editor.set_cursor_position('eof')

        self.editors.append(editor)
        self.filenames.append(filename)
        self.icons.append(icon)
        index = self.tabwidget.addTab(editor, osp.basename(filename))
        self.find_widget.set_editor(editor)
        self.tabwidget.setTabToolTip(index, filename)
        self.tabwidget.setTabIcon(index, icon)
        self.tabwidget.setCurrentIndex(index)
コード例 #41
0
    def start(self, fname, wdir=None, ask_for_arguments=False,
              interact=False, debug=False, python=True):
        """Start new console"""
        # Note: fname is None <=> Python interpreter
        fname = unicode(fname) if isinstance(fname, QString) else fname
        wdir = unicode(wdir) if isinstance(wdir, QString) else wdir

        if fname is not None and fname in self.filenames:
            index = self.filenames.index(fname)
            if CONF.get(self.ID, 'single_tab'):
                old_shell = self.shells[index]
                if old_shell.is_running():
                    answer = QMessageBox.question(self, self.get_widget_title(),
                        self.tr("%1 is already running in a separate process.\n"
                                "Do you want to kill the process before starting "
                                "a new one?").arg(osp.basename(fname)),
                        QMessageBox.Yes | QMessageBox.Cancel)
                    if answer == QMessageBox.Yes:
                        old_shell.process.kill()
                        old_shell.process.waitForFinished()
                    else:
                        return
                self.close_console(index)
        else:
            index = 0

        # Creating a new external shell
        if python:
            shell = ExternalPythonShell(self, fname, wdir, self.commands,
                                        interact, debug, path=self.main.path)
        else:
            shell = ExternalSystemShell(self, wdir)
        shell.shell.set_font( get_font(self.ID) )
        shell.shell.toggle_wrap_mode( CONF.get(self.ID, 'wrap') )
        shell.shell.set_calltips( CONF.get(self.ID, 'calltips') )
        shell.shell.set_codecompletion( CONF.get(self.ID,
                                                 'autocompletion/enabled') )
        shell.shell.set_codecompletion_enter(CONF.get(self.ID,
                                                 'autocompletion/enter-key'))
        if python:
            shell.shell.set_docviewer(self.docviewer)
        self.historylog.add_history(shell.shell.history_filename)
        self.connect(shell.shell, SIGNAL('append_to_history(QString,QString)'),
                     self.historylog.append_to_history)
        self.connect(shell.shell, SIGNAL("go_to_error(QString)"),
                     self.go_to_error)
        self.connect(shell.shell, SIGNAL("focus_changed()"),
                     lambda: self.emit(SIGNAL("focus_changed()")))
        if python:
            if fname is None:
                name = "Python"
                icon = get_icon('python.png')
            else:
                name = osp.basename(fname)
                icon = get_icon('run.png')
        else:
            name = "Command Window"
            icon = get_icon('cmdprompt.png')
        self.shells.insert(index, shell)
        self.filenames.insert(index, fname)
        self.icons.insert(index, icon)
        if index is None:
            index = self.tabwidget.addTab(shell, name)
        else:
            self.tabwidget.insertTab(index, shell, name)
        
        self.connect(shell, SIGNAL("started()"),
                     lambda sid=id(shell): self.process_started(sid))
        self.connect(shell, SIGNAL("finished()"),
                     lambda sid=id(shell): self.process_finished(sid))
        self.find_widget.set_editor(shell.shell)
        self.tabwidget.setTabToolTip(index, fname if wdir is None else wdir)
        self.tabwidget.setCurrentIndex(index)
        if self.dockwidget and not self.ismaximized:
            self.dockwidget.setVisible(True)
            self.dockwidget.raise_()
        
        # Start process and give focus to console
        shell.start(ask_for_arguments)
        shell.shell.setFocus()
コード例 #42
0
ファイル: externalconsole.py プロジェクト: vipmath/luminoso
    def start(self,
              fname,
              wdir=None,
              ask_for_arguments=False,
              interact=False,
              debug=False,
              python=True):
        """Start new console"""
        # Note: fname is None <=> Python interpreter
        fname = unicode(fname) if isinstance(fname, QString) else fname
        wdir = unicode(wdir) if isinstance(wdir, QString) else wdir

        if fname is not None and fname in self.filenames:
            index = self.filenames.index(fname)
            if CONF.get(self.ID, 'single_tab'):
                old_shell = self.shells[index]
                if old_shell.is_running():
                    answer = QMessageBox.question(
                        self, self.get_widget_title(),
                        self.tr(
                            "%1 is already running in a separate process.\n"
                            "Do you want to kill the process before starting "
                            "a new one?").arg(osp.basename(fname)),
                        QMessageBox.Yes | QMessageBox.Cancel)
                    if answer == QMessageBox.Yes:
                        old_shell.process.kill()
                        old_shell.process.waitForFinished()
                    else:
                        return
                self.close_console(index)
        else:
            index = 0

        # Creating a new external shell
        if python:
            shell = ExternalPythonShell(self,
                                        fname,
                                        wdir,
                                        self.commands,
                                        interact,
                                        debug,
                                        path=self.main.path)
        else:
            shell = ExternalSystemShell(self, wdir)
        shell.shell.set_font(get_font(self.ID))
        shell.shell.toggle_wrap_mode(CONF.get(self.ID, 'wrap'))
        shell.shell.set_calltips(CONF.get(self.ID, 'calltips'))
        shell.shell.set_codecompletion(
            CONF.get(self.ID, 'autocompletion/enabled'))
        shell.shell.set_codecompletion_enter(
            CONF.get(self.ID, 'autocompletion/enter-key'))
        if python:
            shell.shell.set_docviewer(self.docviewer)
        self.historylog.add_history(shell.shell.history_filename)
        self.connect(shell.shell, SIGNAL('append_to_history(QString,QString)'),
                     self.historylog.append_to_history)
        self.connect(shell.shell, SIGNAL("go_to_error(QString)"),
                     self.go_to_error)
        self.connect(shell.shell, SIGNAL("focus_changed()"),
                     lambda: self.emit(SIGNAL("focus_changed()")))
        if python:
            if fname is None:
                name = "Python"
                icon = get_icon('python.png')
            else:
                name = osp.basename(fname)
                icon = get_icon('run.png')
        else:
            name = "Command Window"
            icon = get_icon('cmdprompt.png')
        self.shells.insert(index, shell)
        self.filenames.insert(index, fname)
        self.icons.insert(index, icon)
        if index is None:
            index = self.tabwidget.addTab(shell, name)
        else:
            self.tabwidget.insertTab(index, shell, name)

        self.connect(shell,
                     SIGNAL("started()"),
                     lambda sid=id(shell): self.process_started(sid))
        self.connect(shell,
                     SIGNAL("finished()"),
                     lambda sid=id(shell): self.process_finished(sid))
        self.find_widget.set_editor(shell.shell)
        self.tabwidget.setTabToolTip(index, fname if wdir is None else wdir)
        self.tabwidget.setCurrentIndex(index)
        if self.dockwidget and not self.ismaximized:
            self.dockwidget.setVisible(True)
            self.dockwidget.raise_()

        # Start process and give focus to console
        shell.start(ask_for_arguments)
        shell.shell.setFocus()
コード例 #43
0
ファイル: figure.py プロジェクト: Brainsciences/luminoso
 def set_statusbar(self):
     """Set status bar"""
     statusbar = QLabel('')
     statusbar.setFont(get_font(self.ID, 'statusbar'))
     return statusbar
コード例 #44
0
ファイル: workspace.py プロジェクト: Brainsciences/luminoso
 def __change_font(self, section):
     font, valid = QFontDialog.getFont(get_font(section), self,
                                       self.tr("Select a new font"))
     if valid:
         set_font(font, section)
コード例 #45
0
ファイル: pylintgui.py プロジェクト: Brainsciences/luminoso
    def __init__(self, parent=None):
        PylintWidget.__init__(self, parent=parent,
                              max_entries=CONF.get(self.ID, 'max_entries'))
        PluginMixin.__init__(self, parent)

        self.set_font(get_font(self.ID))
コード例 #46
0
ファイル: __init__.py プロジェクト: jromang/retina-old
 def get_plugin_font(self, option=None):
     """Return plugin font option"""
     return get_font(self.CONF_SECTION, option)
コード例 #47
0
ファイル: workspace.py プロジェクト: vipmath/luminoso
 def __change_font(self, section):
     font, valid = QFontDialog.getFont(get_font(section), self,
                                       self.tr("Select a new font"))
     if valid:
         set_font(font, section)