pygobject / pycairo

Python bindings for cairo
https://pycairo.readthedocs.io
Other
613 stars 83 forks source link

Can we provide a constructor for XlibSurface? #278

Open stuaxo opened 1 year ago

stuaxo commented 1 year ago

I found this comment, which looks like it's out of date -

XlibSurface cannot be instantiated directly because Python interaction with Xlib would require open source Python bindings to Xlib which provided a C API. However, an XlibSurface instance can be returned from a function call when using pygtk http://www.pygtk.org/.

https://github.com/pygobject/pycairo/blob/7a725bd1a4e7ba1777835aab63d73de1a5d97399/cairo/__init__.pyi#L5292

python-xlib is an LGPL python binding with a current version (0.3, released Jul 02, 2021), which looks like a good fit. (It also has an examples directory which helps to get started).

@rjopek also has some C based xlib + cairo examples here, (placed under public domain): https://github.com/rjopek/xlib-cairo

We currently block instantiation here: https://github.com/pygobject/pycairo/blob/master/cairo/surface.c#L2323

Maybe we can allow this ?

The current situation leads to people using workarounds https://stackoverflow.com/questions/63606306/pycairo-how-to-correctly-instance-cairo-xlibsurface

I can't look any further right now as I'm not on my own computer.

rjopek commented 1 year ago

Hi,

The glfw-cairo project is oriented towards testing Cairo's ability to create simple user interfaces. I encourage you to use my examples, will be glad to see these examples in pycairo.

gl_08.c gl_11.c gl_13.c

https://harbour.pl/glfw-cairo/

-- Rafał