如何在 python GUI 中创建交互式等轴测框架(最好是 wxpython)
我正在设计一个管道软件,目前它可以在 2D 上运行。我用 wx.paintDC() 实现了一个非常简单的框架,它基本上是这样的:
def OnDrawing(self, evt):
dc = wx.PaintDC(self.leftWindow)
self.leftWindow.PrepareDC(dc)
dc.Clear()
for image in self.images[1:]:
x = image[1][0]
y = image[1][1]
img = wx.Image(image[0], wx.BITMAP_TYPE_ANY)
bmp = wx.BitmapFromImage(img)
dc.DrawBitmap(bmp, x, y, True)
结果是这样的 [1]。右侧的按钮用于将部分(管道、阀门等)添加到右侧框架。当您单击按钮时,程序会计算位置并绘制它,因此框架是非交互式的,您无法单击管道或阀门的部分,无法调整其大小等。
这非常容易和简单,但作为一个新的程序员这花了我一些时间(并且我对此相当自豪)。现在我想改进这一点,我现在想做的是创建一个类似 3D 的交互式框架,用户可以在其中“通过鼠标”创建管道图,单击它们来更改属性等。
我的目标是什么像这些[2] [3]。具有这样的等距背景 [4]
我想这并不容易(但也不是)对我来说,一开始我做了什么),但我决定继续努力和学习以实现这一目标。我想从你们那里得到的是指导..
现在我不知道从哪里开始,我想知道“这在wx上可能吗?”,“我应该使用openGL还是其他东西?”嗯>。我需要你指出正确的方向。
只用wx可以实现吗?或者我需要 pyopengl (我对此一无所知),或者类似的东西?
谢谢!!!...
Am designing a piping software, right now it works on 2D. I implemented a very simple frame with wx.paintDC() it basically goes like this:
def OnDrawing(self, evt):
dc = wx.PaintDC(self.leftWindow)
self.leftWindow.PrepareDC(dc)
dc.Clear()
for image in self.images[1:]:
x = image[1][0]
y = image[1][1]
img = wx.Image(image[0], wx.BITMAP_TYPE_ANY)
bmp = wx.BitmapFromImage(img)
dc.DrawBitmap(bmp, x, y, True)
The result is this [1]. The buttons on the right are used to add sections (pipes, valves, etc) to the right frame. when you click on a button the program calculate the position and draw it, so the frame its non interactive, you cant clic on the segments of pipe or valves, cant resize it, etc.
This its very easy and simple, but as a new programmer it cost me some time (and am fairly proud of it). now I want to improve that, what I want to do now is to create a 3D-like interactive frame, where the user could create "by mouse" the pipe diagram, click on them to change properties etc.
what am aiming for its something like these [2] [3]. with a isometric background like this [4]
I guess thats not going to be easy (but neither was for me in the beginning what I did), but am decided to keep trying and studying to make it. What I want from you guys is directions..
Now I dont know where to start, am wondering "is this possible on wx?", "should I use openGL or something?". I need you to point to the right direction.
is this possible to implement with only wx? or I need pyopengl (witch I dont know anything about), or something like that?
thanks!!!...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想研究一下 Python-Ogre。 Ogre是一个开源的3D引擎,Python-Ogre允许你通过Python来操作场景。这可以让您专注于用户界面,而不是学习如何使用 pyopengl 绘制纹理三角形。
http://python-ogre.org/
You might want to investigate Python-Ogre. Ogre is an open source 3D engine, and Python-Ogre allows you to manipulate the scene through Python. This could allow you to focus on the user interface, instead of learning how to draw textured triangles with pyopengl.
http://python-ogre.org/