我正在尝试在Windows中为GNU广播构建GUI。我已经创建了一个基于top_block(GNU Radio)的主类,并且尝试在正在编写的另一个脚本中导入该类,但是当我尝试导入主类时,它说,找不到指定的模块(Pyqt4)< / p>
if __name__ == '__main__':
import ctypes
import sys
if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print ("Warning: failed to XInitThreads()")
from PyQt4 import Qt, QtGui, QtCore
from PyQt4.QtGui import *
from PyQt4.QtCore import QObject, pyqtSlot
import win32com.client
from gnuradio import analog
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import qtgui
from gnuradio.eng_option import eng_option
from gnuradio.filter import firdes
from gnuradio.qtgui import Range, RangeWidget
from optparse import OptionParser
import limesdr
import sip
import sys
import os
import serial
import serial.tools.list_ports
from gnuradio import qtgui
class lime_iq_test1(gr.top_block, Qt.QWidget):
def __init__(self, inFile, outFile):
QtGui.QWidget.__init__(self)
gr.top_block.__init__(self, "Lime Iq Test1")
Qt.QWidget.__init__(self)
self.setWindowTitle("Lime Iq Test1")
qtgui.util.check_set_qss()
try:
self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
except:
pass
self.top_scroll_layout = Qt.QVBoxLayout()
self.top_scroll_layout.setAlignment(QtCore.Qt.AlignTop)
self.setLayout(self.top_scroll_layout)
self.top_scroll = Qt.QScrollArea()
self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
self.top_scroll_layout.addWidget(self.top_scroll)
self.top_scroll.setWidgetResizable(True)
self.top_widget = Qt.QWidget()
self.top_scroll.setWidget(self.top_widget)
self.top_layout = Qt.QVBoxLayout(self.top_widget)
self.top_grid_layout = Qt.QGridLayout()
self.top_layout.addLayout(self.top_grid_layout)
self.settings = Qt.QSettings("GNU Radio", "lime_iq_test1")
self.restoreGeometry(self.settings.value("geometry").toByteArray())
这是我主要课程的开始,因为很长,我没有粘贴整个文件。Pyqt4导入正确,我得到了所需的结果
if __name__ == '__main__':
import ctypes
import sys
if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.so')
x11.XInitThreads()
except:
print ("Warning: failed to XInitThreads()")
from PySide import QtGui, QtCore
import pandas as pd
import pyqtgraph as pg
import numpy as np
from limeIq import lime_iq_test1
QVariant = lambda value=None: value
class Widget(QtGui.QWidget):
def __init__(self, parent=None):
super(Widget, self).__init__(parent)
v_global_layout = QtGui.QVBoxLayout()
v_global_layout.addWidget(TabDialog())
v_global_layout.setAlignment(QtCore.Qt.AlignTop)
self.setLayout(v_global_layout)
文件名是limeIq.py,我正在调用的类是lime_iq_test1
我不明白为什么它无法导入文件