Is this possible to draw GtkTreeView listed like GtkIconView?

前端 未结 2 1606
情书的邮戳
情书的邮戳 2020-12-20 02:42

I am working on a GTK+ application written in python. I obviously use PyGtk. My application is about collections of videos. It\'s a kind of F-spot or Picasa, but for video.<

相关标签:
2条回答
  • 2020-12-20 03:30

    IconView is what you need. In the ListStore every row represent just one pixbuf but the IconView adjusts the images in a grid. Here a small example, launch it with the image files you want to show as arguments, for example:

    python example.py /usr/share/icons/hicolor/16x16/apps/*
    

    .

    import sys
    import gtk
    
    
    store = gtk.ListStore(gtk.gdk.Pixbuf)
    iv = gtk.IconView(store)
    iv.set_pixbuf_column(0)
    for arg in sys.argv[1:]:
        pixbuf = gtk.gdk.pixbuf_new_from_file(arg)
        store.append((pixbuf, ))
    
    w = gtk.Window()
    w.connect('destroy', lambda w: gtk.main_quit())
    sw = gtk.ScrolledWindow()
    w.add(sw)
    sw.add(iv)
    w.show_all()
    gtk.main()
    
    0 讨论(0)
  • 2020-12-20 03:30

    The best approach is either to stick with a table and reimplement selections or Use a custom version of IconView with a custom cellrenderer wich can take gtk.HBox().

    Some guidelines about custom cellrenderer are :

    http://faq.pygtk.org/index.py?req=show&file=faq13.045.htp

    http://faq.pygtk.org/index.py?req=show&file=faq13.056.htp

    a discuss occured on pygtk mailing list :

    htp://old.nabble.com/Drawing-widgets-in-a-custom-cellrenderer-td14207692.html

    WWWalter make a sample code : http://www.translate.org.za/blogs/walter/en/content/conquering-cellrendererwidget

    According to Ruben Vermeersch, f-pot use a modified version of IconView. Code can be found here : http://git.gnome.org/browse/f-spot/?h=icon-view-cleanup

    0 讨论(0)
提交回复
热议问题