L
Lionel
Hello all:
I've crafted several classes and exceptions which I've stored in a
file called "DataFileType.py". I then invoke them from within other
files like this:
# Top of file
import sys
sys.path.append("c:\DataFileTypes")
from DataFileTypes import *
data = None
try:
# Note: "INTData" is a class defined in "DataFileTypes"
data = INTData("C:\SomeRawDataFile.int")
except DataFileError:
print("Error opening data file")
except ResourceFileError:
print("Error opening resource file")
The above works very well. No complaints. However, I'm experimenting
with the wxPython gui library and found that this no longer seems to
work when I add the crucial bits to one of their examples. I've copied
and run an example that came with wxPython and verified that, with no
modification on my part, it runs with no problem. I then add ONLY my
import instructions and try to instantiate an object as follows (I'm
only showing a portion of the file):
#!/usr/bin/env python
from numpy import arange, sin, pi
import matplotlib
matplotlib.use('WX')
from matplotlib.backends.backend_wx import FigureCanvasWx as
FigureCanvas
from matplotlib.figure import Figure
from wx import *
# The following 4 lines are my additions to the example code:
import sys
sys.path.append("c:\DataFileTypes")
from DataFileTypes import *
data = INTData("C:\SomeRawDataFile.int")
class CanvasFrame(Frame):
..
..
etc
..
..
Running the above program (which I've called "guiplottest.py")
generates an immediate error with the following traceback:
C:\Guiplottest.py
Traceback <most recent call last>:
File "C:\GuiPlotTest.py", line 19, in <module>
data = INTData("C:\SomeRawDataFile.int")
NameError: name 'INTData' is not defined
But "INTData" is defined...it's defined in "DataFileTypes" from which
I've imported everything. What's happening here? Thanks in advance!
-L
I've crafted several classes and exceptions which I've stored in a
file called "DataFileType.py". I then invoke them from within other
files like this:
# Top of file
import sys
sys.path.append("c:\DataFileTypes")
from DataFileTypes import *
data = None
try:
# Note: "INTData" is a class defined in "DataFileTypes"
data = INTData("C:\SomeRawDataFile.int")
except DataFileError:
print("Error opening data file")
except ResourceFileError:
print("Error opening resource file")
The above works very well. No complaints. However, I'm experimenting
with the wxPython gui library and found that this no longer seems to
work when I add the crucial bits to one of their examples. I've copied
and run an example that came with wxPython and verified that, with no
modification on my part, it runs with no problem. I then add ONLY my
import instructions and try to instantiate an object as follows (I'm
only showing a portion of the file):
#!/usr/bin/env python
from numpy import arange, sin, pi
import matplotlib
matplotlib.use('WX')
from matplotlib.backends.backend_wx import FigureCanvasWx as
FigureCanvas
from matplotlib.figure import Figure
from wx import *
# The following 4 lines are my additions to the example code:
import sys
sys.path.append("c:\DataFileTypes")
from DataFileTypes import *
data = INTData("C:\SomeRawDataFile.int")
class CanvasFrame(Frame):
..
..
etc
..
..
Running the above program (which I've called "guiplottest.py")
generates an immediate error with the following traceback:
C:\Guiplottest.py
Traceback <most recent call last>:
File "C:\GuiPlotTest.py", line 19, in <module>
data = INTData("C:\SomeRawDataFile.int")
NameError: name 'INTData' is not defined
But "INTData" is defined...it's defined in "DataFileTypes" from which
I've imported everything. What's happening here? Thanks in advance!
-L