Import Main problem

Thread Solved
Reply

Join Date: May 2008
Posts: 838
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 130
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Import Main problem

 
0
  #1
Sep 27th, 2008
Hi
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:
  1. Traceback (most recent call last):
  2. File "<pyshell#7>", line 1, in <module>
  3. from Main import opj
  4. ImportError: No module named Main
Any help would be greatly appreciated.
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,258
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 118
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: Import Main problem

 
0
  #2
Sep 27th, 2008
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

Steve
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 838
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 130
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: Import Main problem

 
0
  #3
Sep 27th, 2008
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:
  1. text = opj('data.xrc')
with this:
  1. 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.
Thanks!
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 845
Reputation: Gribouillis has a spectacular aura about Gribouillis has a spectacular aura about Gribouillis has a spectacular aura about 
Solved Threads: 192
Gribouillis's Avatar
Gribouillis Gribouillis is online now Online
Practically a Posting Shark

Re: Import Main problem

 
0
  #4
Sep 27th, 2008
Here is a way to open an object file and make it a string
  1. text = open('data.xrc').read()
Last edited by Gribouillis; Sep 27th, 2008 at 8:45 am.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 666
Reputation: ZZucker is on a distinguished road 
Solved Threads: 38
ZZucker's Avatar
ZZucker ZZucker is offline Offline
Practically a Master Poster

Re: Import Main problem

 
0
  #5
Sep 27th, 2008
If you look into Main.py, you find:
  1. def opj(path):
  2. """Convert paths to the platform-specific separator"""
  3. st = apply(os.path.join, tuple(path.split('/')))
  4. # HACK: on Linux, a leading / gets lost...
  5. if path.startswith('/'):
  6. st = '/' + st
  7. 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.
Last edited by ZZucker; Sep 27th, 2008 at 9:51 am.
Never argue with idiots, they'll just bring you down to their level and beat you with their experience.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 838
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 130
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: Import Main problem

 
0
  #6
Sep 27th, 2008
So should i just import that little bit of code into my project to load my xrc files?
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 838
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 130
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: Import Main problem

 
0
  #7
Sep 27th, 2008
Oh i also was wondering where do you find the code for such things as that Main module? Is it in the program files?
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,862
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 870
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Import Main problem

 
0
  #8
Sep 28th, 2008
If you installed the wxPython docs file, it could be in something like:
C:\Python25\Doc\wxPython2.8 Docs and Demos\demo
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 838
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 130
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: Import Main problem

 
0
  #9
Sep 28th, 2008
Yeah i ended up finding it in:
C:\Program Files\wxPython2.8 Docs and Demos\demo\
So thats all worked out. Thanks Guys!
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC