chris200x9
April 27th, 2008, 06:20 PM
hi, I'm trying to make my first GUI apps, I installed pygtk but when I follow a tutorial and try to execute this:
# Load GTK
import gtk
# Load our own source code from gtktest.py
# There you can find the main class gtktest()
from gtktest import gtktest
# Load sugar libraries
from sugar.activity import activity
class gtktestActivity(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self._name = handle
# Set title for our Activity
self.set_title('gtk test')
# Attach sugar toolbox (Share, ...)
toolbox = activity.ActivityToolbox(self)
self.set_toolbox(toolbox)
toolbox.show()
# Create the main container
self._main_view = gtk.VBox()
# Import our class gtktest():
# Step 1: Load class, which creates gtktest.widget
self.gtktest = gtktest()
# Step 2: Remove the widget's parent
if self.gtktest.widget.parent:
self.gtktest.widget.parent.remove(self.gtktest.wid get)
# Step 3: We attach that widget to our window
self._main_view.pack_start(self.gtktest.widget)
# Display everything
self.gtktest.widget.show()
self._main_view.show()
self.set_canvas(self._main_view)
self.show_all()
I get this error:
chris200x9@chris200x9-desktop:~$ ~/untitled.py
/home/chris200x9/untitled.py: line 2: import: command not found
from: can't read /var/mail/gtktest
from: can't read /var/mail/sugar.activity
/home/chris200x9/untitled.py: line 11: syntax error near unexpected token `('
/home/chris200x9/untitled.py: line 11: `class gtktestActivity(activity.Activity):'
what am I doing wrong?
# Load GTK
import gtk
# Load our own source code from gtktest.py
# There you can find the main class gtktest()
from gtktest import gtktest
# Load sugar libraries
from sugar.activity import activity
class gtktestActivity(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self._name = handle
# Set title for our Activity
self.set_title('gtk test')
# Attach sugar toolbox (Share, ...)
toolbox = activity.ActivityToolbox(self)
self.set_toolbox(toolbox)
toolbox.show()
# Create the main container
self._main_view = gtk.VBox()
# Import our class gtktest():
# Step 1: Load class, which creates gtktest.widget
self.gtktest = gtktest()
# Step 2: Remove the widget's parent
if self.gtktest.widget.parent:
self.gtktest.widget.parent.remove(self.gtktest.wid get)
# Step 3: We attach that widget to our window
self._main_view.pack_start(self.gtktest.widget)
# Display everything
self.gtktest.widget.show()
self._main_view.show()
self.set_canvas(self._main_view)
self.show_all()
I get this error:
chris200x9@chris200x9-desktop:~$ ~/untitled.py
/home/chris200x9/untitled.py: line 2: import: command not found
from: can't read /var/mail/gtktest
from: can't read /var/mail/sugar.activity
/home/chris200x9/untitled.py: line 11: syntax error near unexpected token `('
/home/chris200x9/untitled.py: line 11: `class gtktestActivity(activity.Activity):'
what am I doing wrong?