How to move Actor by using interactive Python script (REPL)?

Dear community,

I am impressed by Panda3D!
I think it has the potential what I am looking for.
I am designing a some kind of Python teaching aid tool, where children presented to a Isometric 3D world, and (s)he can move around the actor by typing python command. The following code draft should explain it :

ironman = Superhero(“ironman”)
ironman.setPos(0,0)
ironman.hover()
ironman.move(10)
ironman.down()

Kids can enter those codes in a separate Text Editor which resemble a REPL environment.
There, making a new superhero object being generated dynamically in the existing 3D world
It is somekind of Turtle/Logo application, but it just an interactive 3D world

Does this kind of flexibility offered by Panda3D?

Thanks in advance!

  • Eko

I am not aware that Panda3D has anything prebuilt in its own API to do that, but it is simple enough to load an interactive console in a separate thread. A bare bones example with no error handling:

from direct.showbase.ShowBase import ShowBase
from direct.stdpy import threading
from code import InteractiveConsole

app = ShowBase()
ic = InteractiveConsole(globals())
ic_thread = threading.Thread(target=ic.interact)
ic_thread.start()
app.run()

See the code module docs for more information. You can subclass code.InteractiveInterpreter and make it as fancy as you like.

so in short it translates to “yes, if you implement it” :slight_smile:

What about the interactive mode?
panda3d.org/manual/index.php … n_Debugger

Wow, thanks for that code.InteractiveInterpreter !
I am surely gonna explore that!

But, actually, I have been able (since yesterday), in creating my POC application. Here is my blog post about it http://tinyurl.com/pythonthusiast-programmedme-1

It use Python eval() to evaluate a one line Python code. And for a longer script, I use execfile to read an external script. The code editor was implemented using Tkinter. Working flawlessly in Windows 7, but failed to do so in OSX. I think I am gonna search for Tkinter replacement, as from what I’ve read, it’s not so much great running with multiple thread.

Thank you so much for Panda!
It really is … entertaining my week end :smiley: