pyqtgraph-导入语句的正确顺序?

Jacksporrow

标题中的问题。在下面的导入中,应该从pyqtgraph还是PyQt5导入QtCore和QtGui?

我的代码工作正常,但是从这个角度看,我的代码感觉很糟糕-我不确定pyqtgraph如何修补pyqt5以及最佳实践是什么。

from PyQt5.QtWidgets import QWidget, QDesktopWidget, QApplication, QLabel, QMainWindow, QHBoxLayout, QVBoxLayout, QSplitter, QFrame,  QSizePolicy
from PyQt5.QtCore import QThread, QObject, QTimer, pyqtSlot, pyqtSignal


from pyqtgraph import PlotWidget
from pyqtgraph.Qt import QtCore, QtGui
永乐

pyqtgraph从任何一个文件中检测您是否已导入PyQt5并将其建立为后端。Qt.py文件是负责管理这个逻辑。

例如,如果最初导入PyQt5,很容易验证pyqtgraph导入的模块与PyQt5相同。

from PyQt5 import QtCore as PyQt5QtCore
from PyQt5 import QtGui as PyQt5QtGui
from PyQt5 import QtWidgets as PyQt5QtWidgets

from pyqtgraph.Qt import QtCore as pgQtCore
from pyqtgraph.Qt import QtGui as pgQtGui
from pyqtgraph.Qt import QtWidgets as pgQtWidgets

assert(pgQtCore == PyQt5QtCore)
assert(pgQtGui == PyQt5QtGui)
assert(pgQtWidgets == PyQt5QtWidgets)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

TOP 榜单

热门标签

归档