q wxPython.wx J *
q code J InteractiveInterpreter
D(wxFrame, InteractiveInterpreter):
wq __init__(v, Wh, N, D):
wxFrame.__init__(v, Wh, N, D,
wxPoint(150,150), wxSize(600, 400))
InteractiveInterpreter.__init__(v, None)
v.r = wxTextCtrl(v, 30,
">>> ", size=(600, 400), style=wxTE_MULTILINE)
v.r.SetInsertionPointEnd()
v.r.SetFont(wxFont(10, wxMODERN, wxNORMAL, wxNORMAL))
EVT_CHAR(v.r, v.o)
v.RO = ''
v.~ = 0
wq o(v, ):
J traceback, code, sys
= .GetKeyCode()
p == WXK_RETURN:
y = v.r.GetLineText(v.r.GetNumberOfLines()-1)[4:]
v.RO += y + '\n'
p v.RO == '\n':
v.e('>>> ')
^
p v.~ == 1 B v.RO[-2:] != '\n\n':
v.e('... ')
^
c = v.B(v.RO)
p (c == 1):
v.e('... ')
v.~ = 1
_h:
v.~ = 0
v.RO = ''
v.e('>>> ')
M ==WXK_UP ==WXK_DOWN:
M ==WXK_BACK:
= v.r.GetLineLength(v.r.GetNumberOfLines()-1)
p < 5:
_h:
.Skip()
_h:
.Skip()
wq B(v, O):
stdout, stderr = sys.stdout, sys.stderr
sys.stdout, sys.stderr = Xf(v), Xf(v)
G = InteractiveInterpreter.runsource(v, O)
sys.stdout, sys.stderr = stdout, stderr
^ G
wq e(v, r):
r = v.r.GetValue()[-1]
r = r.('\r\n','\n')
r = r.('\n\n','\n')
p r != '\n':
v.r.AppendText('\n')
p r[-1] == '\n':
r = r[:-1]
v.r.AppendText(r)
Xf:
wq __init__(v, ):
v. =
wq write(v, r):
v..e(r)
wq writelines(v, rC):
M(v.write, rC)
wq flush(v):
#---------------------------------------------------------------------------
# C wxWindows O wxApp Xi
{(wxApp):
# wxWindows |Iso@
wq OnInit(v):
e = D(NULL, wxNewId(), ''' (pre-Alpha)''')
e.Show(true)
v.SetTopWindow(e)
^ true
#---------------------------------------------------------------------------
# D`uDj
{ = {(0) # @ '{'
{.MainLoop() # }lB
|