0

我知道在 GTK+ 中你可以创建按钮、事件等,但是有没有办法让你在 cairo 中创建的东西(假设你画一个圆圈)成为可点击的按钮?我想我对 GTk 和 cairo 之间的关系感到困惑。

4

2 回答 2

1

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
于 2013-12-01T11:30:13.567 回答
1

正如 giamt 所说,你需要一个画布。对于 GTK 2,GooCanvas 可能会有所帮助。对于 GTK 3(甚至可能是 GTK 2),Clutter 可能是首选。

于 2013-12-02T09:53:43.213 回答