def test(): from spyderlib.utils.qthelpers import qapplication app = qapplication() from spyderlib.widgets.externalshell.pythonshell import ExternalPythonShell from spyderlib.widgets.externalshell.systemshell import ExternalSystemShell import spyderlib from spyderlib.plugins.variableexplorer import VariableExplorer settings = VariableExplorer.get_settings() shell = ExternalPythonShell(wdir=osp.dirname(spyderlib.__file__), ipykernel=True, stand_alone=settings, arguments="-q4thread -pylab -colors LightBG", light_background=False) # shell = ExternalPythonShell(wdir=osp.dirname(spyderlib.__file__), # interact=True, umr_enabled=True, # stand_alone=settings, # umr_namelist=['guidata', 'guiqwt'], # umr_verbose=True, light_background=False) # shell = ExternalSystemShell(wdir=osp.dirname(spyderlib.__file__), # light_background=False) shell.shell.toggle_wrap_mode(True) shell.start_shell(False) from spyderlib.qt.QtGui import QFont font = QFont("Lucida console") font.setPointSize(10) shell.shell.set_font(font) shell.show() sys.exit(app.exec_())
def test(): from spyderlib.widgets.externalshell.pythonshell import ExternalPythonShell from spyderlib.widgets.externalshell.systemshell import ExternalSystemShell app = QApplication(sys.argv) import spyderlib shell = ExternalPythonShell(wdir=osp.dirname(spyderlib.__file__), interact=True) # shell = ExternalSystemShell(wdir=osp.dirname(spyderlib.__file__)) shell.shell.toggle_wrap_mode(True) shell.start(False) from PyQt4.QtGui import QFont font = QFont("Lucida console") font.setPointSize(10) shell.shell.set_font(font) shell.show() sys.exit(app.exec_())
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()