Hello,
I am new to pygtk but was very excited to find out about it. It seemed
like the easiest way to get started with some simple graphics programs.
I found an excellent tutorial (with example for DrawingArea) at:
http://www.moeraki.com/pygtktutorial/sec-drawingareamethods.html
The DrawingArea example given on the page would be all that I need right
now to get started. Unfortunately, when I upgraded my RedHat7.3
(python1.5, gtk+) to 8.0 (python2.2, gtk2+) things weren't working
according to tutorial any more. That's quite understandable, but they
don't seem to work even after I rewrote things according to FAQ-2.3
(migrating from PyGTK-0 to PyGTK-2). All I need is to get the basic
DrawingArea methods to work in PyGTK2. Here is how I rewrote a simple
test example (based on the above given tutorial):
--------------------------
#!/usr/bin/env python2
# Draw a blue rectangle on DrawingArea, that's all
import gtk
import string
def area_expose_cb(area, event):
global gc
gc = style.fg_gc[gtk.STATE_NORMAL]
gc.foreground = blue
area.draw_rectangle(gc, gtk.TRUE, 50, 50, 100, 50)
if __name__ == "__main__":
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("drawing test example")
window.connect("destroy", gtk.mainquit)
#gtk.push_rgb_visual() ... this doesn't work any more in pygtk2
area = gtk.DrawingArea()
#gtk.pop_visual() ... this doesn't work any more in pygtk2
width = 400; hight = 300
area.size(width, hight)
window.add(area)
colormap = area.get_colormap()
blue = colormap.alloc(0, 0, 65535)
area.connect("expose-event", area_expose_cb)
area.show()
window.show()
gtk.mainloop()
-------------------------------
When I try to run this, I get an error message:
AttributeError: 'gtk.DrawingArea' object has no atribute
'draw_rectangle'
(is it possible that DrawingArea methods are not implemented in pygtk2
yet?)
I admit that I don't understand what's neccessary to open a window and
create a graphics context in pygtk2. Therefore, it would be a _great_
help to have the tutorial DrawingArea example at www.moreaki.com
rewritten for pygtk2.
I'd really appreciate a lot if someone could provide a working example
of some simple DrawingArea methods (like the one above, but working :-).
Thanks very much,
-Viktor
--
===================================================================
Viktor Hornak
SUNY at Stony Brook
Stony Brook, NY 11794 E-mail: [EMAIL PROTECTED]
===================================================================
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/