Dear wxPythonistas,
I have been trying without much success to connect the python "cmd" standard
lib command line interface to a wxTreeCtrl without much success. The task
seems simple enough and I'm sure it involves redirecting standard input and
output, however I'm almost positive there are some wxPython specific issues
that I should be addressing. Can anybody give me some pointers? Any feedback
would be much appreciated.
Many thanks,
Shakeeb
## wxCmd_test.py
import cmd
from wxPython.wx import *
class CLI(cmd.Cmd, wxTextCtrl):
def __init__(self, parent, id, txt, style):
cmd.Cmd.__init__(self)
wxTextCtrl.__init__(self, parent, id, txt, style=style)
self.prompt = '> '
def do_hello(self, arg):
print "hello again", arg
def do_quit(self, arg):
sys.exit(1)
#~ cli = CLI()
#~ cli.cmdloop()
class MyApp(wxApp):
def OnInit(self):
self.frame = wxFrame(NULL, -1, "Hello from wxPython")
#self.frame.cmd = wxTextCtrl(self.frame, -1, "Your command",
style=wxTE_MULTILINE)
self.frame.cmd = CLI(self.frame, -1, "Your command",
style=wxTE_MULTILINE)
self.frame.Show(true)
self.SetTopWindow(self.frame)
return true
app = MyApp(0)
app.frame.cmd.cmdloop() # this doesn't work
app.MainLoop()
You could get an idea of how this works by looking at PyCrust.
http://sourceforge.net/projects/pycrust/
PyCrust is an interactive Python environment written in Python.
PyCrust components can run standalone or be integrated into other
development environments and/or other Python applications.
PyCrust comes with an interactive Python shell (PyShell), an
interactive namespace/object tree control (PyFilling) and an
integrated, split-window combination of the two (PyCrust).
···
---
Patrick K. O'Brien
Orbtech (http://www.orbtech.com)
"I am, therefore I think."
-----Original Message-----
From: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of Shakeeb
Alireza
Sent: Wednesday, September 12, 2001 12:35 PM
To: wxpython-users@lists.wxwindows.org
Subject: [wxPython] connecting interactive command line interface to
wxTreeCtrl
Dear wxPythonistas,
I have been trying without much success to connect the python "cmd" standard
lib command line interface to a wxTreeCtrl without much success. The task
seems simple enough and I'm sure it involves redirecting standard input and
output, however I'm almost positive there are some wxPython specific issues
that I should be addressing. Can anybody give me some pointers? Any feedback
would be much appreciated.
Many thanks,
Shakeeb
## wxCmd_test.py
import cmd
from wxPython.wx import *
class CLI(cmd.Cmd, wxTextCtrl):
def __init__(self, parent, id, txt, style):
cmd.Cmd.__init__(self)
wxTextCtrl.__init__(self, parent, id, txt, style=style)
self.prompt = '> '
def do_hello(self, arg):
print "hello again", arg
def do_quit(self, arg):
sys.exit(1)
#~ cli = CLI()
#~ cli.cmdloop()
class MyApp(wxApp):
def OnInit(self):
self.frame = wxFrame(NULL, -1, "Hello from wxPython")
#self.frame.cmd = wxTextCtrl(self.frame, -1, "Your command",
style=wxTE_MULTILINE)
self.frame.cmd = CLI(self.frame, -1, "Your command",
style=wxTE_MULTILINE)
self.frame.Show(true)
self.SetTopWindow(self.frame)
return true
app = MyApp(0)
app.frame.cmd.cmdloop() # this doesn't work
app.MainLoop()
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users