python的简单图形 [英] simple graphics for python

查看:37
本文介绍了python的简单图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 python 进行需要可视化的模拟.我正在寻找 python 拥有的最简单的图形库.有什么可以让我做一些类似的事情:

I am making a simulation in python that needs visualization. I am looking for the most simple graphics library python has. Is there anything that can let me do something along the lines of:

setWindow(10,10)
setCube(0,0,1,1,1)#windowX, windowY, width, length, hight,
updateList = simUpdate
for update in updateList:
    removeShape(0,0)
    setCube(0,0,1,1,1)

有这么简单的吗?3d 不是必须的,但它会很好.我在 python 3.3 中工作,据我所知,pygames 还没有在 Mac 上更新.我一直在使用 tkinter,但想要更简单的东西.

Is there anything that simple? 3d is not a must but it would be nice. I'm working in python 3.3 and pygames hasn't been updated for that on a mac as far as I can tell. I've been working with tkinter but would like something a little easier.

推荐答案

对于简单的图形,可以使用 graphics.py.

For simple graphics, you can use graphics.py.

它不包含在 Python 中,因此您应该将其保存为 Python 文件(最好命名为 graphics.py),Python 可以在其中看到它 --- 在您的 sys.path.

It's not included with Python, so you should save it as a Python file (preferably named graphics.py) where Python can see it --- on your sys.path.

注意:也可以使用 pip install graphics.py 见链接

它非常容易学习并且已经内置了各种形状.没有原生 3D 图形(里面没有),但这样做很容易:对于一个立方体,绘制一个正方形,然后在旁边绘制另一个正方形,然后将正方形的一个角连接到另一个正方形中的相应角.

It's very easy to learn and has various shapes already built-in. There are no native 3D graphics (none are in there) but it's easy to do so: for a cube, draw one square and another one to the side, and connect one corner of a square to the corresponding corner in the other square.

使用 graphics.py 创建正方形的示例:

Example using graphics.py to create a square:

from graphics import *
win = GraphWin(width = 200, height = 200) # create a window
win.setCoords(0, 0, 10, 10) # set the coordinates of the window; bottom left is (0, 0) and top right is (10, 10)
mySquare = Rectangle(Point(1, 1), Point(9, 9)) # create a rectangle from (1, 1) to (9, 9)
mySquare.draw(win) # draw it to the window
win.getMouse() # pause before closing

这篇关于python的简单图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆