[pygtk] how to add to a scrolledwindow?

Timo timomlists at gmail.com
Mon Jan 3 02:20:28 WST 2011


On 02-01-11 14:42, Brian Keck wrote:
> Hello,
>
> I've written very little pygtk (&  no straight gtk),&  am stuck trying to
> add to a vbox inside a scrolledwindow.
>
> A minimal example is ...
Not tested, but try these changes:

>      import gtk
>      window = gtk.Window()
>      window.connect('destroy', gtk.main_quit)
>      scrolled = gtk.ScrolledWindow()
>      window.add(scrolled)
>      vbox = gtk.VBox()
>      scrolled.add_with_viewport(vbox)
>      def addbutton(window, event):
>        vbox.pack_start(gtk.Button('extra'))
>        window.show_all
Change this function to:
def addbutton(widget):
     button = gtk.Button('extra')
     button.show() # Don't know if it really is needed here
     vbox.pack_start(button)
>      b1 = gtk.Button('aaa')
>      b1.connect('button_press_event', addbutton)
Connect to the gtk.Button's clicked signal, not the gtk.Widget's button 
press event. So:
b1.connect('clicked', addbutton)

Cheers,
Timo

>      vbox.pack_start(b1)
>      b2 = gtk.Button('bbb')
>      vbox.pack_start(b2)
>      window.show_all()
>      gtk.main()
>
> I click 'aaa' but no 'extra' appears.
>
> The actual application starts with a list of book authors as button
> labels.  Clicking on an author should insert the author's book titles (a
> vbox of buttons) between this author&  the next.  Also, it's for a Nokia
> N900&  really uses hildon.PannableArea etc.
>
> Thanks for any help,
> Brian Keck
>
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/



More information about the pygtk mailing list