File: ipythonShell.py

package info (click to toggle)
psychopy 2020.2.10%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 44,056 kB
  • sloc: python: 119,649; javascript: 3,022; makefile: 148; sh: 125; xml: 9
file content (55 lines) | stat: -rw-r--r-- 2,211 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import absolute_import, print_function

import wx
import IPython.gui.wx.ipython_view


class ShellFrame(wx.Frame):
    def __init__(self, parent, ID, title, files=None, app=None):
        self.app = app
        self.frameType = 'shell'
        # things the user doesn't set like winsize etc
        self.appData = self.app.prefs.appData['coder']
        self.prefs = self.app.prefs.coder
        self.appPrefs = self.app.prefs.app
        self.paths = self.app.prefs.paths
        self.IDs = self.app.IDs

        wx.Frame.__init__(self, parent, ID, title, size=((600, 400)))
        self.sizer = wx.BoxSizer()

        IPShell = IPython.gui.wx.ipython_view.IPShellWidget
        self.ipython = IPShell(parent=self, background_color='WHITE',)
        # turn off threading - interferes with pygame thread
        self.ipython.options['threading']['value'] = 'False'
        tracker = self.ipython.updateOptionTracker
        self.ipython.IP.set_threading(False)
        self.ipython.threading_option.SetValue(False)
        # allow a write fmethod for the window
        self.ipython.cout.write = self.ipython.text_ctrl.write
        self.ipython.write = self.ipython.text_ctrl.write

        # set background to white
        # this setting isn't used by __init__ apparently
        self.ipython.options['background_color']['value'] = 'WHITE'
        self.ipython.text_ctrl.setBackgroundColor(
            self.ipython.options['background_color']['value'])
        self.ipython.background_option.SetValue(True)
        tracker('background_color',
                self.ipython.options['background_color']['value'])
        # scintilla autocompletion method
        self.ipython.completion_option.SetValue(True)
        self.ipython.options['completion']['value'] = 'STC'
        self.ipython.text_ctrl.setCompletionMethod(
            self.ipython.options['completion']['value'])
        tracker('completion', self.ipython.options['completion']['value'])
        self.ipython.text_ctrl.SetFocus()

        self.sizer.Add(self.ipython, 0, wx.EXPAND)
        self.SendSizeEvent()

        self.SetSizerAndFit(self.sizer)
        self.SetAutoLayout(1)