Re: drawing, structured graphics

2008-03-13 Thread Jim Gettys

On Thu, 2008-03-13 at 17:29 +0100, Marco Pesenti Gritti wrote:
> On Thu, Mar 13, 2008 at 5:13 PM, Jim Gettys <[EMAIL PROTECTED]> wrote:
> > Sayamindu,
> >
> >  I think Victor is asking for something at a higher level of abstraction;
> >  particularly what goes by the name of a canvas in various toolkits.
> >
> >  I thought we were using goocanvas, or something like that on top of
> >  cairo for TK canvas equivalent functionality...
> 
> Sugar is using hippo-canvas, which is pretty good for css-like
> graphics but is very much of a work in progress and it's not very
> convenient for completely free form graphics.
> 
> On the short term I suggest to use goocanvas which is more mature,
> more convenient for free form graphics and has also simple layout
> support. We should add it to the builds, it's small and useful. (the
> API is very similar to libgnomecanvas which was originally a port of
> tk canvas).
> 
> On the longer term I'm putting all my bets on Havoc plan:
> http://mail.gnome.org/archives/gtk-devel-list/2008-March/msg00017.html
> 
> Marco

This looks like a good strategy to me...  Havoc generally delivers what
he says he will, and has shown good taste :-).

 - Jim

-- 
Jim Gettys
One Laptop Per Child


___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: drawing, structured graphics

2008-03-13 Thread Marco Pesenti Gritti
On Thu, Mar 13, 2008 at 5:13 PM, Jim Gettys <[EMAIL PROTECTED]> wrote:
> Sayamindu,
>
>  I think Victor is asking for something at a higher level of abstraction;
>  particularly what goes by the name of a canvas in various toolkits.
>
>  I thought we were using goocanvas, or something like that on top of
>  cairo for TK canvas equivalent functionality...

Sugar is using hippo-canvas, which is pretty good for css-like
graphics but is very much of a work in progress and it's not very
convenient for completely free form graphics.

On the short term I suggest to use goocanvas which is more mature,
more convenient for free form graphics and has also simple layout
support. We should add it to the builds, it's small and useful. (the
API is very similar to libgnomecanvas which was originally a port of
tk canvas).

On the longer term I'm putting all my bets on Havoc plan:
http://mail.gnome.org/archives/gtk-devel-list/2008-March/msg00017.html

Marco
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: drawing, structured graphics

2008-03-13 Thread Victor Lazzarini
goocanvas seems to be what I was looking for.

Thanks

At 16:13 13/03/2008, Jim Gettys wrote:
>Sayamindu,
>
>I think Victor is asking for something at a higher level of abstraction;
>particularly what goes by the name of a canvas in various toolkits.
>
>I thought we were using goocanvas, or something like that on top of
>cairo for TK canvas equivalent functionality...
>
>Marco?
>  - Jim
>
>On Mon, 2008-03-10 at 20:08 +0530, Sayamindu Dasgupta wrote:
> > On Mon, Mar 10, 2008 at 7:39 PM, Victor Lazzarini
> > <[EMAIL PROTECTED]> wrote:
> > > Hi all,
> > >
> > >  what would be the best bet for going about implementing
> > >  structured graphics a-la Tkinter's canvas class in XO
> > >  activities? Would it be PyCairo? or PyGTK (gtk/gdk)?
> > >
> >
> > I guess PyCairo would be the best :-)
> >
> >
> > >  also could anyone point to a PyGTK custom widget
> > >  tutorial somewhere? I had a look at one in
> > > 
> http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
> > >
> > >  but the code wouldn't work. Are there others?
> >
> > 
> > http://pymag.phparch.com/c/issue/view/60
> > 
> >
> > Last time I checked - the code was working. You'll have to register to
> > download the issue (it should be a free download).
> >
> > Thanks,
> > Sayamindu
> >
>--
>Jim Gettys
>One Laptop Per Child

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth

___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: drawing, structured graphics

2008-03-13 Thread Jim Gettys
Sayamindu,

I think Victor is asking for something at a higher level of abstraction;
particularly what goes by the name of a canvas in various toolkits.

I thought we were using goocanvas, or something like that on top of
cairo for TK canvas equivalent functionality...

Marco?
 - Jim

On Mon, 2008-03-10 at 20:08 +0530, Sayamindu Dasgupta wrote:
> On Mon, Mar 10, 2008 at 7:39 PM, Victor Lazzarini
> <[EMAIL PROTECTED]> wrote:
> > Hi all,
> >
> >  what would be the best bet for going about implementing
> >  structured graphics a-la Tkinter's canvas class in XO
> >  activities? Would it be PyCairo? or PyGTK (gtk/gdk)?
> >
> 
> I guess PyCairo would be the best :-)
> 
> 
> >  also could anyone point to a PyGTK custom widget
> >  tutorial somewhere? I had a look at one in
> >  
> > http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
> >
> >  but the code wouldn't work. Are there others?
> 
> 
> http://pymag.phparch.com/c/issue/view/60
> 
> 
> Last time I checked - the code was working. You'll have to register to
> download the issue (it should be a free download).
> 
> Thanks,
> Sayamindu
> 
-- 
Jim Gettys
One Laptop Per Child


___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: drawing, structured graphics

2008-03-10 Thread C. Scott Ananian
On Mon, Mar 10, 2008 at 10:09 AM, Victor Lazzarini
<[EMAIL PROTECTED]> wrote:
>  what would be the best bet for going about implementing
>  structured graphics a-la Tkinter's canvas class in XO
>  activities? Would it be PyCairo? or PyGTK (gtk/gdk)?
>
>  also could anyone point to a PyGTK custom widget
>  tutorial somewhere? I had a look at one in
>  http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
>
>  but the code wouldn't work. Are there others?

goocanvas is another option; it's what I used for my icon-editor activity.

Attached is the goocanvas 'hello, world' activity using goocanvas'
python bindings.
 --scott

-- 
 ( http://cscott.net/ )
#!/usr/bin/python2.5
"""Translate the example in goocanvas' manual into python."""

import gtk
import goocanvas
import sys

def on_delete_event(widget, event, data=None):
"""This is our handler for the "delete-event" signal of the
 window, which is emitted when the 'x' close button is clicked. We
 just exit here."""
sys.exit(0)

def on_rect_button_press(item, target, event, data=None):
"""This handles button presses in item views. We simply output a
message to the console."""
print "rect item received button press!"
return True

def main():
window = gtk.Window(gtk.WINDOW_TOPLEVEL)

window.set_default_size(640, 600)
window.show()
window.connect('delete_event', on_delete_event)
  
scrolled_win = gtk.ScrolledWindow()
scrolled_win.set_shadow_type (gtk.SHADOW_IN)
scrolled_win.show()
window.add(scrolled_win)

canvas = goocanvas.Canvas()
canvas.set_size_request(600, 450)
canvas.set_bounds(0,0,1000,1000)
canvas.show()
scrolled_win.add(canvas)

root = canvas.get_root_item()
  
# Add a few simple items.
rect_item = goocanvas.Rect(parent=root,
   x=100, y=100, width=400, height=400,
   line_width=10.0, radius_x=20.0,
   radius_y=10.0, stroke_color='yellow',
   fill_color='red')

text_item = goocanvas.Text (parent=root, text="Hello World", x=300, y=300,
anchor=gtk.ANCHOR_CENTER, font='Sans 24')
text_item.rotate(45, 300, 300)
  
# Connect a signal handler for the rectangle item.
rect_item.connect('button_press_event', on_rect_button_press)
  
# Pass control to the GTK+ main event loop.
gtk.main()

if __name__=='__main__':
main()
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: drawing, structured graphics

2008-03-10 Thread Chris Hager
Victor Lazzarini wrote:
> Hi all,
>
> what would be the best bet for going about implementing
> structured graphics a-la Tkinter's canvas class in XO
> activities? Would it be PyCairo? or PyGTK (gtk/gdk)?
>
> also could anyone point to a PyGTK custom widget
> tutorial somewhere? I had a look at one in
> http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
>   


Also, on the Wiki there's a PyGTK section with some nice xo-related 
tutorials.

  http://wiki.laptop.org/go/PyGTK


Chris
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: drawing, structured graphics

2008-03-10 Thread Sayamindu Dasgupta
On Mon, Mar 10, 2008 at 7:39 PM, Victor Lazzarini
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
>  what would be the best bet for going about implementing
>  structured graphics a-la Tkinter's canvas class in XO
>  activities? Would it be PyCairo? or PyGTK (gtk/gdk)?
>

I guess PyCairo would be the best :-)


>  also could anyone point to a PyGTK custom widget
>  tutorial somewhere? I had a look at one in
>  http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
>
>  but the code wouldn't work. Are there others?


http://pymag.phparch.com/c/issue/view/60


Last time I checked - the code was working. You'll have to register to
download the issue (it should be a free download).

Thanks,
Sayamindu

-- 
Sayamindu Dasgupta
[http://sayamindu.randomink.org/ramblings]
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


Re: drawing, structured graphics

2008-03-10 Thread Tomeu Vizoso
On Mon, Mar 10, 2008 at 3:09 PM, Victor Lazzarini
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
>  what would be the best bet for going about implementing
>  structured graphics a-la Tkinter's canvas class in XO
>  activities? Would it be PyCairo? or PyGTK (gtk/gdk)?

Pycairo looks best to me. There's not much info specific to pycairo,
but between the C docs and the examples in the pycairo tarball you
could get an idea of how things work.

>  also could anyone point to a PyGTK custom widget
>  tutorial somewhere? I had a look at one in
>  http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/
>
>  but the code wouldn't work. Are there others?

Why is the code not working? Perhaps we could discuss it here so other
interested people can participate, and perhaps someone will add a
howto to the wiki?

Here you can find other related articles:

http://www.pygtk.org/articles.html

Good luck,

Tomeu
___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel


drawing, structured graphics

2008-03-10 Thread Victor Lazzarini
Hi all,

what would be the best bet for going about implementing
structured graphics a-la Tkinter's canvas class in XO
activities? Would it be PyCairo? or PyGTK (gtk/gdk)?

also could anyone point to a PyGTK custom widget
tutorial somewhere? I had a look at one in
http://www.learningpython.com/2006/07/25/writing-a-custom-widget-using-pygtk/

but the code wouldn't work. Are there others?

Thanks

Victor

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth

___
Devel mailing list
Devel@lists.laptop.org
http://lists.laptop.org/listinfo/devel