pycairo

How to get a PNG (alpha channel) screenshot of Gtk window?

为君一笑 提交于 2019-12-08 06:52:35
问题 Gtk windows support transparency using Cairo. I tried to get a screenshot with the code here. But it prints pure black for windows that use transparency. How can I make a screenshot (PNG) which caputures the alpha channel too? EDIT: I tried with alpha pixbuf, but the output is still with no alpha. Here's my code (sing Gtk#, but it's pretty identical to C): static void GetScreenshot(Gtk.Window win) { var pixbuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 500, 500); var pix = pixbuf

What is the logic behind d3.js nice() ticks

北战南征 提交于 2019-12-07 21:45:05
问题 I have generated some charts in d3.js. I use the following code to calculate the values to put in my y axis which works like a charm. var s = d3.scale.linear().domain([minValue, maxValue]); var ticks = s.nice().ticks(numberOfPoints); However I now have to write python code using pycairo which generates clones of the d3.js charts on the server side. My question is does anybody know the logic used in the above code, or something that can give similar results, so that I can replicate it in

Activating cairo-dependent features of graph_tool

余生长醉 提交于 2019-12-07 19:16:47
问题 I have been using the graph-tool library for a while now, thus far I hadn't really been using most of its drawing features. Today when trying to use graph_tool.draw.graph_draw I realised that I had configured graph-tool initially without cairo, ./configure --disable-cairo and this is exactly the graphics library that graph_draw uses. If I install cairo now, is there a way to activate the features of graph_tool that rely on cairo without having to remove and reinstall the whole graph_tool

get cairosvg working in windows

寵の児 提交于 2019-12-07 10:04:13
问题 Trying to get this code working: import cairosvg import os path = "D:/PyProjects/Bla/Temp" os.chdir(path) cairosvg.svg2pdf(url='Pic.svg', write_to='image.pdf') but get errors along similar to this post: Traceback (most recent call last): File "D:/work/lean_python/pdf/other.py", line 2, in <module> import cairosvg File "D:\env_python352\lib\site-packages\cairosvg\__init__.py", line 29, in <module> from . import surface File "D:\env_python352\lib\site-packages\cairosvg\surface.py", line 24, in

Using Pycairo to generate images dynamically and serve in Django

萝らか妹 提交于 2019-12-06 16:10:30
问题 I want to generate a dynamically created png image with Pycairo and serve it usign Django. I read this: Serve a dynamically generated image with Django. Is there a way to transport data from Pycairo surface directly into HTTP response? I'm doing this for now: data = surface.to_rgba() im = Image.frombuffer ("RGBA", (width, height), data, "raw", "RGBA", 0,1) response = HttpResponse(mimetype="image/png") im.save(response, "PNG") return response But it actually doesn't work because there isn't a

Activating cairo-dependent features of graph_tool

陌路散爱 提交于 2019-12-06 06:19:06
I have been using the graph-tool library for a while now, thus far I hadn't really been using most of its drawing features. Today when trying to use graph_tool.draw.graph_draw I realised that I had configured graph-tool initially without cairo , ./configure --disable-cairo and this is exactly the graphics library that graph_draw uses. If I install cairo now, is there a way to activate the features of graph_tool that rely on cairo without having to remove and reinstall the whole graph_tool module? This would spare a few hours of re-installation. (the make process takes about 3 hours on my

What is the logic behind d3.js nice() ticks

戏子无情 提交于 2019-12-06 06:00:50
I have generated some charts in d3.js. I use the following code to calculate the values to put in my y axis which works like a charm. var s = d3.scale.linear().domain([minValue, maxValue]); var ticks = s.nice().ticks(numberOfPoints); However I now have to write python code using pycairo which generates clones of the d3.js charts on the server side. My question is does anybody know the logic used in the above code, or something that can give similar results, so that I can replicate it in python to get nice values to use in my y axis? Lars Kotthoff D3 is open source, so you can look up the

Cairo context and persistence?

拥有回忆 提交于 2019-12-06 02:22:15
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 Pixmap or Window parameter)'. (Details: serial 230 error_code 9 request_code 53 minor_code 0) #! /usr/bin

get cairosvg working in windows

我怕爱的太早我们不能终老 提交于 2019-12-05 12:25:42
Trying to get this code working: import cairosvg import os path = "D:/PyProjects/Bla/Temp" os.chdir(path) cairosvg.svg2pdf(url='Pic.svg', write_to='image.pdf') but get errors along similar to this post : Traceback (most recent call last): File "D:/work/lean_python/pdf/other.py", line 2, in <module> import cairosvg File "D:\env_python352\lib\site-packages\cairosvg\__init__.py", line 29, in <module> from . import surface File "D:\env_python352\lib\site-packages\cairosvg\surface.py", line 24, in <module> import cairocffi as cairo File "D:\env_python352\lib\site-packages\cairocffi\__init__.py",

Using Pycairo to generate images dynamically and serve in Django

∥☆過路亽.° 提交于 2019-12-04 21:10:24
I want to generate a dynamically created png image with Pycairo and serve it usign Django. I read this: Serve a dynamically generated image with Django . Is there a way to transport data from Pycairo surface directly into HTTP response? I'm doing this for now: data = surface.to_rgba() im = Image.frombuffer ("RGBA", (width, height), data, "raw", "RGBA", 0,1) response = HttpResponse(mimetype="image/png") im.save(response, "PNG") return response But it actually doesn't work because there isn't a to_rgba call (this call I found using Google code but doesn't work). EDIT: The to_rgba can be replaced