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

Return to Code Snippets

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

Postby ynjh_jo » Tue Mar 04, 2008 12:13 pm

What it is :
A package of dynamic scene instant update (so you don't have to shutdown Panda and reload it again and again everytime you make minor/major changes) and a little attempt to minimize Panda3D - IDE windows switch, if you have 1 small monitor like mine.
It's a 1 application, 1 window solution.

Full reason why : <read at the end of this post>


What's missing :
[-] line wrap
[-] unicode support
[-] code folding
[-] code browser
[-] and anything not mentioned down below.....

FEATURES :
[+] create new file, open, save, and save duplicate
[+] error pinpoint
[+] output capture
[+] line:column bookmarks
[+] auto & smart indent
[+] repetitive characters insertion
[+] Python syntax highlight
[+] matching brackets highlight & selection
[+] 2-ways grow & shrink selection
[+] edit history
[+] color chooser
[+] macro recording, replaying, and editing (visually, so you don't need macro editing manual) [1] [2]
Works with undo/redo during recording, the recorded actions are popped out/in upon undo/redo. The last recorded action type is displayed at status bar.
[+] find & replace, with Regular Expressions
Able to replace in all opened files, and selectable files under a directory.
[+] 3 mouse selection modes (character, word, line), switched by another mouse click
[+] easy launch of PStats server (on local machine) and auto-establish connection
[+] code completion
[+] save to snippets and its completion [1] [2] [3]
[+] import completion [Python] [Panda3D] [new Panda3D]
[+] call tips [Python functions] [Panda3D functions] [individual argument insertion]
[+] Preferences GUI [1] [2] [3] [4] [5] [6] [7]
[+] portable app (can live in removable media)
[+] single instance app, all files passed to IDE_STARTER or using the Welcome Screen will be opened by the running instance of IDE
[+] per-file CWD and arguments
[+] SceneGraph browser and Node Properties panel [1] [2]
[+] software auto-upgrade [1] [2] [3] [4]


Dependency : wxPython


Download:
Since v0.1, there is C++ extension to speed up text generation.
Source code : Text Drawer extension
Windows binaries : for Panda3D 1.5.3, 1.6.0, 1.6.2, 1.7.0, 1.7.2, 1.8.0.
NOTE : if you up/downgrade your Panda3D version, you should rebuild the extension, or it would be done in python, which is approx. 4x slower.
Read /TD/HOW_TO_USE.txt for further info.

IDE codes : OnscreenIDEdynamic.zip [UPDATED Jun/26/2012]
images : IDEimages.zip [UPDATED Aug/31/2011]
models : IDEmodels.zip [UPDATED 3/2/2010]
slider skins : IDEsliderSkins.zip [NEW 6/3/09]
test scene : testDynScene.zip [UPDATED 5/18/09]
fonts : IDEfonts.zip [UPDATED 12/09/08]
tab skins : IDEtabSkins.zip [NEW 07/27/08]
sounds : IDEsounds.zip [NEW 03/31/08]
Put all the .zip files in the directory of your choice and extract them, so that the fonts, models, sounds, images, and skins directories are at the same level with the IDE codes.
You can put the test scene somewhere else.


Screenshots :
Image (1st week)
Image (Oct 2008)
Image (June 2009)
See my later posts for more shots.


KNOWN RESTRICTIONS & LIMITATIONS :
RESTRICTION <1> :
In your main script, you have to protect your World instantiation, because it's done by the IDE.
This is a sample of it :
Code: Select all
if __name__=='__main__':
   print '\n', '@'*10, "\n  I'M PROCESSED !!!\n", '@'*10
   if not hasattr(help,'IDE'):
      World()
   run()

So you must isolate World instantiation so it won't be done twice each time you update the scene. The rest of your code will be executed normally.
World instantiation is done by the IDE, to isolate the instance, to ease the pain when searching for the must-be-destroyed class instances.
The run() call is safe and meaningless when you use the IDE, since it's redirected to a dummy run() function.
The test scene is not already use this blocker, so add it yourself.

But, in case you need to instantiate it yourself, save the instance in global namespace as "winst", like this :
Code: Select all
if __name__=='__main__':
   winst = World( arg1,arg2,etc. )
   run()


RESTRICTION <2> :
If you leave World instantiation to the IDE, you should name the class "World".
Note that you don't need to have a World class to instantiate. If you're trying some very simple modules, you can just do everything in module global namespace.

LIMITATION <1> :
The destructors are still very limited to the commonly used ones, so if you think some destructors need to be added (in myFinder.py), let me know.


IDE START-UP INSTRUCTIONS :
1. run IDE_STARTER.pyw
2. for testing only :
2a. select dyn1.py and (optional) all other test scene files to be edited
2b. select the main script file : dyn1.py
And the IDE will be opened in a new fresh Python session.

NOTE : the default key to open Preferences window is Shift-Ctrl-P

Code: Select all
CRITICAL SITUATION (when it stops responding to any key) :
Alt-M         : print current mode
Shift-Alt-R   : restore to correct mode


Once you're ready to update your scene, press your beloved F9. All edited documents will be saved, and all changes will be instantly updated.


PS. : code donation is always welcome :D

PPS. : You don't have to read my rant below this line.
_______________________________________________

The reason why :
this IDE is generally a pain killer for me, on both Panda and editing sides.

PANDA3D side :
If I use large models or textures, they're loaded from disk only once at first, and the next scene updates will load them from the pools. So, I don't have to waste my time waiting for my scene being loaded from disk, each time I want to see some changes. This saves lots of time when debuging or developing shaders.

EDITING side :
Every IDE I've tried has some unbelieveably unique ways in hurting me. I can't do this or that, or have to do it in weird way. At the end I can only sighhhhhhhhh.
To mention some (in contrast with mine) :
[_1_] Very small range of recent files, and there is no way to adjust it.
[_2_] Some IDE's don't save bookmarks, and some forcefully save bookmarks even if I don't want to save the file.
[_3_] I can't easily stop at the edge when cycling over bookmarks, and some IDE's simply forbid me to wrap to the other edge.
[_4_] So far, no IDE I've tried offers me easy macro editing. All of them force me to read the commands reference, since there is no completion for IDE commands itself. It sounds like slouuuuuu hell if I only need to fix my mistakes when recording it, since I'm very aware that I'm just a mistakes factory.
[_5_] So far, no IDE I've tried adjusts the recorded macro commands upon undo/redo, it just runs 1 way straight forward, blindfold without looking back, so I have to go through point (4) if I made mistakes.
[_6_] I don't know if there is IDE which displays indentation helper line only when needed, i.e. when the alignment notch is off the screen. The worst thing is if it's offscreen, I can't even see what it is. So, why don't I just close my eyes instead ? Opening my eyes wouldn't change anything.
[_7_] I don't know if there is IDE which shows me other than start-matched completion.
[_8_] Any other IDE's do multiple lines operation only on lines which have at least 1 selected character in it.
Imagine this, I put the cursor at the 1st column, and then select 2 lines downward, the line on which the cursor is now, won't be included in the process. Now imagine if I do that in a macro, and I don't put the cursor first at the first column, the result will be different at macro replay time.
Case 1: cursor is at column #1, there will be 2 processed lines
Case 2: cursor is at column #2, there will be 3 processed lines !!!
[_9_] I don't know any IDE which is able to insert the call arguments into the script easily. The worst thing is it's mostly not even wrapped.
Last edited by ynjh_jo on Tue Oct 29, 2013 5:08 am, edited 112 times in total.
http://ynjh.tk
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 rdb » Wed Mar 05, 2008 9:46 am

Can't wait to try it one of these days (very busy right now.)
Screenshot? :)
rdb
 
Posts: 9592
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby ynjh_jo » Wed Mar 05, 2008 1:10 pm

Done.
Found a bug already. I missed the rstrip('\n') in delLine, caused a havoc to the indentation.

QUICK UPDATE :
1. able to load files, press Ctrl-O
2. I don't like filling my screen with files' tabs, so I make the tabs draggable sideways. Use MMB to slide it, and Ctrl-MMB to close a file.
http://ynjh.tk
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 Mar 06, 2008 1:16 pm

xUPDATE :
1. able to load files, create new file, and save file as
2. supports case change, to uppercase, lowercase, and swapcase
3. besides rebind process exceptions handling, now able to handle runtime continuous tasks exceptions too, done by wrapping taskMgr.run(), and if the faulty task is in the tasks list, it would be removed, so it wouldn't halt Panda. Practically, you will never get dropped to Python prompt at all. To demonstrate this, I split the jacks into a separate module : jackClass.py. In there, I used doMethodLater, which will be called 5 seconds later, after the scene get started. That method uses Task, which is not imported, I commented out its import line (line #2). So after 5 seconds passes by, you'll be alerted about the error, and the module file will be set as the active document, or if it's not loaded, it will be loaded first.

more shots :
Image Image Image Image
Last edited by ynjh_jo on Tue Oct 29, 2013 5:27 am, edited 3 times in total.
http://ynjh.tk
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 treeform » Thu Mar 06, 2008 1:58 pm

wow you are putting quite amount of work into this! Much better then the editor i made.
User avatar
treeform
 
Posts: 2106
Joined: Sat May 05, 2007 5:15 pm
Location: SF, CA

Postby ditus » Fri Mar 07, 2008 6:12 am

wow wow wow-wow-wow :D
is the idea of the lenov diing? no!
the aries is already on build :)
User avatar
ditus
Troll
 
Posts: 277
Joined: Mon Oct 15, 2007 2:15 pm
Location: moon

Postby bigfoot29 » Fri Mar 07, 2008 7:22 am

Looks amazing! :D

Regards, Bigfoot29
User avatar
bigfoot29
 
Posts: 618
Joined: Thu Jun 30, 2005 4:22 am
Location: Germany

Postby ynjh_jo » Sun Mar 16, 2008 11:59 am

UPDATE:
1. dynamic updater : there was a super huge hole in my previous updater. I hadn't thought about it earlier. It's the old instances replacement. The way I recreated the new instances was simply by generally call realClass(). Of course, that doesn't work for a class which receives init arguments, which is mostly the way you need it.
So, how if I want to rebind such a class (say class B) ? I must find its host class instances (say class A), and crush them and recreate them, so all class B instances will be created correctly and treated naturally afterward by class A instances. But how if those class A instances are part of a larger environment, which is part of another larger one ? I have to do exactly the same thing for them.
At the end, I might need to crush the whole World class instance and recreate it anyway. So, yes that's what I do now, directly crush World instance and recreate it everytime after any rebind process. The major inconvenience of that is the whole thing get restarted from the very beginning.

2. dynamic updater : if there is an error in a class during instantiation after rebind, and before that erroneous point, you have attached some nodes to scenegraph, registered some events, etc, they used to get left over, alive and don't get rolled back. It means, the next time you update the scene, you'd get another set of duplicates, models, events, lights, and everything instantiated before the broken line. So the scene would look and behave just like hell, or trash bin, sooooo ugly.
It's because the broken class instance doesn't get crushed. Previously, I hadn't figured out how to crush it, since the broken class instance isn't saved in the caller's locals, but only in the broken class' locals.
But I have found a way to crush it, by tracking the real error until the end of tracebacks chain, saving it in the caller class instance, so it can be removed altogether. So there should not be any artifact left anymore during rebind-restart process.
To demonstrate this, uncomment this line in dyn1.py :
# self.brokenInstance=BrokenClass()
and update it (press F9).
You should never see the teapot created before messItUp() call in BrokenClass. What would happen is, the instance of World class, which is responsible for creating BrokenClass instance, will be crushed altogether after saving BrokenClass instance temporarily as its attribute, to ensure safety, in case the expected BrokenClass instance is used in other part of it.
Image

3. code completion is available, works for live objects (everything exists in __builtins__), all imported modules, Python keywords, and class instance attributes (the last part is still experimental and not usable yet).
Works as you type, with stop-typing-threshold .3 second.
It's enabled by default, press F4 to toggle.
Press Ctrl-Space to force it to show up if you're not typing but want to know more about the code your cursor is on.
Use ArrowUp/Down, PageUp/Down, and Home/End to navigate through the list.
Press F1 to toggle the description when highlighting the available code.
Use Ctrl-arrow up/down to navigate through the description.
Press Enter to use the highlighted code.
Press Esc to cancel.
The performance to render the available codes list is poor, since I use my own text builder, which is not optimized for fast render, it's geared towards quick show, so the faster it's generated, the better. For 422 list items, DirectButton takes 3 seconds, plus additional 1 mysterious second. DirectLabel takes 2.3 seconds. Then I decided to use my own text builder, as for the script's text, since I don't need any cosmetics part. The result is it takes only 0.15 second for the same 422 items. In the future, I might use RTT too for it, just like what I do for the code description, which uses 3 pages cameras.
Image Image Image Image

4. before I released this in the 1st place, I dropped pixel-perfect text rendering for a funny reason. Somehow, some letter's vertical edge or corner vanished. I thought that was due to "nearest" texture filter. But recently I found out that it was due to something completely different, it's the side effect of flattenStrong(). Somehow, some overlapping vertices of adjacent letters get welded, or its texcoord loses precission or so, I don't know exactly. The good news is it's easy to solve, only by enlarging each letter's quad to avoid overlapping vertices. See if it's better.
Last edited by ynjh_jo on Tue Oct 29, 2013 5:26 am, edited 2 times in total.
http://ynjh.tk
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

Just a quick one

Postby rninne » Sun Mar 30, 2008 7:18 pm

I can't seem to get this to run.

Here is the output.

Code: Select all
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\smartviz>cd Desktop

C:\Documents and Settings\smartviz\Desktop>cd "New Folder"

C:\Documents and Settings\smartviz\Desktop\New Folder>python IDE_STARTER.py
Warning: DirectNotify: category 'Interval' already exists
DirectStart: Starting the game.
:prc(warning): Invalid integer value for ConfigVariable win-size: 600,500
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
:prc(warning): Invalid floating-point value for ConfigVariable background-color:
 .1,.1,.1,1
:display:windisplay(warning): Could not find icon filename icon.ico
:display:gsg:glgsg(warning): BlendEquation advertised as supported by OpenGL run
time, but could not get pointers to extension function.
:display:gsg:glgsg(warning): BlendColor advertised as supported by OpenGL runtim
e, but could not get pointers to extension function.
:audio(error):   LoadLibrary() failed, will use NullAudioManager
:audio(error):     Module not found
:util(warning): Adjusting global clock's real time by 5.5873e-006 seconds.
:util(warning): Adjusting global clock's real time by -0.0761046 seconds.
enteringFrame
exitingFrame
enteringFrame
exitingFrame
exitingFrame
########################################
STARTING.....
########################################

C:\Documents and Settings\smartviz\Desktop\New Folder>Warning: DirectNotify: cat
egory 'Interval' already exists
############### YOUR FILES ###############
C:\Documents and Settings\smartviz\Desktop\New Folder\2\dyn1.py
C:\Documents and Settings\smartviz\Desktop\New Folder\2\brokenClass.py
C:\Documents and Settings\smartviz\Desktop\New Folder\2\jackClass.py
C:\Documents and Settings\smartviz\Desktop\New Folder\2\pandaClass.py
C:\Documents and Settings\smartviz\Desktop\New Folder\2\smileyClass.py
##########################################
C:\Documents and Settings\smartviz\Desktop\New Folder\2\dyn1.py
C:\Documents and Settings\smartviz\Desktop\New Folder\2
DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
:display:windisplay(warning): Could not find icon filename icon.ico
:display:gsg:glgsg(warning): BlendEquation advertised as supported by openGL run time, but could not get pointers to extension function.
:display:gsg:glgsg(warning): BlendColor advertised as supported by OpenGL runtime, but could not get pointers to extension function.
:audio(error):   LoadLibrary() failed, will use NullAudioManager
:audio(error):     Module not found
:util(warning): Adjusting global clock's real time by 4.74921e-006 seconds.
APP ['WorldInst', '__doc__', '__init__', '__module__', 'moduleName']
APP_modName : dyn1
APP_modName : dyn1
CC_TEMP CLEARED !!
:text(warning): No definition in Lucida Console Regular for character 13
:text(warning): No definition in Lucida Console Regular for character 11
:text(warning): No definition in Lucida Console Regular for character 12
['\x0c', ' ', '$', '(', ',', '0', '4', '8', '<', '@', 'D', 'H', 'L', 'P', 'T', '
X', '\\', '`', 'd', 'h', 'l', 'p', 't', 'x', '|', '\x0b', '#', "'", '+', '/', '3
', '7', ';', '?', 'C', 'G', 'K', 'O', 'S', 'W', '[', '_', 'c', 'g', 'k', 'o', 's
', 'w', '{', '\n', '"', '&', '*', '.', '2', '6', ':', '>', 'B', 'F', 'J', 'N', '
R', 'V', 'Z', '^', 'b', 'f', 'j', 'n', 'r', 'v', 'z', '~', '\t', '\r', '!', '%',
 ')', '-', '1', '5', '9', '=', 'A', 'E', 'I', 'M', 'Q', 'U', 'Y', ']', 'a', 'e',
 'i', 'm', 'q', 'u', 'y', '}']
100
IDE_normal_chars_maxWidth : 0.654545474052
IDE_normal_chars_maxHeight: 2.09090900421
:text(warning): No definition in Lucida Console Regular for character 13
:text(warning): No definition in Lucida Console Regular for character 11
:text(warning): No definition in Lucida Console Regular for character 12
['\x0c', ' ', '$', '(', ',', '0', '4', '8', '<', '@', 'D', 'H', 'L', 'P', 'T', '
X', '\\', '`', 'd', 'h', 'l', 'p', 't', 'x', '|', '\x0b', '#', "'", '+', '/', '3
', '7', ';', '?', 'C', 'G', 'K', 'O', 'S', 'W', '[', '_', 'c', 'g', 'k', 'o', 's
', 'w', '{', '\n', '"', '&', '*', '.', '2', '6', ':', '>', 'B', 'F', 'J', 'N', '
R', 'V', 'Z', '^', 'b', 'f', 'j', 'n', 'r', 'v', 'z', '~', '\t', '\r', '!', '%',
 ')', '-', '1', '5', '9', '=', 'A', 'E', 'I', 'M', 'Q', 'U', 'Y', ']', 'a', 'e',
 'i', 'm', 'q', 'u', 'y', '}']
100
IDE_bold_chars_maxWidth : 0.654545474052
IDE_bold_chars_maxHeight: 2.09090900421
IDE_textScale : Vec3(0.0366667, 1, 0.0366667)
:display(error): Window wouldn't open; abandoning window.
:display:wgldisplay(error): Could not share texture contexts between wglGraphics StateGuardians.


I'm not sure what is going on but the last 2 lines say something I think...

Oh ignore the audio errors the panda version I am using is compiled without FMOD and OpenAL

Robert
rninne
 
Posts: 51
Joined: Mon Dec 10, 2007 9:35 pm
Location: Brisbane, Australia

Postby ynjh_jo » Mon Mar 31, 2008 5:44 am

I'm not sure either, that's very weird. Even the Config params are invalid.
The error is very similar to this :
http://panda3d.net/phpbb2/viewtopic.php ... t=contexts
My own 1.4.2 build works just fine. Perhaps it's 1.5.0 issue ?
[EDIT]:
I'll try to replace makeTextureBuffer with makeOutput. I guess you can't run teapot-on-tv sample too.

I have some (minor) improvements ready for update. I'll UL it tonight.
http://ynjh.tk
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 Mar 31, 2008 9:46 am

I've used makeOutput, but still using different framebuffer properties. It might not work. I tried to use main window's FBprops but the RTT result was funny, so I dropped it.

UPDATE :
1. changed keys for moving line(s) and duplicating line. Instead of using modifier keys (Shift-Ctrl-Alt), now I use double Ctrl, so I only need to utilize 1 hand. Double Ctrl press threshold is .3 second.
2. pausing the scene now correctly pauses all scene's intervals and tasks (both oridinary and doLater tasks).
3. upon rebind, all doLater tasks get removed to avoid unnecessary annoying assertion error due to operating on no-longer-exist objects.
4. code completion : works a little more correct on imported stuff, temporarily imported upon module/document switch (or anytime a document is set to active). Class instance attributes now includes all of its methods, but still not properly usable yet.
5. added destructor for sound
http://ynjh.tk
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 » Sun May 18, 2008 8:03 am

UPDATE :
1. the last edited files list now always saved upon exit, and can be loaded in the next execution.
2. integrated WxPython, mainly to replace the limited my own file dialog and create a welcome screen. Luckily, it also allows me to use a better IDE-OS clipboards management and interaction. It's my 1st time using this cool serves-everything GUI lib, so there should be better ways in doing things.
3. moved the IDE's root to render2dp, to avoid it being affected by user's need over render2d and aspect2d.
4. added pools clears for models, textures, and shaders
5. added destructors for collision traverser and handlerPhysical
6. added collisions in the sample scene
[EDIT 05/22/08]:
7. any camera is preserved upon update

more shots :
Image Image Image Image

Image Image Image Image
Last edited by ynjh_jo on Tue Oct 29, 2013 5:26 am, edited 3 times in total.
http://ynjh.tk
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 rninne » Mon May 26, 2008 12:51 am

Ok, still doesn't run :(

A few things...

may have to do with the WXPython version...

I downloaded: http://downloads.sourceforge.net/sourceforge/wxpython/wxPython2.6-win32-unicode-2.6.4.0-py25.exe

Firstly, when I clicked open / new There was an error saying that
Code: Select all
Traceback (most recent call last):
  File "IDE_STARTER.pyw", line 265, in __init__
    self.SetTransparent(ALPHA_optionsScreen)
AttributeError: 'CreateNewFile' object has no attribute 'SetTransparent'


So I commented out these 2 lines
Code: Select all
193 #self.SetTransparent(ALPHA_optionsScreen)
265 #self.SetTransparent(ALPHA_optionsScreen)


Then this error was raised after creating a new file.
Code: Select all
PREVIEW UPDATED
Nothing was selected.
########################################
STARTING.....
########################################

C:\Documents and Settings\smartviz\Desktop\asdf>Warning: DirectNotify: category
'Interval' already exists
############### YOUR FILES ###############
C:\Documents and Settings\smartviz\Desktop\asdf\brt.py
##########################################
DirectStart: Starting the game.
Known pipe types:
  wglGraphicsPipe
(all display modules loaded.)
:display:windisplay(warning): Could not find icon filename icon.ico
:display:gsg:glgsg(warning): BlendEquation advertised as supported by OpenGL run
time, but could not get pointers to extension function.
:display:gsg:glgsg(warning): BlendColor advertised as supported by OpenGL runtim
e, but could not get pointers to extension function.
:audio(error):   LoadLibrary() failed, will use NullAudioManager
:audio(error):     Module not found
:util(warning): Adjusting global clock's real time by 8.66315e-006 seconds.
APP ['WorldInst', '__doc__', '__init__', '__module__', 'modDir', 'moduleName']
APP_modName : brt
APP_modName : brt
CC_TEMP CLEARED !!
Traceback (most recent call last):
  File "IDE.py", line 449, in <module>
    base.startWx()
AttributeError: ShowBase instance has no attribute 'startWx'
>>>


Again looks like the wxpython playing up, where / how did you install your wxpython / what os are you using?

Robert.
rninne
 
Posts: 51
Joined: Mon Dec 10, 2007 9:35 pm
Location: Brisbane, Australia

Postby ynjh_jo » Mon May 26, 2008 1:23 am

Why are you still using v.2.6 ? Here I use wx v2.8, the latest, and Panda 1.5.1. I don't know since which version startWx was added to ShowBase.

self.SetTransparent :
self is CreateNewFile instance, derived from wx.Frame, so it's a method of a wx.Frame.

It was developed on Windows. But I have just setup a Hardy box (I'm a 3 days linuxer :D) with the latest NVIDIA driver, and I have Panda's gutsy .deb v1.5.2, I'll try it soon on Hardy.

rninne, what's your graphics card ?
For the previous RTT problem you have, do the render-to-texture samples work ?
RTT setup is tricky, the result varies too much across graphics cards.
http://ynjh.tk
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 rninne » Mon May 26, 2008 1:41 am

ynjh_jo wrote:Why are you still using v.2.6 ? Here I use wx v2.8, the latest, and Panda 1.5.1. I don't know since which version startWx was added to ShowBase.


Well I chose v.2.6 because it said latest stable release :P Ill try with v2.8

ynjh_jo wrote:It was developed on Windows. But I have just setup a Hardy box (I'm a 3 days linuxer :D) with the latest NVIDIA driver, and I have Panda's gutsy .deb v1.5.2, I'll try it soon on Hardy.


Welcome to Linux! I'm glad that you chose Ubuntu.

ynjh_jo wrote:rninne, what's your graphics card ?


It is a Colorgraphic Xentera GT... dxdiag tells me it has 4 ATI mobility radeon 9000's (shaders aren't supported on this card... but I'm sure it is the drivers, since it is a specialist card and Colorgraphic have stopped supporting it it's hard to get updates)

With regards to that I'll try it on my other computer it has a more standard card (NVIDIA 7600 GS).

Robert.
rninne
 
Posts: 51
Joined: Mon Dec 10, 2007 9:35 pm
Location: Brisbane, Australia

Postby ynjh_jo » Mon May 26, 2008 1:54 am

Well, life must go on, and v2.6 is just too old.
You'd be better stick to your 7600 GS.

[EDIT]:
for the base.startWx, you can use the next lines (for creating the wx.App instance and the loop) in IDE.py instead of it.
User avatar
ynjh_jo
 
Posts: 1795
Joined: Tue Apr 18, 2006 12:41 am
Location: Malang, Indonesia

Postby Hypnos » Mon May 26, 2008 9:19 am

I am currently trying to port the app to os x. While doing this i wanted to post one mayor problem of wxpython (under osx):

if using StaticBoxSizer, all objects that are added must be created after the StaticBoxSizer.

this:
Code: Select all
WELCOME_openLastEditedFilesBtn = wx.Button(welcomeScreenPanel, -1, 'Open Last Edited Files',size=(0,50))
if os.path.exists('lastFiles') and os.stat('lastFiles')[6]>0:
   WELCOME_openLastEditedFilesBtn.Bind(wx.EVT_BUTTON,OpenLastEditedFiles)
else:
   WELCOME_openLastEditedFilesBtn.Disable()

WELCOME_openFilesBtn = wx.Button(welcomeScreenPanel, -1, 'Open Files',size=(0,50))
WELCOME_openFilesBtn.Bind(wx.EVT_BUTTON,OpenFiles)

WELCOME_createNewFileBtn = wx.Button(welcomeScreenPanel, -1, 'Create New File',size=(0,50))
WELCOME_createNewFileBtn.Bind(wx.EVT_BUTTON,CreateNewFile)

WELCOME_buttonsSizer = wx.StaticBoxSizer(wx.StaticBox(welcomeScreenPanel),wx.VERTICAL)
WELCOME_buttonsSizer.Add((250,0))
WELCOME_buttonsSizer.Add(WELCOME_openLastEditedFilesBtn, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 5)
WELCOME_buttonsSizer.Add(WELCOME_openFilesBtn, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 5)
WELCOME_buttonsSizer.Add(WELCOME_createNewFileBtn, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 5)


must be changed to this:

Code: Select all
WELCOME_buttonsSizer = wx.StaticBoxSizer(wx.StaticBox(welcomeScreenPanel),wx.VERTICAL)

WELCOME_openLastEditedFilesBtn = wx.Button(welcomeScreenPanel, -1, 'Open Last Edited Files',size=(0,50))
if os.path.exists('lastFiles') and os.stat('lastFiles')[6]>0:
   WELCOME_openLastEditedFilesBtn.Bind(wx.EVT_BUTTON,OpenLastEditedFiles)
else:
   WELCOME_openLastEditedFilesBtn.Disable()

WELCOME_openFilesBtn = wx.Button(welcomeScreenPanel, -1, 'Open Files',size=(0,50))
WELCOME_openFilesBtn.Bind(wx.EVT_BUTTON,OpenFiles)

WELCOME_createNewFileBtn = wx.Button(welcomeScreenPanel, -1, 'Create New File',size=(0,50))
WELCOME_createNewFileBtn.Bind(wx.EVT_BUTTON,CreateNewFile)

WELCOME_buttonsSizer.Add((250,0))
WELCOME_buttonsSizer.Add(WELCOME_openLastEditedFilesBtn, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 5)
WELCOME_buttonsSizer.Add(WELCOME_openFilesBtn, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 5)
WELCOME_buttonsSizer.Add(WELCOME_createNewFileBtn, 0, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL, 5)


it would be great, if you could consider this, while you continue your work.
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby ynjh_jo » Mon May 26, 2008 1:29 pm

Great shot, Hypnos !
So, I guess the StaticBox doesn't wrap all children defined before the StaticBoxSizer is created. Is that it ? How about BoxSizer, is it buggy too ?
Are there anything else I should be aware of ?
http://ynjh.tk
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 May 26, 2008 2:18 pm

I got it mostly working in the meantime, i dont think anything else is affected. I could open files and start the ide (i have not checked if the BoxSizer is used in those parts).

I didnt really understand why StaticBoxSizer is not working correctly. It took me a while to figure out this solution from the messages i found on the internet. But it seems to be a known osx problem for wx-windows.

---

Another problem i have found, under osx is that os.execl does not work while using wx-windows. A possibility is to keep the window opened (by using os.spawnl)

Code: Select all
    if sys.platform == "darwin":
        pythonExecutable = "/usr/bin/python" # i think thats the usual py2.5 from 10.5 (leopard)
        result = os.spawnlp( os.P_NOWAIT, pythonExecutable,' -i ', the_IDE, the_files, ' %i'%PStatsEnabled)
    else:
        os.execl(sys.executable.replace('pythonw','ppython'),' -i ',the_IDE,the_files,' %i'%PStatsEnabled)


---

I think adding sys.path.append('.') to IDE.py will fix a problem which can occur in APP_MODULE when importing modules from the loaded file. I think the path is somehow not set correctly when spawning the ide process.

---

Maybe a working directory should be defined when loading a file.
i sometimes use a filestructure like this:
Code: Select all
- panda_function_lib_dir
  - __init__.py
  - file1.py
  - file2.py
- currect_project_dir
  - main.py
  - class2.py

Where main contains:
Code: Select all
from panda_function_lib_dir import file1

This does not work with the current structure.

---

The APP_files is a list of '"/path/to/file"', the filename should be stripped of "
Code: Select all
APP_files_unstrip=sys.argv[1].split('::::')
APP_files = list()
for app in APP_files_unstrip:
    APP_files.append( app.strip('"') )


---

I have changed a lot of other things, but most of them related to the fact that i still use python 2.4 ("var = 'x' if a else 'y' does not exist in 2.4)
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby ynjh_jo » Thu May 29, 2008 5:35 am

Sorry, it took me too long. My first 1.5.2 .deb was corrupt, so I had to DL it again, plus wxPython was not installed by default in Hardy 8.0.4, so I had to install GTK+2 and build wxWidgets myself. Got confused a bit, I did some parts of the build process a little differently and got stuck for a while. :S
After it was built, I moved wx's /lib/* to /usr/lib and the built /wx to python2.5/site-packages. The demo works gorgeously, but when I tried the IDE, none of the threads work. I use new thread to display all dialog (except 1, the exit & save confirmation), since ShowModal never return. On Windows, that works fine, but not on Linux.
Any clue about that ? Could it be something wrong with my wx build ? Perhaps I missed something.

Other bad news on Linux :
[x] The code-completion description's RTT is at low res
[x] the sort order of 2d nodes get scrambled
Perhaps they're simply P3D version changes (serious !) issues, I use 1.5.1 on Windows, and 1.5.2 on Linux.
[x] wx's clipboard must be checked if it's already opened, otherwise assertion error !
[x] wx show event for the code preview panel in create-new-file step doesn't fired at all, causes the preview never generated at all
I'll take closer look at them soon.

Good news :

I have re-arranged all StaticBoxSizers.
______________________
Hypnos wrote:Another problem i have found, under osx is that os.execl does not work while using wx-windows. A possibility is to keep the window opened (by using os.spawnl)

Before migrated to execl recently, I've used to use spawnl P_NOWAIT, plus sys.exit.
The only reason is, on Windows, most of the time, using spawnl minimizes the python console, it's kinda annoying. One thing you (might) miss was closing the welcome screen window (sys.exit after os.spawnl). I could be wrong, so what's the difference of with and without sys.exit ? The problem is solved as soon as the new python session is spawned, isn't it ?
______________________
Hypnos wrote:I think adding sys.path.append('.') to IDE.py will fix a problem which can occur in APP_MODULE when importing modules from the loaded file. I think the path is somehow not set correctly when spawning the ide process.

In IDE.py, I already inserted the main script's dir to the path :
Code: Select all
IDE_lastBrowsePath=os.path.dirname(APP_mainFile)
sys.path.insert(0,IDE_lastBrowsePath)

at the beginning, before importing user's app, and nothing went wrong on Linux. Moreover, I always stick to /root when running "python /path/to/IDE_STARTER.pyw" on terminal.
______________________
Hypnos wrote:Maybe a working directory should be defined when loading a file.
i sometimes use a filestructure like this:

On Windows, I used to execute "python script.py" not from console, so the CWD is set automatically to script's dir. But on Linux (so far I always start the IDE from terminal, still from /root), so the CWD isn't changed.
I just added this to IDE_STARTER, so the panda image can be found :
Code: Select all
# sets the working dir to the script's location, just to ease the pain
os.chdir( os.path.dirname(sys.argv[0]) )

but I haven't tried adding that in IDE.py though.
______________________
Hypnos wrote:The APP_files is a list of '"/path/to/file"', the filename should be stripped of "

On Windows it's without double-quotes, since double-quotes are automatically stripped by the OS. I guess Unix uses single-quotes, isn't it ?
Actually, sys.argv[1] is "/path/to/file1::::/path/to/file2::::/path/to/file3", not "/path/to/file1"::::"/path/to/file2"::::"/path/to/file3", so this works :
Code: Select all
APP_files=sys.argv[1].strip('"').split('::::')


Thanks for your attention, Hypnos !
BTW, is there any delicious reason to stick to python 2.4 ? v2.5 offers some performance optimizations and more interesting things.
http://ynjh.tk
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 rdb » Thu May 29, 2008 10:04 am

Uhrm, shouldn't that be more something along the lines of:
Code: Select all
APP_files=sys.argv[1].split('::::').strip('"')

Small typo? :)
Last edited by rdb on Thu May 29, 2008 11:52 am, edited 1 time in total.
rdb
 
Posts: 9592
Joined: Mon Dec 04, 2006 5:58 am
Location: Netherlands

Postby Hypnos » Thu May 29, 2008 11:48 am

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?
or:
Code: Select all
APP_files=sys.argv[1].strip('"').split('"::::"')

but this needs to be checked for platform type (as it seems to differ for osx & windows and maybe linux).
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby ynjh_jo » Thu May 29, 2008 2:42 pm

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 :
Code: Select all
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 :/
[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'.
http://ynjh.tk
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 » Thu May 29, 2008 6:23 pm

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

Postby ynjh_jo » Thu May 29, 2008 9:49 pm

I already have your old code lying around somewhere.
I've read this before, and finally tried it :
http://panda3d.net/phpbb2/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.
http://ynjh.tk
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 » Sun Jun 01, 2008 11:42 pm

Hypnos wrote:Maybe a working directory should be defined when loading a file.
i sometimes use a filestructure like this:
Code: Select all
- panda_function_lib_dir
  - __init__.py
  - file1.py
  - file2.py
- currect_project_dir
  - main.py
  - class2.py

Where main contains:
Code: Select all
from panda_function_lib_dir import file1

This does not work with the current structure.

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 :
Code: Select all
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) :
Code: Select all
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 :
Code: Select all
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 ?
Image Image

[x] funny news :
How could Python spit Windows path on Linux ?
Look at the last path :
Code: Select all
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.
Last edited by ynjh_jo on Tue Oct 29, 2013 5:25 am, edited 2 times in total.
http://ynjh.tk
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:14 am

ynjh_jo wrote:
Hypnos wrote:Maybe a working directory should be defined when loading a file.
i sometimes use a filestructure like this:
Code: Select all
- panda_function_lib_dir
  - __init__.py
  - file1.py
  - file2.py
- currect_project_dir
  - main.py
  - class2.py

Where main contains:
Code: Select all
from panda_function_lib_dir import file1

This does not work with the current structure.

Hypnos, did you mean to tell me that panda_function_lib_dir and currect_project_dir are at the same level ?

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:
Code: Select all
python currect_project_dir/main.py


so the root directory of this example would have to be in the pythonpath
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby ynjh_jo » Mon Jun 02, 2008 7:08 am

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

IDE.py :
Code: Select all
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'>
http://ynjh.tk
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 8:02 am

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 :) It's already great that you make this ide available.
Hypnos
 
Posts: 585
Joined: Sat Sep 11, 2004 8:07 am
Location: Zürich, Switzerland

Postby Hypnos » Mon Jun 02, 2008 8:07 am

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

Next

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 0 guests