PyQt and PyCairo
I know it's possible to place a PyCairo surface inside a Gtk Drawing Area. But I think Qt is a lot better to work with, so I've been wondering if there's anyway to place a PyCairo surface inside some Qt component?
Asked by: Robert839 | Posted: 28-01-2022
Answer 1
Qt's own OpenGL based surfaces (using QPainter) are known to be much faster than Cairo. Might you explain why you want specifically Cairo in Qt?
For the basics of using QPainter see this excerpt from the book "C++ GUI Programming with Qt4", and while it's C++ code, the PyQt implementation will be parallel.
As for joining Cairo with Qt... This article in ArsTechnica sheds some light - it seems nothing that could help you exists currently (iow., nobody tried such marriage).
Answered by: Aida268 | Posted: 01-03-2022Answer 2
For plotting with you should also consider matplotlib, which provides a higher level API and integrates well with PyQT.
Answered by: Fenton565 | Posted: 01-03-2022Similar questions
python - rotate text around its center in pycairo
community.
I know that there are many answers here, manuals, tutorials and references over the internets and amny more about this question. Also I know that knowledge of linear algebra is required.
But when I think about time to figuring out all the theory and solving exercises in practice - my head is blowing off and I can't do the simplest things :(
Please, if you know a little fast solution how to make r...
python - Trying to build pycairo on mac 10.8
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
python - Text and lines in pycairo
I'm having a little bit of trouble with pycairo. I want to draw a chord chart, but for some reason I don't quite understand it only displays the text, not the lines it should be drawing.
I use pygtk (3.0) and pycairo. Here's the result of what this code draws
python - pyCairo Stack images
I'm using pycairo to compose images.
Currently I am creating my ImageSurface from a base image and setting a Context from this Surface.
surface = cairo.ImageSurface.create_from_png("base.png")
ctx = cairo.Context (surface)
Then I can for example add text on top:
# draw text
ctx.select_font_face('Sans')
ctx.set_font_size(20)
ctx.move_to(10, 90)
ctx.set_source_rgb(1....
python - How to merge path with pycairo?
I am drawing with pycairo using curve_to , here's the code :
ctx.move_to(0.4,0.8)
ctx.curve_to(0.3,0.4 ,0.4,0.4 ,0.4,0.4)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(0.001)
ctx.fill()
ctx.move_to(0.4,0.8)
ctx.line_to(0.5,0.8)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(0.001)
ctx.stroke()
ctx.move_to(0.5,0.8)
ctx.curve_to(0.6,0.4 ,0.5,0.4 ,0.5,0.4)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width...
python - Draw a shape on top of an image using Gtk and pycairo
I have recently started using glade, python gtk+ and cairo to build GUI apps. I have constructed a DrawingArea widget in which I have used pixbuf to paint an image. However when i try to draw shapes on the image, the shapes get drawn behind the image.
def on_draw(self, wid, cr):
#cr.rectangle(1500, 300, 400, 800)
#cr.stroke()
self.pb = GdkPixbuf.Pixbuf.new_from_file_at_scale("image2.jpg", 1920...
python - Arrow in pycairo
I need to draw a directed line or arrow.
context.move_to (10,10)
context.line_to(10,100)
this provide an undirected line but I need an arrow. How can I accomplish this in pycairo?
python - How to delete an item in Pycairo
I'm trying to make a simple drawing program. I can draw a rectangle based on the mouse coordinates , but I don't know how to delete old elements so that I have the same behavior as in the second video.How can I implement the behavior from the second video (Where the rectangle is on a white background)?
Now here's how: https://youtu.be/a7MWjOXk84Y
Correct ...
python - PyCairo : how to resize & rotate an image by its center to a final canvas
Using PyCairo, I want to be able to have a method that can put, resize & rotate a given ImageSurface on a context, but rotating by the center of the image (not the top-left)
Okay I've tried the examples I've found here but without any success.
Let's introduce the "context" in details.
I've got a "finale" ImageSurface (say A) on which some other images & texts are written.
I want to...
python - rotate text around its center in pycairo
community.
I know that there are many answers here, manuals, tutorials and references over the internets and amny more about this question. Also I know that knowledge of linear algebra is required.
But when I think about time to figuring out all the theory and solving exercises in practice - my head is blowing off and I can't do the simplest things :(
Please, if you know a little fast solution how to make r...
python - pycairo install error on osx
While I am installing pycairo using easy_install on osx, there is an error message as following:
Searching for pycairo
Reading http://pypi.python.org/simple/pycairo/
Reading http://cairographics.org/pycairo
Best match: pycairo 1.10.0
Downloading http://cairographics.org/releases/pycairo-1.10.0.tar.bz2
Processing pycairo-1.10.0.tar.bz2
error: Couldn't find a setup script in /tmp/easy_install-hnheQI/pycairo-1...
python - Trying to build pycairo on mac 10.8
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
python - Text and lines in pycairo
I'm having a little bit of trouble with pycairo. I want to draw a chord chart, but for some reason I don't quite understand it only displays the text, not the lines it should be drawing.
I use pygtk (3.0) and pycairo. Here's the result of what this code draws
python - Pycairo fails to produce PDF when drawing 100's of fills
Drawing a trivial array of filled circles fails when more than about a thousand appear on a PDF surface, yet a PNG render of the same context has no problem. I have tried a range of solutions and cannot readily get an error message or other clues -- any ideas, please? (under Mac OS X 10.12.6, latest libraries installed)
import cairo
Pi=3.14159265
# this works, Python 2.7
surface = cairo.PDFSurface("cairoT...
python - pyCairo Stack images
I'm using pycairo to compose images.
Currently I am creating my ImageSurface from a base image and setting a Context from this Surface.
surface = cairo.ImageSurface.create_from_png("base.png")
ctx = cairo.Context (surface)
Then I can for example add text on top:
# draw text
ctx.select_font_face('Sans')
ctx.set_font_size(20)
ctx.move_to(10, 90)
ctx.set_source_rgb(1....
python - How to merge path with pycairo?
I am drawing with pycairo using curve_to , here's the code :
ctx.move_to(0.4,0.8)
ctx.curve_to(0.3,0.4 ,0.4,0.4 ,0.4,0.4)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(0.001)
ctx.fill()
ctx.move_to(0.4,0.8)
ctx.line_to(0.5,0.8)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(0.001)
ctx.stroke()
ctx.move_to(0.5,0.8)
ctx.curve_to(0.6,0.4 ,0.5,0.4 ,0.5,0.4)
ctx.set_source_rgb(0,0,0)
ctx.set_line_width...
python - Draw a shape on top of an image using Gtk and pycairo
I have recently started using glade, python gtk+ and cairo to build GUI apps. I have constructed a DrawingArea widget in which I have used pixbuf to paint an image. However when i try to draw shapes on the image, the shapes get drawn behind the image.
def on_draw(self, wid, cr):
#cr.rectangle(1500, 300, 400, 800)
#cr.stroke()
self.pb = GdkPixbuf.Pixbuf.new_from_file_at_scale("image2.jpg", 1920...
python - Arrow in pycairo
I need to draw a directed line or arrow.
context.move_to (10,10)
context.line_to(10,100)
this provide an undirected line but I need an arrow. How can I accomplish this in pycairo?
PyCairo Pip Install in python 3.8 on windows 10 is failing
I know a lot of threads have been made about this but none of them have solved my problem.
I'm trying to install Cairo through pip install. I am using the command prompt. Here's the error message:
C:\python38\Scripts>pip install cairo
ERROR: Could not find a version that satisfies the requirement cairo (from versions: none)
ERROR: No matching distribution found for cairo
I was reading t...
Still can't find your answer? Check out these communities...
PySlackers | Full Stack Python | NHS Python | Pythonist Cafe | Hacker Earth | Discord Python