Python:在 PyQt4 中嵌入 Chaco 之谜
我如何将 Chaco 添加到现有的 PyQt4 应用程序中?
经过数小时的搜索,收效甚微(自行搜索 )。到目前为止,我认为我需要以下几行:
import os
os.environ['ETS_TOOLKIT']='qt4'
我在互联网上的任何地方都找不到 PyQt4-Chaco 代码
我将非常感谢任何填写空白的人向我展示最简单的线图(有 2 点)
from PyQt4 import QtCore, QtGui
import sys
import os
os.environ['ETS_TOOLKIT']='qt4'
from enthought <blanks>
:
:
app = QtGui.QApplication(sys.argv)
main_window = QtGui.QMainWindow()
main_window.setCentralWidget(<blanks>)
main_window.show()
app.exec_()
print('bye')
Chaco 是什么/Enthought 类继承自 QWidget ?
How do i go about adding Chaco to an existing PyQt4 application?
Hours of searches yielded little (search for yourself). So far i've figured i need the following lines:
import os
os.environ['ETS_TOOLKIT']='qt4'
i could not find PyQt4-Chaco code anywhere on the internets
i would be very grateful to anyone filling in the blanks to show me the simplest line plot possible (with 2 points)
from PyQt4 import QtCore, QtGui
import sys
import os
os.environ['ETS_TOOLKIT']='qt4'
from enthought <blanks>
:
:
app = QtGui.QApplication(sys.argv)
main_window = QtGui.QMainWindow()
main_window.setCentralWidget(<blanks>)
main_window.show()
app.exec_()
print('bye')
what Chaco/Enthought class inherits from QWidget ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我今天才看到这个。将 Chaco 嵌入到 Qt 和 WX 中是绝对可能且相当简单的。事实上,当 ETS_TOOLKIT 环境变量设置为“qt4”时,所有示例都在执行此操作。 (Chaco 要求有一个底层 GUI 工具包。)
我编写了一个小型独立示例,它填补了代码模板中的空白,并演示了如何将 chaco Plot 嵌入到 Qt 窗口中。
qt_example.py:
I just saw this today. It is absolutely possible and fairly straightforward to embed Chaco inside Qt as well as WX. In fact, all of the examples, when run with your ETS_TOOLKIT environment var set to "qt4", are doing exactly this. (Chaco requires there to be an underlying GUI toolkit.)
I have written a small, standalone example that fills in the blanks in your code template, and demonstrates how to embed a chaco Plot inside a Qt Window.
qt_example.py:
这就是您所需要的:
plot_window.control继承自QWidget
here is what you need:
plot_window.control inherits from QWidget
我不知道 Chaco,但我正在使用 VTK,这里是绘制一些线条的代码,它们具有 (x,y,z) 坐标。
它使用 QVTKRenderWindowInteractor 与 PyQT4 交互。
I don't know about Chaco, but I'm using VTK, here is code to draw some lines, having a (x,y,z) coordinates of them.
It uses QVTKRenderWindowInteractor to interact with the PyQT4.
我不认识 Chaco,但快速一看就知道这是不可能的。
Chaco 和 PyQt 都是旨在与用户交互的图形工具包。 Chaco 是面向情节的,而 PyQt 更面向应用程序。每个窗口都有自己的方式来管理窗口是什么、如何检测用户点击、如何处理绘制事件……这样它们就不会混合在一起。
如果您需要绘图软件,可以尝试使用 matplotlib 生成图形的静态图像并在 PyQt 中显示该图像。或者尝试基于 PyQt 的图形或绘图工具包。
I don't know Chaco but a quick look tells me that this is not possible.
Both Chaco and PyQt are graphical toolkits designed to interact with the user. Chaco is plot oriented and PyQt more application oriented. Each one has its own way of managing what a window is, how to detect user clicks, how to handle paint events, ... so that they don't mix together.
If you need plotting software, you can try to use matplotlib to generate static images of graph and show the image in PyQt. Or try a PyQt based graph or plotting toolkit.