Changes

Line 1: Line 1:  
= Toolbar =
 
= Toolbar =
   −
This snippet shows how an activity would have a toolbar with two buttons:
+
This snippet shows how an activity would have a toolbar with a button and a gtk.TextView widget embedded in a hippo Canvas:
    +
import logging
 
  import hippo
 
  import hippo
 +
import gtk
 
   
 
   
 
  from sugar.activity.Activity import Activity
 
  from sugar.activity.Activity import Activity
Line 16: Line 18:  
         self.add(canvas)
 
         self.add(canvas)
 
         canvas.show()
 
         canvas.show()
       
+
 
         vbox = hippo.CanvasBox()
 
         vbox = hippo.CanvasBox()
 
         canvas.set_root(vbox)
 
         canvas.set_root(vbox)
Line 23: Line 25:  
         vbox.append(toolbar)
 
         vbox.append(toolbar)
 
   
 
   
         button1 = Button('button1_icon')
+
         button = Button('theme:stock-close')
         button1.connect("activated", self._button1_activated_cb)
+
         button.connect("activated", self._button_activated_cb)
         self.append(button1)
+
         toolbar.append(button)
 +
 +
        textViewWidget = hippo.CanvasWidget()
 +
        vbox.append(textViewWidget, hippo.PACK_EXPAND)
 +
 +
        textView = gtk.TextView()
 +
        textView.get_buffer().set_text('Write here!', -1)
 +
        textViewWidget.props.widget = textView
 
   
 
   
        button2 = Button('button2_icon')
+
    def _button_activated_cb(self, button):
         button2.connect("activated", self._button2_activated_cb)
+
         logging.debug('FooActivity._button_activated_cb')
        self.append(button2)
         
[[Category:HowTo]]
 
[[Category:HowTo]]
 
[[Category:Sugar]]
 
[[Category:Sugar]]
647

edits