Using IDLE for panda3d development

Is there a way, to dynamically change functions on the fly using IDLE, instead of writing scripts and then running them with ppython?

try using Emacs. There is discussion about it here:
https://discourse.panda3d.org/viewtopic.php?t=730

Look about halfway down for a post by drwr.

This is a (unconfirmed) hint:
switch to your panda installation dir and run


ppython python/Tools/idle/idle.py

Not sure, but this should work…

Regards, Bigfoot29

my, a second I thought it actually did the trick, but it crashed ^^

Well, in case it worked for a few seconds, it might do as well later on… have had several crashes with IDLE (with no Panda3D around) - so its either me or idle isn’t as stable as suspected…

Regards, Bigfoot29

PS: russ: I guess the Thread starter wanted an EASY to use editor… but I guess you are one of the vi(m)>everything-ppl… :wink:

(Or Emacs)

Apart from the IDLE part of the question, I wanted to know if conceptually changes could be made on the fly.

Example beeing, if there is a game with lights. And there is a falloff function for the light. Is it possible to have panda3d running in a window.
And hack away at the functions in IDLE , and see the changes instantaneously. For me personally, that would be the one big advantage over the change, compile, test paradigm.

I think your best bet would be to put in a function that reloads all your classes after it imported the changed module.

from Idle i don’t know… However the Wizard from Panda have written an emacs mode that does this , ctrc-C/ctrl V replaces your code directly in the running programm.

As the source of the emacs mode is readable, may it can help you write a python script to do the same?

Hello all,

I am new to emacs. I have installed emacs for windows. I think the version is 21. I have downloaded and inserted the modified python-mode.el file mentioned in this post. I can get keyword highlighting, so everthing seems to work so-far.

From the Panda 1.1.0 (beta) examples I open the file Tut-carousel.py
I rumove the run() from the bottom of the file.
I save the file.

In the file I type ALT-m
At the botom, I type ppy-shell

I get back the ppython 2.4.2 ppython shell.

Next,
I modify an create an *.emacs.py file that does not have the run() at the end of the file.
I save the file. This would be Tut-carouselemacs.py

In the ppython shell I do the following …

execfile (“Tut-carouselemacs.py”)

run()

The carousel program runs.

Next, I type ENTER to break out of the program.
This works the program freezes.

run()

The program continues.

Next, I go back to my buffer Tut-carouselemacs.py *

Next, I change the Panda oscillation height.
I change the second line from the bottom, the one above “w=World()”
from
panda.setZ(sin(rad + offset) * .2)
to
panda.setZ(sin(rad + offset) * 20.2)

I do not save.

After the ) in 2.2), I type CTRL+c,CTRL+v

For a moment, the cursor stops blinking. It quickly starts blinking again.

I go back the python buffer

I see a new message …

Rebinding class name: World
Finished rebind

I type the following.

run()

The program continues, the oscillation height is the same at 0.2
My change from .2 to 2.2 was not picked up.

How do I make emacs pick up my changes?

What am I doing wrong in emacs?

Thank you very much.

Andre

Unfortunately, the ctrl+c, ctrl+v repaste operation doesn’t work perfectly. It works by looking around the Python namespace for all pointers it can find to the methods in your redefined class, and replacing them with the pointers to the new methods. It finds direct calls to the methods in code, methods added as Tasks, and methods added as callbacks to accept().

However, there are a few function pointers it can’t find. Function pointers referenced by a LerpFunc interval are one kind of function that is not adjusted.

To work around the problem, you could adopt the carousel code so that instead of calling oscilatePanda() directly from the LerpFunc, it calls a new method called doOscillatePanda(), which in turn calls oscilatePanda(). Then when you make changes to oscilatePanda(), the reference should be adjusted.

David

David,

I followed your advice and did something very similar.

I did the following at the ppython console.

w.startCarousel()
run()

It works!

Or, for simplicity, I also tried adding the function to the World class:

def go(self):
      w.startCarousel()
      run()

I redefined the class.
Next, I did from the ppython shell …

w.go()

This also works!

Thanks David!

AIM