File: start_editra.py

package info (click to toggle)
python-envisageplugins 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,600 kB
  • sloc: python: 6,968; sh: 11; makefile: 8; lisp: 1
file content (45 lines) | stat: -rw-r--r-- 1,349 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
""" Provides a platform indepedent way to launch Editra. Code mostly copied
    from Editra run file (/usr/bin/editra) in Ubuntu wx package.
"""

import sys
import os

try:
    import Editra as Editra_root
    sys.path.insert(0, os.path.join(os.path.dirname(Editra_root.__file__),
                    'src'))
    # Really ugly: we need to remove the Editra name from the list of
    # imported modules
    sys.modules.pop('Editra')
except ImportError:
    import wx.tools

    # Editra needs its src package to be on the sys.path for plugins and
    # such to work right, so put it there before we do the first import of
    # any Editra package or module.
    sys.path.insert(0, os.path.join(os.path.dirname(wx.tools.__file__),
                                    'Editra', 'src'))

import Editra

# XXX: Super ugly: monkey-patch the main Editra class to add our plugins
old_MainLoop = Editra.Editra.MainLoop

def my_MainLoop(self, *args, **kwargs):
    from enthought.plugins.remote_editor.editor_plugins.editra.editra_plugin \
            import RemoteEditorPlugin
    plugin = RemoteEditorPlugin(Editra=self)
    try:
        plugin.do_PlugIt()
        old_MainLoop(self, *args, **kwargs)
    finally:
        plugin.client.unregister()

Editra.Editra.MainLoop = my_MainLoop

def main():
    Editra.Main()

if __name__ == '__main__':
    main()