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

Return to Code Snippets

Postby ynjh_jo » Mon Jun 02, 2008 11:16 am

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

To make it work :
Code: Select all
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 :D
Sorry, too late to realize that.
Alright then, just uncomment IDE.py line 94 :
Code: Select all
os.chdir(IDE_lastBrowsePath)

Don't tell me it's not what you want :P

And what's wrong with this :
Code: Select all
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 ?
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby Hypnos » Mon Jun 02, 2008 4:42 pm

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:
Code: Select all
/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.
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby ynjh_jo » Tue Jun 03, 2008 6:00 am

http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby Hypnos » Tue Jun 03, 2008 5:24 pm

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

I hope you also think the change was worth it. Thanks a lot
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby ynjh_jo » Tue Jun 03, 2008 11:12 pm

Of course. I believe there are a lot of unrevealed cases based on how we do things differently.
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby Hypnos » Wed Jun 04, 2008 6:47 am

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'.
Code: Select all
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.

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

should work afaik.
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby ynjh_jo » Wed Jun 04, 2008 9:55 am

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 :D
Just need to combine the cwd and argv[0] :
Code: Select all
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.
Last edited by ynjh_jo on Tue Jun 10, 2008 8:17 am, edited 1 time in total.
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby ynjh_jo » Sat Jun 07, 2008 3:33 am

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 !
:lol: That's what I call an optimization. :D
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.
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby ynjh_jo » Mon Jul 07, 2008 7:10 am

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
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby ynjh_jo » Fri Jul 11, 2008 12:19 pm

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
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby ynjh_jo » Mon Jul 14, 2008 2:59 pm

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. :lol:
[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 ?
Image Image
Last edited by ynjh_jo on Tue Jul 15, 2008 1:41 pm, edited 1 time in total.
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby Hypnos » Mon Jul 14, 2008 6:24 pm

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:
Image
Image
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby ThunderZ » Mon Jul 14, 2008 11:50 pm

ynjh_jo this is really awesome.
i'm really impresive with your tool.
Easy to use and really usefull to prototype some quick thing and show what we do.

thx.
User avatar
ThunderZ
 
Posts: 57
Joined: Mon May 12, 2008 5:41 am

Postby ynjh_jo » Tue Jul 15, 2008 12:26 am

Glad you like it.

Yes, I know about code folding. I've already implemented it for my scenegraph browser, but that's another story and not good enough. I'll build it again from scratch (so it'd be compatible with line wrap too) if I have more time.

A problem to concern :
if you notice that you made alot of typos while using it, it's NOT your fault. Some keystrokes sometimes evaporate into the air, though according to keydown, they were caught. It's when I press more than 1 buttons at the same time, only the 1st one survives, the others are dead.
[EDIT] :
I found the source of the problem, it's wx's Dispatch() call. It's currently handled by a continuous task. I guess if I enable it only when needed, that could take the problem away.
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby ynjh_jo » Thu Jul 17, 2008 2:56 pm

UPDATE :
[X] I've busted that keystrokes thief. Wx event loop is very weird.
On Linux, it's very important. The clipboard doesn't even work without it.
On Windows, wx still works without it. Enabling the loop on Windows only makes it worse !
So, I enable the loop only on other OSes, except Windows.
Now I can go with my full typing speed without any worries.
[X] all wx interfaces always spawned in the main thread on Linux. I don't know how (wx + threads) would behave on OS X.
[X] the last edited files list is saved in separate files, based on the OS (OS is used for the extension). So, I can switch OSes without losing the last session files list.
[EDIT] :
[X] bugfix : vanishing line due to the newly implemented text rendering optimization
[X] selection indent/unindent : the aligned column now always kept onscreen
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby ynjh_jo » Sat Jul 19, 2008 8:34 am

UPDATE :
[X] Panda's default values (background color, mouse interface) and default scenegraphs attributes (fog, effects, lights, material, rendermode, shader, 2sided, etc.) correctly restored upon update
[X] added open recent files. The displayed recent files are not including the already opened ones, and you can multiselect them, unlike in most editors. The limit is 150 files. It's adjustable, but I haven't implemented config file yet, so if you want to edit it, find it near the top of IDE.py.
[X] the currently opened files and recent files list also saved upon opening & closing any file
[X] added missing files retry open
[X] added main module switch. You can set any file as the main module, so theoretically, upon update it will be ran instead of the main module set in the first place. But that won't let you get some changes which involve different window or framebuffer properties, since those changes require me to recreate the window and/or graphics state guardian, which isn't possible at the moment.
Before the switch happens, you need to choose the prefered CWD, as at the startup screen. You can use this mean to reset it if you accidentally chose the incorrect one. The CWD change affects config variable search path (model & sound paths) used by Panda loader.
[X] added auto jump to scene upon update
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby birukoff » Sat Jul 19, 2008 11:29 am

ynjh_jo, you the man!!! I am really exited about your work. Fantastic!
Thanks to pro-rsoft for his shadow mapping feature for the shader generator!
User avatar
birukoff
 
Posts: 424
Joined: Thu Nov 08, 2007 7:03 am
Location: Russia, Moscow

Postby CJLopez » Sun Jul 20, 2008 8:08 pm

Am, can you give me or point me for a "How to install..." tut, I juts downloaded the binaries of the program for python 2.5 ansi, and the whole thing was installed on the python\lib\site-packages, and I can't seem to fin the executable, or the way to compile this and run. I already looked on the Build Instrucctions, but the setup.py is not in the wxPython directory either
CJLopez
 
Posts: 14
Joined: Thu Jul 17, 2008 4:01 pm

Postby ynjh_jo » Sun Jul 20, 2008 9:57 pm

If you already have wx installed, you're good to go. Just extract all the zip files, put the sounds, fonts, and images directories at the same level with the IDE files. There isn't executable to start the IDE, they're simply python files. So, just locate IDE_STARTER.pyw and run it with your pythonw.exe.
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby BrianInSuwon » Tue Jul 22, 2008 12:28 pm

The screenshots look amazing. I'd love to try the IDE. I downloaded wxPython and when I went to install it I got this message:

No installation of Python 2.5 found in registry.
Be sure to enter a pathname that places wxPython on the PYTHONPATH


Also when I start Blender I see,
Checking for installed Python...No installed Python found.


I think the two problems are related. Any help?
BrianInSuwon
 
Posts: 98
Joined: Wed Jun 18, 2008 1:25 am

Postby Thaumaturge » Tue Jul 22, 2008 2:04 pm

Well, do you have your PYTHONPATH variable set?

If not, what operating system are you using?

If you know how to set environment variables, you should be safe in ignoring the rest of this post. I include it in case you don't. ;)

If it's Windows XP, and you don't know how to set environment variables, go to Control Panel, open System/System Properties, go to the "Advanced" tab, and click on the "Environment Variables" tab.

In the panel that should show up, look at the panel labelled "System variables" (it should be the lower one). If you find a variable named PYTHONPATH there, then select it and click on "Edit", otherwise click on "New".

In the dialogue that should appear, set the "Variable name" to PYTHONPATH (all upper-case, no spaces) if applicable, and set the "Variable value" appropriately. In my case, it reads:
"C:\Panda3D-1.5.2\python\python.exe;C:\Panda3D-1.5.2\python\DLLs;C:\Panda3D-1.5.2\python\Lib;
C:\Panda3D-1.5.2\python\Lib\lib-tk"
(Without the inverted commas or the line break.)

Note the semicolons between entries, and the various paths included: one each for python.exe, the DLLs folder, the Lib folder, and the lib-tk folder.
MWAHAHAHAHA!!!

*ahem*

Sorry.
User avatar
Thaumaturge
 
Posts: 684
Joined: Sat Jun 07, 2008 6:34 pm
Location: Cape Town, South Africa

Postby ynjh_jo » Tue Jul 22, 2008 2:21 pm

I don't have standard python2.5 installed. So, the one set in registry is Panda's. All python libs can detect it at installation, but yes, blender can't.
Can't you just create its registry entry manually and point it to your Panda3D\python ?
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby BrianInSuwon » Wed Jul 23, 2008 12:44 am

Can't you just create its registry entry manually and point it to your Panda3D\python ?


I'm hoping so, but I don't know how. Any pointers?
BrianInSuwon
 
Posts: 98
Joined: Wed Jun 18, 2008 1:25 am

Postby ynjh_jo » Wed Jul 23, 2008 2:59 am

The path is saved in HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.5\InstallPath

Create the needed keys if it's not exist. Or if you want an easy way, just google for "python to registry".
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby BrianInSuwon » Thu Jul 24, 2008 3:34 am

I downloaded python 2.5.2, then I installed wxPython with no problems and even Blender is happy. I downloaded the IDE zip files. I tried to run the IDE START.py but it didn't find wx. Do I need to move some files/folders around ? Do I need to move some wx files to the panda/python folder?
BrianInSuwon
 
Posts: 98
Joined: Wed Jun 18, 2008 1:25 am

Postby ynjh_jo » Thu Jul 24, 2008 7:12 am

Where did you install it ? I guess it must be in python25. Don't move it around, copy it instead to p3d's python site-packages.
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby BrianInSuwon » Thu Jul 24, 2008 3:56 pm

I copied the Site Package folder from Python to Panda/python. That helped alot. Another question, do I place the IDEfonts folder (which contains a font folder) into the OnscreenIDEdynamic folder or do I just place the font folder into the OnscreenIDEdynamic folder.

I opened the IDE_STARTER.pyw file in PyPE and ran it. I got the start screen to open a file. I choose to open the dyn1.py. Now I have just a blank black Panda window, I think its locked up. I also tried to open dyn1.py then the smileyClass.py. That didn't work. I also noticed there are 2 dyn1.py files.

I'm pretty sure, I don't understand what the files do and in what order I should open them.
BrianInSuwon
 
Posts: 98
Joined: Wed Jun 18, 2008 1:25 am

Postby ynjh_jo » Fri Jul 25, 2008 12:08 am

I believe IDEfonts folder was created by your unpacker. Move the zip contents at the same level with the IDE codes.

2 dyn1.py files ? There is only 1 in the zip.
http://ynjh.panda3dprojects.com | http://ynjh.p3dp.com
Intel P4Prescott 2.8GHz HT | ATI Radeon HD4670 1GB GDDR3
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby BrianInSuwon » Fri Jul 25, 2008 1:39 pm

I tried to follow along with the steps outlined in the original post but had no luck. What steps do I need to follow to get the IDE working once all the files are installed and I can get the open file/new file screen running (thats as far as I've gotten)?

Do I need to load the dyn1.py file even when I make a new file? If so, why?

If you have time, can you give a one or two sentence summary of what the different py files do and outline their dependencies.
BrianInSuwon
 
Posts: 98
Joined: Wed Jun 18, 2008 1:25 am

Postby dual » Fri Jul 25, 2008 2:53 pm

BrianInSuwon: No, you don't have to load dyn1.py or any other files. Simply run IDE_STARTER.pyw, and click either Open Files or Create New File. It should work without any problems.
dual
 
Posts: 6
Joined: Sun Jul 20, 2008 10:39 am

PreviousNext

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 0 guests