简体   繁体   English

如何将 VPython 模拟显示放置到 PyQt5 GUI 的某个区域?

[英]How would I be able to place a VPython simulation display into a certain area of a PyQt5 GUI?

I'm building a 2D simple projectile motion simulation.我正在构建一个 2D 简单的弹丸运动模拟。 I have the GUI layout on the PyQt5 side set (with buttons/dropdowns/checkboxes, but none work yet), and the VPython physics code set as well.我在 PyQt5 侧集上有 GUI 布局(带有按钮/下拉菜单/复选框,但还没有工作),还有 VPython 物理代码集。 I have a large area of the windowed application meant to show the screen (the same one that would pop up in a browser with only VPython code).我有一大块窗口化应用程序用于显示屏幕(与只有 VPython 代码的浏览器中弹出的相同)。 I can't figure out how to connect the simulation visual to that portion of the window, so how would I do that?我不知道如何将模拟视觉连接到 window 的那部分,那我该怎么做呢? What widget should I use?我应该使用什么小部件?

It's also worth mentioning that I am at an intermediate level with VPython and Python itself, but a complete beginner with PyQt5, so I've built the whole GUI in the Qt Designer.还值得一提的是,我对 VPython 和 Python 本身处于中级水平,但对 PyQt5 完全是初学者,所以我在 Qt 设计器中构建了整个 GUI。

I don't know if it's worth posting my code here as all of it is completely unmodified Qt Designer code with no references to VPython, but here's the code for the black box, which was placed in the UiMainWindow() class:我不知道是否值得在这里发布我的代码,因为所有这些都是完全未经修改的 Qt 设计器代码,没有引用 VPython,但这是放置在 UiMainWindow() class 中的黑盒代码:

    self.simulation_view = QtWidgets.QOpenGLWidget(self.centralwidget)
    self.simulation_view.setGeometry(QtCore.QRect(70, 10, 961, 541))
    self.simulation_view.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
    self.simulation_view.setObjectName("simulation_view")

Here's a screenshot of the GUI, with the black box being an OpenGL widget (which is probably wrong for my case) where I want the simulation to appear:这是 GUI 的屏幕截图,黑框是 OpenGL 小部件(这对我来说可能是错误的),我希望在其中显示模拟:

图形用户界面图像

My guess is that this won't work, because I might expect VPython's event loop and PyQt5's event loop would fight with each other.我的猜测是这行不通,因为我可能预计 VPython 的事件循环和 PyQt5 的事件循环会互相争斗。 A different approach would be simply to use VPython's widgets, which includes buttons/dropdowns/checkboxes.另一种方法是简单地使用 VPython 的小部件,其中包括按钮/下拉菜单/复选框。 I'll comment that for VPython questions it's better to post to the VPython forum, where there are many more VPython users who will see your question than if you post to stackoverflow:我会评论说,对于 VPython 问题,最好发布到 VPython 论坛,那里有更多的 VPython 用户会看到您的问题,而不是发布到 stackoverflow:

https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users https://groups.google.com/forum/?fromgroups&hl=en#!forum/vpython-users

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM