0
votes

I understand that in GTK+ you can create buttons, events, etc., but is there a way to make something you create in cairo (lets say you draw a circle) a button that is clickable? I guess I am confused on the relationship between GTk and cairo.

2

2 Answers

1
votes

Cairo is a 2D graphic library that provides drawing API, GTK+ uses Cairo to draw itself, for clicking items made with Cairo you might want to have a look at a Canvas such as GooCanvas [1], it supports introspection so you can use it from Python too (pygobject 3) [2]

Items [3] created with GooCanvas support events and are drawn with Cairo underneath, so you can draw a circle [4] and use the events as you prefer.

  1. https://wiki.gnome.org/Projects/PyGObject
  2. https://wiki.gnome.org/action/show/Projects/PyGObject?action=show&redirect=PyGObject
  3. https://developer.gnome.org/goocanvas/unstable/GooCanvasItem.html
  4. https://developer.gnome.org/goocanvas/unstable/GooCanvasEllipse.html
1
votes

As gianmt said you need a canvas. For GTK 2, GooCanvas may help. For GTK 3 (and maybe even GTK 2), Clutter may be preferred.