Onscreen IDE & dynamic instant update [_v0.5.4_]

Uhrm, shouldn’t that be more something along the lines of:


Small typo? :slight_smile:

actually APP_files=sys.argv[1].strip(’"’).split(’::::’) would make sense, if it’s only 1 file (where the split would not be used)

but APP_files=sys.argv[1].split(’::::’).strip(’"’) does not work, because a list cant be stripped.

maybe some re is what we need?


but this needs to be checked for platform type (as it seems to differ for osx & windows and maybe linux).

Don’t worry about it, guys. It’s not a problem at all.
I don’t think there is any OS allows these characters to be part of a filename : "*?/:<>|
Those paths are definitely free of quotes. The quotes serve only to pack the ::::-concat’ed paths, here in IDE_STARTER.startIDE :


It’s only to asure that all paths, which may contain whitespaces are properly packed as a single argument to python. If I leave this string passed over as is, it would be split to be some arguments :
/I am/pathTo/file 1.py::::/I am/pathTo/file 2.py::::/I am/pathTo/file 3.py
The quotes are just a packer :
“/I am/pathTo/file 1.py::::/I am/pathTo/file 2.py::::/I am/pathTo/file 3.py”
So, to extract the paths, first I have to strip those quotes, then split the result by ::::. I’ve tried that both on Windows and Linux, nothing is wrong. I don’t know about OS X’s packer though, I think quotes (both single and double) are universal.

If you guys want to worry, there is 1 more bad news :confused:
[x] on Windows, wx can store & retrieve clipboard text content without any problem, though I have to close it using Flush() to actually store it, so it’s available to the OS, since Close() doesn’t seem enough. Unfortunately, not even Flush() work on Linux, I don’t know why.
I thought that all those problems were caused by my a little dirty build. I have just done a clean build, but it still behaves the same. There must be something wrong somewhere else…
It could be me being so new to Linux…

[+] I’ve fixed the cross platforms EOL-delimiter. File loading now uses universal newline character read mode : ‘rU’.

For copy paste functions for most platforms you may want to check this functionality in the panda3d-interactive-console i wrote. It’s currently not downloadable, as my server went down, i’ll try to remember to upload it again soon (it’s too late for today).

I already have your old code lying around somewhere.
I’ve read this before, and finally tried it :
That solves the clipboard problem, but there are still a lot of critical warnings when spawning a dialog in separate thread. Sometimes, it even segfault. I’ll play around with it further.

Hypnos, did you mean to tell me that panda_function_lib_dir and currect_project_dir are at the same level ?
I tried it by copying /actor from P3D/direct/src to the parent directory of the test scene’s dir, and import it :

from actor import Actor # /actor is copied from P3D/direct/src

Python can’t find it unless I added the parent dir to the path (in the main test file) :


So, normally how do you do it ?
If you added the parent dir yourself, then it will always be found, no matter what the IDE is doing.


  1. fixed all wxPython issues on Linux. File dialog is not spawned in a new thread, since it’s a complicated widget, and tends to crash.
  2. added auto-indent for these keywords : class, def, if, else, elif, try, except, finally, for, while
  3. fixed the scrambled sort order of nodes when using separate render bin. Using back-to-front type bin used to work in 1.5.1, but in 1.5.2, using unsorted bin does it correctly.
  4. improved runtime task-spawn error-tracing, something used to end up this way :
Traceback (most recent call last):
  File "IDE.py", line 3027, in IDE_safeRun
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 939, in run
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 877, in step
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 776, in __stepThroughList
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 696, in __executeTask
TypeError: changeColor() takes exactly 1 argument (2 given)

i.e. due to incorrect arguments count.
The IDE now can locate the exact error position, unless you change the method and/or the class’ name, before it actually run.
Shots of it, see the difference if I change self.changeColor to changeColor ?

[x] funny news :
How could Python spit Windows path on Linux ?
Look at the last path :

Traceback (most recent call last):
  File "IDE.py", line 3018, in IDE_safeRun
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 939, in run
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 877, in step
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 776, in __stepThroughList
  File "linuxroot/usr/share/panda3d/direct/src/task/Task.py", line 696, in __executeTask
  File "I:\PROGRAMMING\Panda3D\=coba IDE\jackClass.py", line 21, in changeColor
NameError: global name 'Task' is not defined

I’ve covered that too.


i have actually never tried to call a python class by spawn or exec using this structure. i would call the main.py script like this:

python currect_project_dir/main.py

so the root directory of this example would have to be in the pythonpath

So, how do you make this import work :
from panda_function_lib_dir import file1
Python doesn’t automatically walk up if you don’t tell it to. So, I think it’s your responsibility.

This is the way I tried it in dyn1.py :

import os
from actor import Actor
print Actor

IDE.py :


Using “python /path/to/dyn1.py” command or started from the IDE work.
Both return <module ‘actor.Actor’ from ‘…/actor/Actor.pyc’>

i just think a workig directory might not be to bad. This not only affects the python imports, but also the panda3d path, where ‘.’ (the working/current directory) is usually in the config file.

to be sure we mean the same, i have put together a example which shows the structure:

if you dont want to do it, im fine :slight_smile: It’s already great that you make this ide available.

Not sure, are you applying this to the way the ide is started?

I thought about defining a working directory for the script that is loaded, not the ide.

btw: i just tested the new version on osx, loading, selecting files, starting up works fine now, except line 16, which i needed to comment out.

os.chdir( os.path.dirname(sys.argv[0]) )


and one suggection, adding a log-output-window would be great (redirect sys.stdout and sys.stderr to some tab)

I tried your sample. It doesn’t work, right ?
ImportError: No module named lib.test

To make it work :

import os,sys
from lib.test import testClass

test = testClass()

And … I just saw the real problem. It’s simply due to my IDE’s dir and the test files’ dir were at the same level. Once I moved the IDE’s dir a bit deeper, I saw it, I saw it :smiley:
Sorry, too late to realize that.
Alright then, just uncomment IDE.py line 94 :


Don’t tell me it’s not what you want :stuck_out_tongue:

And what’s wrong with this :

os.chdir( os.path.dirname(sys.argv[0]) )

sys.argv[0] is IDE_STARTER.pyw path, how could it go wrong ?
Does it return something else on OS X ?

i actually thought of another selection you could make if you load a file.

like i want to load the file:

but i want the working directory

Just make a list of the directories above the file to be loaded.
list would be:


then you can select one of these paths as working directory.

i actually dont like the fact that the ide must be in the same directory like the code i work on.

like this ?

i havent got the time to check if it works correctly right now, but it does look like i wanted :slight_smile:

I hope you also think the change was worth it. Thanks a lot

Of course. I believe there are a lot of unrevealed cases based on how we do things differently.

I have checked the sys.argv[0] error i mentioned a few posts earlier.
if i start IDE_STARTER.pyw from it’s own directory, sys.argv[0] is ‘IDE_STARTER.pyw’. If i start it from a directoy above it sys.argv[0] is ‘OnscreenIDEdynamic_Folder/IDE_STARTER.pyw’.

os.path.dirname( 'IDE_STARTER.pyw' )
->   '' (empty string)
->   'OnscreenIDEdynamic_Folder'

os.chdir does not work with a empty string.

    os.chdir( os.path.dirname(sys.argv[0]) )

should work afaik.

Yes, that’s one difference between you and me. I always supply absolute path to Python, while you like relative path.
No problem, actually there is a simple 1 line solution for both of us :smiley:
Just need to combine the cwd and argv[0] :

absPath=os.path.dirname( joinPaths(os.getcwd(),sys.argv[0]) )

joinPaths is os.path.join
or simply sys.path[0], which is the absolute path to the script, set by Python by default.


  1. improved rendering performance of thousands lines of text
    Rendering IDE.py which is 4300+ lines used to be too slow : 10+ fps. That’s due to the text lines were plainly attached to text parent without any optimization. Eventhough Panda culls the offscreen text lines by default (using cam2d’s frustum planes and DirectScrolledFrame’s clip planes), Panda still needs to traverse the whole text lines, just to decide if the line should be rendered or not, and that spends too much time.
    To solve that, I didn’t implement hierarchical bounding volume trick, since it would only complicate things too much, e.g. when I need to move lines around, then it must be moved across page parents. So I decided to use a more general solution, which I believe is used by any software text editor, i.e. draw only the visible/onscreen text, started from the page’s top line. It’s so simple, I just need to stash the currently visible text lines, and unstash the onscreen text lines. That helps to boost render speed from 10+ fps to 60+ fps !
    :laughing: That’s what I call an optimization. :smiley:
  2. shader pool clears now happens every update, since shader files are tiny, compared to models or textures, so any tiny mod in shader file should be updated.


  1. startup (new file) : added config variable search
  2. startup (new file) : added option to embed config description
  3. added delete to word head
  4. the prefered CWD now appended to lastFiles. On the next run, if you want to open last edited files, you can start the IDE straight ahead by pressing spacebar twice, or holding down ENTER/RETURN for a second, without setting the CWD again every startup.
  5. integrated PauseResume module


  1. the completion codes list text now optimized for rendering, using the same trick as the script text. Boost : 160% for 420+ items (NodePath attributes)
  2. added goto page top and bottom
  3. fixed new bug in exception handling
  4. all .pyc files under the main file directory now removed recursively at startup to eliminate the misleading hardcoded module path, which occurs if you develop on a multi-OSes machine.
  5. updated PauseResume