mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge Christoph Holtermann's 'python-shell-access-outer-variables' into maint.
This commit is contained in:
@@ -43,8 +43,9 @@ class Console (cons.Console):
|
||||
""" GTK python console """
|
||||
|
||||
def __init__(self, argv=[], shelltype='python', banner=[],
|
||||
filename=None, size=100):
|
||||
cons.Console.__init__(self, argv, shelltype, banner, filename, size)
|
||||
filename=None, size=100, user_local_ns=None, user_global_ns=None):
|
||||
cons.Console.__init__(self, argv, shelltype, banner, filename, size,
|
||||
user_local_ns=user_local_ns, user_global_ns=user_global_ns)
|
||||
self.buffer.create_tag('center',
|
||||
justification=Gtk.Justification.CENTER,
|
||||
font='Mono 4')
|
||||
@@ -101,12 +102,15 @@ if False:
|
||||
title = "gnucash "+shelltype+" shell"
|
||||
banner_style = 'title'
|
||||
banner = "Welcome to "+title+"!\n"
|
||||
console = Console(argv = [], shelltype = shelltype, banner = [[banner, banner_style]], size = 100)
|
||||
|
||||
window = Gtk.Window(type = Gtk.WindowType.TOPLEVEL)
|
||||
window.set_position(Gtk.WindowPosition.CENTER)
|
||||
window.set_default_size(800,600)
|
||||
window.set_border_width(0)
|
||||
|
||||
console = Console(argv = [], shelltype = shelltype, banner = [[banner, banner_style]],
|
||||
size = 100, user_local_ns=locals(), user_global_ns=globals())
|
||||
|
||||
window.connect('destroy-event', console.quit_event)
|
||||
window.connect('delete-event', console.quit_event)
|
||||
window.add (console)
|
||||
|
||||
@@ -126,7 +126,7 @@ class Console (Gtk.ScrolledWindow):
|
||||
""" GTK python console """
|
||||
|
||||
def __init__(self, argv=[], shelltype='python', banner=[],
|
||||
filename=None, size=100):
|
||||
filename=None, size=100, user_local_ns=None, user_global_ns=None):
|
||||
|
||||
""" Console interface building + initialization"""
|
||||
|
||||
@@ -184,12 +184,18 @@ class Console (Gtk.ScrolledWindow):
|
||||
self.history_init(filename, size)
|
||||
self.cout = io.StringIO()
|
||||
self.cout.truncate(0)
|
||||
|
||||
if not user_local_ns:
|
||||
user_local_ns = locals()
|
||||
if not user_global_ns:
|
||||
user_global_ns = globals()
|
||||
|
||||
if shelltype=='ipython':
|
||||
self.shell = ishell.Shell(argv,locals(),globals(),
|
||||
self.shell = ishell.Shell(argv,user_local_ns, user_global_ns,
|
||||
cout=self.cout, cerr=self.cout,
|
||||
input_func=self.raw_input)
|
||||
else:
|
||||
self.shell = shell.Shell(locals(),globals())
|
||||
self.shell = shell.Shell(user_local_ns,user_global_ns)
|
||||
self.interrupt = False
|
||||
self.input_mode = False
|
||||
self.input = None
|
||||
|
||||
Reference in New Issue
Block a user