On Fri, 16 Mar 2001, dblank wrote:

> Hello, I have just begun to work with gtk under Python. Almost everything 
> works as advertised, except I can't seem to get draw_array() to work. I think 
> I may be doing something wrong. Here's my sample code:
> 
> import Numeric
> from gtk import *
> 
> class Example(GtkWindow):
>     def __init__(self):
>         win = GtkWindow()
>         win.connect("destroy", mainquit)
This bit is wrong.  To subclass a Gtk object, call its constructor, just
like for any other python object.

>         self.pic = GtkDrawingArea()
>         self.pic.show()
>         win.add(self.pic)
Use self rather than win here.

>         self.pic.connect("expose_event", self.on_exposure)
>         self.pic.set_events(GDK.EXPOSURE_MASK)
> 
>         self.pixmap = create_pixmap(win, 50, 50)
>         gc = self.pixmap.new_gc()
> 
>         self.buff = Numeric.ones((50, 50, 3), 'b')
>         draw_array(self.pixmap, gc, 0, 0, 0, self.buff)

Use the constant for the fifth argument here (GDK.RGB_DITHER_NONE
corresponds to 0 here).

>         self._o = win._o
Don't do this.  If you chain to the GtkWindow constructor, it shouldn't be
necessary.

> 
>     def on_exposure(self, widget, event):
>         gc = self.pic.get_style().fg_gc[STATE_NORMAL]
>         self.pic.draw_pixmap(gc, self.pixmap, 0, 0, 0, 0, 50, 50)
> 

You need to push the GdkRGB visual before creating widgets that will use
the GdkRGB functions.  So add the following line here:

  push_rgb_visual()
> example = Example()

and optionally, have pop_rgb_visual() afterwards.

> example.show()
> mainloop()
> 
> 
> I get a core dump if I run the above. Any hints you can provide would be much 
> welcomed!
> 
> (I'm running Python2.0, and I have Numpy (Numeric-17.3.0) installed, with  
> pygtk-0.6.6. draw_array is defined, but crashes when called.)

James.

-- 
Email: [EMAIL PROTECTED]
WWW:   http://www.daa.com.au/~james/



_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk

Reply via email to