>>>>> "Luc" == Luc Lefebvre <[EMAIL PROTECTED]> writes:

    Luc> Hi, I am experimenting with glade/gtk and python. (python
    Luc> 2.2, glade2, gtk-1.2).  I tried an example with a window and
    Luc> a simple DrawingArea.  I can get the window up and bind the
    Luc> mainquit method to the event but when I try any of the draw
    Luc> functionis (for ex. draw_point) it doesn't work.  I get the
    Luc> message:

It's not a glade problem.  The traceback is correct, gtk.DrawingArea
doesn't have the draw_point method.  gtk.gdk.Drawable does

When the application is realized, you'll be passed at gtk.DrawingArea
widget.  The window attribute of that widget is a gtk.gdk.Drawable.
Here is a simple example that illustrates how to draw.

Note the use of widget.window to get the gtk.gdk.drawable.

JDH

import pygtk
pygtk.require('2.0')
import gtk
from gtk import gdk

def draw(widget):
    gc = widget.window.new_gc()
    gc.line_style = gdk.LINE_ON_OFF_DASH
    gc.set_dashes(0, [6,6])
    x = range(0,100,2)
    y = [2*val for val in x]
    
    widget.window.draw_lines( gc, zip(x, y) )
    
def configure_event(widget, event):
    draw(widget)
    return gtk.TRUE

def expose_event(widget, event):
    draw(widget)
    return gtk.TRUE

win = gtk.Window()
win.set_size_request(100, 200)
win.show()


vbox = gtk.VBox()
vbox.show()
win.add(vbox)

da = gtk.DrawingArea()
da.connect('configure_event', configure_event)
da.connect('expose_event', configure_event)
da.show()
vbox.pack_start(da, gtk.TRUE, gtk.TRUE)


button = gtk.Button('Quit')
button.show()
vbox.pack_start(button, gtk.FALSE, gtk.FALSE)
button.connect('clicked', gtk.mainquit)

gtk.mainloop()
_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to