On Sat, 16 Oct 2004 15:54:23 -0700 John Finlay <[EMAIL PROTECTED]>
wrote:
> Maybe setting the xalign property to 0.0 for the CellRendererPixbuf 
> would work assuming that the icons are all the same size.

Thanks for the tip! This works very nicely. However, I now see a
stranger problem: when I pull down the menu, all the text fits nicely
(the icons are all aligned along the lefthand side and the text is
centered; the widget is sized so that the largest text just fits).

However, when I select the longest string (which just fits when I pull
down the menu), it is aligned much further to the right, in line with
the other strings, resulting in the text disappearing off of the widget.
Very frustrating. Would this qualify as a gtk bug?

I've attached the earlier sample modified to use xalign and modified to
provide an example of the text disappearing off the right.


> John
Tom

#!/usr/bin/env python

import gtk

class SampleSaveAsWidget:
    def __init__ (self):
        # create self.hbox with a label and ComboBox inside
        self.setup_saveas_widget()
        self.w = gtk.Window()
        self.w.add(self.hbox)
        self.w.show_all()
        self.w.connect('delete-event',self.quit)
        
    def quit (self,*args):
        gtk.main_quit()
        
    def setup_saveas_widget (self):
        """We imitate the functionality we want GNOME to have not long
        from now and we provide a saveas widget."""
        it = gtk.icon_theme_get_default()
        ls = gtk.ListStore(gtk.gdk.Pixbuf, str)
        self.combo = gtk.ComboBox()
        # build our list store with an icon column and
        # a text column.
        for name,icon in [['Plain Text','gnome-mime-text'],
                        ['PDF', 'gnome-mime-application-pdf'],
                        ['Postscript', 'gnome-mime-application-postscript'],
                        ['XML (extensible markup language, blah blah blah)','gnome-mime-text'],
                        ['Web Page (HTML)', 'gnome-mime-text-html'],
                        ['JPEG', 'gnome-image-jpeg']]:
            image = it.load_icon(icon,48,gtk.ICON_LOOKUP_USE_BUILTIN)
            ls.append([image,name])
        # set our ListStore
        self.combo.set_model(ls)
        crp = gtk.CellRendererPixbuf()
        crp.set_property('xalign',0)
        self.combo.pack_start(crp, True)
        self.combo.add_attribute(crp, 'pixbuf', 0)
        crt = gtk.CellRendererText()
        crt.set_property('xalign',0)
        self.combo.pack_start(crt, True)
        self.combo.add_attribute(crt, 'text', 1)        
        self.combo.set_active(3)
        # label our combo widget        
        self.hbox = gtk.HBox()
        l=gtk.Label()
        l.set_use_markup(True)
        # give our label an HIG friendly mnemonic
        l.set_text_with_mnemonic('Select File_type')
        l.set_mnemonic_widget(self.combo)
        l.set_padding(12,0)
        # set up our HBox with label and combo
        self.hbox.add(l)
        self.hbox.add(self.combo)
        self.hbox.show_all()
        # set the default to the first one in our list
        # (in the real deal, of course, we do this based
        # on the default filename if there is one)


if __name__ == '__main__':
    SampleSaveAsWidget()
    gtk.main()

_______________________________________________
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to