Demos dont run!!

aoos

09-02-2008 08:09:43

Hi, i'm new to python-Ogre i've just download python Ogre 1.1 and i have the python 2.5 i made the installation of pyOgre and created a folder, (c:\PythonOgre) but when i try to run a demo i get the following error:
Traceback (most recent call last):
File "C:\Python-Ogre\demos\dshow\demo_video.py", line 12, in <module>
import ogre.renderer.OGRE as ogre
ImportError: No module named ogre.renderer.OGRE

U see i know C++ but i m new to python , i think anyway that i don't import or link the module of Ogre with python , so how i do that?? (I've checked the wiki but i only found outdated information! :cry: )

andy

09-02-2008 10:30:34

So you ran the Python-Ogre installer -- did it confirm that it had found Python 2.5 (or more importantly did it complain that it hadn't found python?)

Just in case you can try
cd pythonogre
python setup.py install
cd demos\ogre
python demo_smoke.py

Regards
Andy

aoos

12-02-2008 22:20:34

OK that was my mistake i installed pythonogre without making a startup folder (i've cheched the option dont create startup folder), now that i reinstall it the demos seems to run fine. But when i use the source code from tutorials from wiki i got an error most in 3rd tutorial "There's an error in your program: expected an indented block" what does this mean? i just copy paste the code to Idle interpreter:

import ogre.renderer.OGRE as ogre
import SampleFramework as sf


class TutorialApplication (sf.Application):
"""Application class."""

def _createScene (self):
# Create a scene with terrain, sky and fog.
self.sceneManager.setWorldGeometry ("terrain.cfg")

# Setup the fog.
fadeColour = (0.9, 0.9, 0.9)
self.renderWindow.getViewport (0).backgroundColour = fadeColour
self.sceneManager.setFog (ogre.FOG_LINEAR, fadeColour, 0.0, 50, 500)
# Setup a sky plane.
plane = ogre.Plane ((0, -1, 0), -10)
self.sceneManager.setSkyPlane (True, plane, "Examples/CloudySky",
100, 45, True, 0.5, 150, 150)

def _chooseSceneManager (self):
# Select the terrain scene manager.
self.sceneManager = self.root.createSceneManager (ogre.ST_EXTERIOR_CLOSE,
'TerrainSM')

if __name__ == '__main__':
ta = TutorialApplication ()
ta.go ()

althought the first tutorial worked fine to me this seems not to be running
for somehow i think that the place where its line of code starts its sensitive for python!

bharling

12-02-2008 22:41:26

Its a python thing :)

the tabs have got messed up from the copy and paste from the wiki. Python reads tabs on lines and does not ignore whitespace in the same way as other languages, in an effort to enforce readable code.

It looks like you just need to delete the space at the start of each line ( the wiki formating for the text meant that you had to put a space at the start of each line to make it display properly ). if that does not work, in IDLE select all the text and do 'un-tabify region'.

aoos

12-02-2008 23:05:57

Nope that doesn't work i used untabify region with 4 columns i even delete any spaces at the start of every line but this error keeps showing and i think that it highlights this line always: def _createScene (self):

silentpolygon

13-02-2008 04:20:38

Maybe it has a problem with your

self.sceneManager.setSkyPlane (True, plane, "Examples/CloudySky",
100, 45, True, 0.5, 150, 150)


Did you try it like that?

self.sceneManager.setSkyPlane (True, plane, "Examples/CloudySky", 100, 45, True, 0.5, 150, 150)

andy

13-02-2008 06:03:04

And make sure you use an editor that has a tool(s) option to convert tabs to spaces..

As a general rule never use the tab character in python source code - set you editor up to use spaces...

Andy

aoos

13-02-2008 12:53:25

ok a at last it worked . ι copy pasted again the code and i modified the tads. even now i dont understand why python is so stupidly sensitive in this matter. it just gives headaches without reason , with C++ i had not to worry about this..

bharling

13-02-2008 13:49:27

:lol:

I think a lot of people say that about python, then they use it for a few weeks and then they find out why its sooo much easier than C++. Glad its working for you now anyway.

fpois

14-02-2008 23:33:58

Yeah, I agree with bharling, these coding standard enforcements make it ALOT easier to work with other people, and understanding/maintaining other people's code. In the real world of programming, that's very important (if not THE most important), and I can't say the same about C++.

You're not really sacrificing much by conforming to the coding standard, but you'll get alot back.