My problem today is i have opened up the wxPython Demo and copied one of the pieces of code across to IDLE so i can have a fiddle with it. My problem is that at the start it goes from Main import opj . Thats what stuffs it up. The interpreter goes something like this:

Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    from Main import opj
ImportError: No module named Main

Any help would be greatly appreciated.

Is Main a custom module or just inbuilt module? I think you have to check if it is custom and check how to import custom module if it is!

Don't think it will help alot for I have note trie d before


It is just found in the wxPython demo so it might be a custom thing. I noticed it was to open a file. But when i replaced this:

text = opj('data.xrc')

with this:

text= open('data.xrc')

It gave me some sort of error where is said it wanted a string or unicode object not a file. So is there any way to open an object (file) and make it a string.

What i want to do with this is have wxPython read from xml files and make a GUI from that. It is in the Demo so i just wanted to do it myself. If you have any pointers for that as well that would be good.

Here is a way to open an object file and make it a string

text = open('data.xrc').read()


If you look into Main.py, you find:

def opj(path):
    """Convert paths to the platform-specific separator"""
    st = apply(os.path.join, tuple(path.split('/')))
    # HACK: on Linux, a leading / gets lost...
    if path.startswith('/'):
        st = '/' + st
    return st

The problem is that the 'wx code demo stuff' is unnecessarily complex on the one side and often very shallow where it counts. It is written by the same guy that wrote the book on wxPython, by all reports a frustrating failure.

So should i just import that little bit of code into my project to load my xrc files?

Oh i also was wondering where do you find the code for such things as that Main module? Is it in the program files?

If you installed the wxPython docs file, it could be in something like:
C:\Python25\Doc\wxPython2.8 Docs and Demos\demo

Yeah i ended up finding it in:
C:\Program Files\wxPython2.8 Docs and Demos\demo\
So thats all worked out. Thanks Guys!