2

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?

1
  • Your question might be more appropriate over at Stack Overflow. Dec 3, 2012 at 6:53

1 Answer 1

2

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):
    ctx.set_source_rgba(1.0,0.0,0.0,1.0)
    ctx.move_to(0,0)
    ctx.rel_line_to(100.0,100.0)
    ctx.stroke()

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

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .