3 from gnucash
import _sw_app_utils
4 from gnucash
import _sw_core_utils
5 from gnucash._sw_core_utils
import gnc_prefs_is_extra_enabled, gnc_prefs_is_debugging_enabled
6 from gi
import require_version
7 require_version(
'Gtk',
'3.0')
8 from gi.repository
import Gtk
11 sys.path.append(os.path.dirname(__file__))
15 if gnc_prefs_is_extra_enabled():
16 print(
"Python shell init file: %s" % (__file__))
17 print(
"\n" +
"The following string should appear translated in your preferred language:" +
"\n")
18 print(
"\n" + _(
"Welcome to GnuCash") +
"\n")
24 old_sigttou = signal.signal(signal.SIGTTOU, signal.SIG_IGN)
29 signal.signal(signal.SIGTTOU, old_sigttou)
33 if gnc_prefs_is_extra_enabled()
and gnc_prefs_is_debugging_enabled():
34 print(
"Hello from python!\n")
35 print(
"sys.modules.keys(): ", sys.modules.keys(),
"\n")
36 print(
"dir(_sw_app_utils): ", dir(_sw_app_utils),
"\n")
42 print(
"dir(gnucash_core_c): ", dir(gnucash_core_c))
53 """ GTK python console """ 55 def __init__(self, argv=[], shelltype='python', banner=[],
56 filename=None, size=100, user_local_ns=None, user_global_ns=None):
57 cons.Console.__init__(self, argv, shelltype, banner, filename, size,
58 user_local_ns=user_local_ns, user_global_ns=user_global_ns)
59 self.buffer.create_tag(
'center',
60 justification=Gtk.Justification.CENTER,
72 """ Handle key press event """ 77 return cons.Console.key_press_event (self, widget, event)
86 """ Button press event """ 90 """ Event handler for closing of console window """ 94 """ Refresh drawing """ 96 figure, canvas, anchor = fig
103 self.write(
"\n" + _(
"Have a nice day!") +
"\n")
104 return super(Console, self).
quit()
112 if shelltype==
"python":
113 shelltypeName =
"Python" 115 shelltypeName =
"IPython" 116 banner_style =
'title' 118 banner = _(
"Welcome to GnuCash %s Shell") % shelltypeName
119 console =
Console(argv = [], shelltype = shelltype, banner = [[banner, banner_style]], size = 100)
121 window = Gtk.Window(type = Gtk.WindowType.TOPLEVEL)
122 window.set_position(Gtk.WindowPosition.CENTER)
123 window.set_default_size(800,600)
124 window.set_border_width(0)
126 console =
Console(argv = [], shelltype = shelltype, banner = [[banner, banner_style]],
127 size = 100, user_local_ns=locals(), user_global_ns=globals())
129 window.connect(
'destroy-event', console.quit_event)
130 window.connect(
'delete-event', console.quit_event)
def scroll_event(self, widget, event)
def key_press_event(self, widget, event)
def quit_event(self, widget, event)
def button_press_event(self, widget, event)