Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are trying to develop a painting area with integrated tools to draw lines, circles, selection tool and trying to enhance the image manipulation process.

Is it possible do the things in text view or drawing area?

tkinter, pygame, cairo which one is the best package to develop these components?

share|improve this question
Your question might be more appropriate over at Stack Overflow. – Kevin Bowen Dec 3 '12 at 6:53

I have no experience of the first two examples you give, but it's certainly possible, and indeed relatively easy, using cairo. Using Python, you can hook it up with PyCairo and GTK3.

The general idea would be to create a GTK DrawingArea and use the cairo context to draw what you want. Here's the shortest snippet I can come up with to give you the general idea:

#!/usr/bin/env python
from gi.repository import Gtk

def draw(widget, ctx):

win = Gtk.Window()
da = Gtk.DrawingArea()
win.connect("delete-event", Gtk.main_quit)
da.connect("draw", draw)

You could use Glade to handle building the GUI. If you felt so inclined, you could even use Quickly (sudo apt-get install quickly, getting started) to help get you started... quickly! Then it becomes as easy as quickly design, quickly edit, quickly run. Granted, it's a long way from a fully developed IDE experience such as VS (shudders), or Eclipse, but for this sort of scripting it's okay.

Unfortunately, documentation is rather patchy for GTK3 under Python, since almost all the docs are for C/CPP. There are however various basic tutorials on the web to get you started, and it's generally quite easy to figure things out.

Also, be aware that since GTK3 has been rolled out, PyGTK is essentially defunct; but a lot of documentation for it still exists on the web, and it's not always made explicitly clear that it relates to PyGTK instead of GTK3. Keep an eye out for that to ensure you don't lose time heading down the wrong path! Remember: PyGTK imports gtk,gdk,gobject; whilst GTK3 goes through gi.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.