PyX python脚本将文件写入光盘,但不写入屏幕

2024-09-25 00:36:20 发布

您现在位置:Python中文网/ 问答频道 /正文

嗨:我有一台win764位机器,并尝试使用PyX(http://pyx.sourceforge.net/examples/drawing/index.html)的示例。我在Python2.7和3.5(在安装3.5之前卸载了2.7)中尝试过它们。在所有情况下,PyX都会将其文件写入我的硬盘,但我的电脑屏幕上什么也没有显示??这是第一个示例,来自:http://pyx.sourceforge.net/examples/drawing/path.html

from pyx import *

c = canvas.canvas()
c.stroke(path.line(0, 0, 3, 0))
c.stroke(path.rect(0, 1, 1, 1))
c.fill(path.circle(2.5, 1.5, 0.5))
c.writeEPSfile("path")
c.writePDFfile("path")
c.writeSVGfile("path")

有人知道出什么问题了吗? 谢谢, 史蒂夫


Tags: path机器http示例indexnetstrokehtml
1条回答
网友
1楼 · 发布于 2024-09-25 00:36:20

你看过你链接的文件了吗?它声明它正在生成一个canvas对象并将其写入多个文件。它并没有声明它也在把它的对象写到屏幕上。在

Description This first path example demonstrates how to create a canvas, how to draw some simple geometric objects onto it and how to write the result into a PostScript or PDF file. First we import all top-level symbols of the PyX package by the usual Python import statement. In the further examples we will always use this form of the import statement to make the PyX package available to our scripts. Now we can create a canvas instance c, onto which our basic paths are drawn. The later is done by passing some path instances (a line, a rectangle and a circle) to the strokes or fill methods of the canvas instance we just created and stored in the variable c. Finally, we call the writeEPSfile and writePDFfile methods of the canvas to create an EPS and a PDF file of our drawing. While typically you will only create either a PostScript or a PDF file, in our examples we always create both output formats to have them both available for download. This example, in addition, shows some basics of the PyX coordinate system. The first coordinate (often referred to as x) goes horizontally from left to right and the second coordinate (y) goes vertically from the bottom to the top. The default unit is 1 cm. The boundary of the resulting image is calculated automatically.

阅读主页页面会告诉你这一点

PyX is a Python package for the creation of PostScript, PDF, and SVG files. It combines an abstraction of the PostScript drawing model with a TeX/LaTeX interface. Complex tasks like 2d and 3d plots in publication-ready quality are built out of these primitives.

它不会写入你的屏幕。它言行一致。在

相关问题 更多 >