gpt4 book ai didi

python - PyQt/PySide 简单的 XY 绘图小部件

转载 作者:太空宇宙 更新时间:2023-11-04 03:21:13 27 4
gpt4 key购买 nike

我想为我公司开发的新硬件编写简单的 GUI 工具。我需要使用 python,因为我的公司使用了很多旧库。我现在的想法是用Python和PyQt编写应用,用pyinstaller部署给其他同事(到处安装python不是我们想要的)。到目前为止它工作得很好,但是当我尝试使用绘图库时,例如 PyQwt ,可执行文件的大小从大约 15MB 增加到 120MB。我发现这是因为 PyQwt 支持 NumPy。但是,我的项目不需要 NumPy。

我发现了一些绘图工具,例如:PyQwt、Matplotlib、PyQtGraph然而,他们都使用 Numpy。

我的问题是:是否有不需要 Numpy 的 PyQt/PySide 绘图工具或框架?

我需要绘制的是简单的顺序数据。例如,传感器每秒提供一个温度,我想在 y/t 图中查看最后 20 个温度。

最好是没有 numpy 的 PyQwt。 PyQwt 主页说 NumPy 是可选的。最终是否有可能以跳过 numpy 的方式配置 PyInstaller?

非常感谢您的帮助!

我的系统:Windows 7的PythonXY 2.7.10PyQT4

最佳答案

查看 documentation , 下降到 3.Fine Tune(可选):

to the configure.py options.

The configure.py script takes many options. The command:

python configure.py -h

displays a full list of the available options

然后查看这些选项,我可以看到如何禁用 Numpy:

Detection options:

--disable-numarray  disable detection and use of numarray [default
enabled]
--disable-numeric disable detection and use of Numeric [default enabled]
--disable-numpy disable detection and use of NumPy [default enabled]

因此,如果您在 PyQwt 目录下运行以下命令,您将能够禁用 Numpy:

$:python configure.h --disable-numarray

如果您的要求只是绘制简单的顺序数据,例如传感器读数与时间的关系,我建议您 PyQtGraphreal time plotting 的例子.

一个通用的例子:

import pyqtgraph as pg
pw = pg.PlotWidget(name='My Graph')
horizontalLayout_Plot.addWidget(pw)
x,y = range(10),range(10)
pw.plot(x,y)

关于python - PyQt/PySide 简单的 XY 绘图小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34672221/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com