Hello,
My application generates a data structure with some methods. After that, the application launchs a PyShell. I would like to enable the user to use that data structure, or its methods directly from the shell. How is this possible?
Thanks for any hints.
peter
Peter Wurmsdobler wrote:
Hello,
My application generates a data structure with some methods. After that, the application launchs a PyShell. I would like to enable the user to use that data structure, or its methods directly from the shell. How is this possible?
Put a reference to the data in a dictionary and then pass the dict to PyShell as the locals parameter. Whatever is in that dict will be added to the local varaiables visible in the shell.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
Robin, thanks a lot for your response. But I am not quite sure how to implement what you suggest by:
Put a reference to the data in a dictionary and then pass the dict to PyShell as the locals parameter. Whatever is in that dict will be added to the local varaiables visible in the shell.
Imagine I have a class CDrive
class CDrive:
def __init__(self):
# DO SOMETHING
def SetValue(self,tag,value):
# DO SOMETHING
pass
class CCommandShell:
def __init__(self, drive): # we pass the actual drive
self.frame = wxFrame(None, -1, "Drive Manager Command Shell")
self.frame.SetSize((800, 400))
win = py.shell.Shell(self.frame, -1,
introText="Drive Manager interactive command shell\n\n")
self.frame.Show()
then I want to do something like
drive = Cdrive()
shell = CCommandShell(drive)
which will open a frame containing the shell, which will allow the user
to access the methods like.
I did not find a documentation of PyShell which explains all the parameters being passed. Where should I look?
Thanks a lot,
peter
Peter Wurmsdobler wrote:
Robin, thanks a lot for your response. But I am not quite sure how to implement what you suggest by:
Put a reference to the data in a dictionary and then pass the dict to PyShell as the locals parameter. Whatever is in that dict will be added to the local varaiables visible in the shell.
Imagine I have a class CDrive
class CDrive:
def __init__(self):
# DO SOMETHINGdef SetValue(self,tag,value):
# DO SOMETHING
passclass CCommandShell:
def __init__(self, drive): # we pass the actual drive
self.frame = wxFrame(None, -1, "Drive Manager Command Shell")
self.frame.SetSize((800, 400))
win = py.shell.Shell(self.frame, -1,
introText="Drive Manager interactive command shell\n\n",
locals = {'drive' : drive}
)
self.frame.Show()then I want to do something like
drive = Cdrive()
shell = CCommandShell(drive)which will open a frame containing the shell, which will allow the user
to access the methods like.I did not find a documentation of PyShell which explains all the parameters being passed. Where should I look?
In wxPython/py/shell.py
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!