-
Notifications
You must be signed in to change notification settings - Fork 65
Description
I'm new to Lantz but I found its features to match the requirements of an experiment I'm currently working on. I'm basing most of my development on the tutorial. I've already written the drivers for my device and wanted to start building a GUI. For that, I started the rich-app tutorial. However, I immediately ran into an error after running the first piece of code:
# We import a helper function to start the app
from lantz.ui.app import start_gui_app
# The block consists of two parts the backend and the frontend
from lantz.ui.blocks import FeatScan, FeatScanUi
# An this you know already
from lantz.drivers.examples import LantzSignalGenerator
with LantzSignalGenerator('TCPIP::localhost::5678::SOCKET') as fungen:
# Here we instantiate the backend setting 'frequency' as the Feat to scan
# and specifying in which instrument
app = FeatScan('frequency', instrument=fungen)
# Now we use the helper to start the app.
# It takes a Backend instance and a FrontEnd class
start_gui_app(app, FeatScanUi)Traceback (most recent call last):
File "<ipython-input-14-d6e2c2282680>", line 1, in <module>
runfile('C:/[...]/test.py', wdir='C:/[...]')
File "C:\[...]\Anaconda\envs\py34\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 601, in runfile
execfile(filename, namespace)
File "C:\[...]\Anaconda\envs\py34\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 80, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "C:/[...]/Documents/JM/Santec TSL-510/PyControl/test.py", line 20, in <module>
start_gui_app(app, FeatScanUi)
File "C:\[...]\Anaconda\envs\py34\lib\site-packages\lantz\ui\app.py", line 242, in start_gui_app
frontend = frontend_class(backend=backend)
File "C:\[...]\Anaconda\envs\py34\lib\site-packages\lantz\ui\app.py", line 131, in __init__
filename = os.path.dirname(inspect.getfile(cls))
File "C:\[...]\Anaconda\envs\py34\lib\inspect.py", line 524, in getfile
raise TypeError('{!r} is a built-in class'.format(object))
TypeError: <module 'builtins' (built-in)> is a built-in classIt seems the problem resides on a section of lantz.ui.app.Frontend:
class Frontend(QtGui.QMainWindow, metaclass=_FrontendType):
frontends = {}
# a declarative way to indicate the user interface file to use.
gui = None
# connect widgets to instruments using connect_setup
auto_connect = True
def __init__(self, parent=None, backend=None):
super().__init__(parent)
self._backend = None
if self.gui:
for cls in self.__class__.__mro__:
filename = os.path.dirname(inspect.getfile(cls)) # <<<<<< This line!
filename = os.path.join(filename, self.gui)
if os.path.exists(filename):
logger.debug('{}: loading gui file {}'.format(self, filename))
self.widget = QtGui.loadUi(filename)
self.setCentralWidget(self.widget)
break
else:
raise ValueError('{}: loading gui file {}'.format(self, self.gui))
# ...The elements inside Frontend.__class__.__mro__ are:
(lantz.ui.app._FrontendType,
PyQt4.QtCore.pyqtWrapperType,
sip.wrappertype,
type,
object)From this it seems the problem is when for cls in self.__class__.__mro__ goes through type and object. I think that since these two classes are built-ins, inspect.getfile(cls) raises the TypeError exception.
I'm not certain if this problem is specific to my system or if it is a general issue. Could it be an incompatibility between lantz and my current libraries? I'm using Python 3.4 and I think that I have every library up-to-date.