Hi,
I am experimenting with glade/gtk and python. (python 2.2, glade2, gtk-1.2). I tried
an example with a window and a simple DrawingArea. I can get the window up and bind
the mainquit method to the event but when I try any of the draw functionis (for ex.
draw_point) it doesn't work. I get the message:
[EMAIL PROTECTED]:~/Projects/sls_data_browser$ python sls_data_browser.py
1
Traceback (most recent call last):
File "sls_data_browser.py", line 77, in ?
app.drawingarea.draw_point(gc,100,100)
AttributeError: 'gtk.DrawingArea' object has no attribute 'draw_point'
My python script is:
#!/usr/bin/env python
import sys
try:
import pygtk
# tell pyGTK, if possible, that we want GTKv2
pygtk.require("2.0")
except:
# Some distributions come with GTK2, but not pyGTK
pass
try:
import gtk
import gtk.glade
except:
print "You need to install pyGTK or GTKv2",
print "or set your PYTHONPATH correctly."
print "try: export PYTHONPATH=",
print "/usr/local/lib/python2.2/site-packages"
sys.exit(1)
#now we have both gtk and gtk.glade imported
#Also, we know we are running GTK v2
class appgui:
def __init__(self):
"""
In this init we are going to display the main
serverinfo window
"""
gladefile="sls_data_browser.glade"
windowname="window1"
self.wTree=gtk.glade.XML(gladefile,windowname)
self.drawingarea=self.wTree.get_widget("drawingarea1")
gc = self.drawingarea.get_style()
gc.line_width= 1
dic = {"on_window1_destroy":(gtk.mainquit)}
self.wTree.signal_autoconnect(dic)
return
# we start the app like this...
app = appgui()
gc = app.drawingarea.get_style()
print gc.line_width
app.drawingarea.draw_point(gc,100,100)
gtk.mainloop()
I thought that I was using gtk-2 but a sys.path indicates:
>>> sys.path
['', '/usr/lib/python2.2', '/usr/lib/python2.2/plat-linux2',
'/usr/lib/python2.2/lib-tk', '/usr/lib/python2.2/lib-dynload',
'/usr/local/lib/python2.2/site-packages', '/usr/lib/python2.2/site-packages',
'/usr/lib/python2.2/site-packages/PIL', '/usr/lib/python2.2/site-packages/gtk-1.2',
'/usr/lib/site-python']
Even though I have both gtk-1.2 and gtk-2.0 installed. I still would have expected
the method supported in 1.2. In fact a non-glade version does work (using
draw_rectangle).
Any insight would be appreciated.
tia
--
Luc Lefebvre
In the beginner's mind there are many possibilities,
in the expert's mind there are few. <Shunryu Suzuki>
Key fingerprint = D2E5 5E35 B910 6F4E 0242 EC63 0FD9 96D0 C7F4 784E
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/