pycairo

Cairo context and persistence?

扶醉桌前 提交于 2020-02-02 06:31:32
问题 I am just getting started using pycairo, and I ran into the following interesting error. The program I write creates a simple gtk window, draws a rectangle on it, and then has a callback to draw a random line on any kind of keyboard input. However, it seems that with each keyboard input, I have to create a new context, or I get an error at the moment the program receives first keyboard input (specifically, on the .stroke() line). Error is as follows, if it matters. 'BadDrawable (invalid

Trying to build pycairo on mac 10.8

巧了我就是萌 提交于 2020-01-24 21:34:05
问题 I have two Python installations. The one that came with the OS, and one I downloaded and installed manually, both are 2.7. The one I downloaded manually is my default Python. which python returns /Library/Frameworks/Python.framework/Versions/2.7/bin/python I have already installed Cairo, again, manually. I then downloaded py2cairo, went to the directory and ran ./waf configure , which then returned... ./set_options ./init ./configure Checking for program gcc or cc : /usr/bin/gcc Checking for

Python igraph unable to plot

纵然是瞬间 提交于 2020-01-15 03:46:27
问题 I wanted to perform a simple plot with igraph but i get the following error: File "testigraph.py", line 51, in <module> plot(g, **visual_style) File "/Library/Python/2.7/site-packages/igraph/drawing/__init__.py", line 446, in plot result = Plot(target, bbox, background=kwds.get("background", "white")) File "/Library/Python/2.7/site-packages/igraph/drawing/__init__.py", line 117, in __init__ self._surface_was_created = not isinstance(target, cairo.Surface) File "/Library/Python/2.7/site

Fit line to width with Pango and Cairo (Pycairo)

梦想的初衷 提交于 2020-01-03 14:15:14
问题 I've several lines of text and I'd like each to fit in width (scaling the font size) to the width of the Context. Is there a way of doing this? I'm using pangocairo and python for this. 回答1: I wish to have time for a working solution, but you can start with something like: import cairo import pango import pangocairo import sys W = 500 H = int(1.4 * W) surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, W, H) context = cairo.Context(surf) #draw a background rectangle: context.rectangle(0, 0, W, H)

How to install PyCairo 1.10 on Mac OSX with default python

为君一笑 提交于 2019-12-29 04:15:24
问题 Has anyone installed pycairo 1.10 on the mac using the new waf build? Its failing on can't find python headers. 回答1: I think waf is seriously broken for Mac OS X :( Here's how it worked for me. After python waf configure failed to find Python.h, I looked through the config.log file located in build_directory and found out that the true cause of failure was incompatible architecture. The waf script tries to build a simple source file with CPython calls in it using i386 architecture. It fails

KeyError 'MACOSX_DEPLOYMENT_TARGET' in waf on kubuntu

半世苍凉 提交于 2019-12-25 00:58:06
问题 I'm trying to install pycairo on kubuntu 13.04, and it's giving me an error complaining about MACOSX_DEPLOYMENT_TARGET: (virtualenv-3)naught101@naught101-chronos:/tmp/pycairo-1.10.0$ python waf configure ./options() Setting top to : /tmp/pycairo-1.10.0 Setting out to : /tmp/pycairo-1.10.0/build_directory ./configure() Checking for 'gcc' (c compiler) : ok Checking for program python : /home/naught101/.virtualenvs/virtualenv-3/bin/python Checking for python version : (3, 3, 2, 'final', 0)

Parallel drawing with GTK and Cairo in Python 3

℡╲_俬逩灬. 提交于 2019-12-23 17:02:18
问题 I am making a GTK application that will draw complex images that can take long time to finish. Because of that I can't do the drawing in the DrawingArea's 'draw' callback. I decided to use Python's multiprocessing module that allows true parallelism and does not have problems with GTK and thread-safety. Python's multiprocessing module uses Pickle protocol to communicate between processes. GTK and Cairo objects do not implement the protocol. My solution was to convert the Cairo surface to

Create cairo path from SVG file

时光毁灭记忆、已成空白 提交于 2019-12-23 15:02:07
问题 There must be something I am missing. I am on Windows and want to use python to take the paths from a SVG-file, scale them an place every single one of them on a new surface (or all on one, that doesn't really matter). I read about cairo here and on stackoverflow and it seemed to me, that it would fit my needs, but I could not find an easy way to generate a path from a svg file. Is there no easier solution than parsing the SVG by hand eg. with xml? 回答1: CairoSVG parses SVG files and renders

Using Cairo Regions in python with gi.repository

こ雲淡風輕ζ 提交于 2019-12-23 10:07:37
问题 I can't seem to get cairo regions working in within using the gintrospection. For example from gi.repository import cairo reg = cairo.Region() will give me Traceback (most recent call last): File "<stdin>", line 1, in <module> MemoryError and trying to get a region from Gdk.get_clip_region() will give me return info.invoke(*args) TypeError: Couldn't find conversion for foreign struct 'cairo.Region' What obvious thing am I missing? I can't find a way to iniatilize the library, and can't

Installing Cairo on OS X Lion

扶醉桌前 提交于 2019-12-22 12:25:38
问题 When I try to install Cairo on OS X Lion with Python 2.7.2 it just does not work, I can build and install it, but when it comes to import cairo in python it can't be found. I have tried the How to install PyCairo 1.10 on Mac OSX with default and it just produces this error "_cairo_xlib_surface_get_width", referenced from: _xlib_surface_get_width in surface.c.1.o ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status lipo: can't open input file: /var/folders/l9