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


#23

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 :

the_files='"%s"'%'::::'.join(files)

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’.


#24

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).


#25

I already have your old code lying around somewhere.
I’ve read this before, and finally tried it :
discourse.panda3d.org/viewtopic.php?t=2397
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.


#26

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) :

sys.path.append(os.pardir)

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.

UPDATE :

  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
    taskMgr.run()
  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
    taskMgr.run()
  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.


#27

Yes

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


#28

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
sys.path.append(os.pardir)
os.chdir(os.path.dirname(sys.argv[0]))
from actor import Actor
print Actor

IDE.py :

IDE_path=os.getcwd()
IDE_lastBrowsePath=os.path.dirname(APP_mainFile)
sys.path.insert(0,IDE_lastBrowsePath)
sys.argv[0]=APP_mainFile

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


#29

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:
http://www.nouser.org/~rspoerri/example.zip

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


#30

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]) )

edit:

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


#31

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

To make it work :

import os,sys
sys.path.append(os.pardir)
#________________________________
from lib.test import testClass

test = testClass()
test.echo()

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 :

os.chdir(IDE_lastBrowsePath)

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 ?


#32

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

like i want to load the file:
/home/rspoerri/project/src/main.py

but i want the working directory
/home/rspoerri/project/

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

/home/rspoerri/project/src/
/home/rspoerri/project/
/home/rspoerri/
/home/

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.


#33

like this ?
ynjh.tk/P3D/OIDE/OnscreenIDEdynamic.zip


#34

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


#35

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


#36

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)
os.path.dirname('OnscreenIDEdynamic_Folder/IDE_STARTER.pyw')
->   'OnscreenIDEdynamic_Folder'

os.chdir does not work with a empty string.

try:
    os.chdir( os.path.dirname(sys.argv[0]) )
except:
    pass

should work afaik.


#37

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.


#38

UPDATE :

  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.

#39

UPDATE :

  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

#40

UPDATE :

  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

#41

UPDATE :
[X] completion codes list text : the last update is bad, I don’t know what I was thinking. All text items were strongly flattened at generation time, which took longer generation time (1+ second, previously only 0.15 sec).
To improve that, I managed to flatten them upon their 1st appearance in the scrolled window. This way, the rest of them (invisible ones) will be flattened (if not already has 1 child) as you scroll.
Result : you can get the codes list generated ASAP (it’s back to 0.1+ sec), lightweight for rendering, and the flattening time isn’t noticable.
[X] I used that trick too for the script text as well. It’s great to cut down the loading time, e.g. IDE.py (4460+ lines, 166 KB) is cut from 50 secs down to 10 secs. At last, it can keep me from falling asleep during loading time. :laughing:
[X] update/restart : added events hook release for objects which use PauseResume extension, and all objects except the IDE and everything under /direct
[X] update/restart : the preserved cameras now only the default ones
[X] update/restart : now the main module is always re-imported, so you can do anything outside World class and it will be updated. Done by unloading it from sys.modules to force import.
[X] improved unindent, now supports fine tune (1 space) unindent
[X] indentation is EVERYTHING : added alignment helper line to easily see to which notch you’re currently aligned. If the notch is offscreen, a viewport will be created to let you see that distant spot, so you don’t have to do some weird scroll just to see it. How many IDEs out there implement this ?


#42

Great work, one thing you could add (some engines do that indentation thing already) is a code-line hider (you can hide lines inside a for loop):

example: