File: testgtkiconlist.py

package info (click to toggle)
python-gtkextra 0.21-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,284 kB
  • ctags: 1,618
  • sloc: ansic: 8,966; python: 4,231; makefile: 43
file content (59 lines) | stat: -rwxr-xr-x 1,759 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python

from gtk import *
from gtkextra import *
import icons

class Application(GtkWindow):

    def __init__(self):
        GtkWindow.__init__(self, title="GtkIconList Demo")
        self.set_usize(400, 400)
        self.connect("destroy", mainquit)

        hbox1 = GtkHBox()
        self.add(hbox1)

        table = GtkTable(4, 2)
        hbox1.pack_start(table, FALSE, FALSE)

        notebook = GtkNotebook()
        hbox1.pack_start(notebook)

        scrollw1 = GtkScrolledWindow()
        scrollw1.set_border_width(0)
        scrollw1.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
        label1 = GtkLabel("Worksheets")
        notebook.append_page(scrollw1, label1)

        scrollw2 = GtkScrolledWindow()
        scrollw2.set_border_width(0)
        scrollw2.set_policy(POLICY_AUTOMATIC, POLICY_AUTOMATIC)
        label2 = GtkLabel("Plots")
        notebook.append_page(scrollw2, label2)

        iconlist1 = GtkIconList(48, ICON_LIST_TEXT_BELOW)
        iconlist1.set_selection_mode(SELECTION_SINGLE)
        iconlist1.connect("select_icon", self.select_icon)
        scrollw1.add_with_viewport(iconlist1)
        for i in xrange(20):
            iconlist1.add_from_data(icons.sheet_icon2, "Data %02d" % i)

        iconlist2 = GtkIconList(48, ICON_LIST_TEXT_RIGHT)
        iconlist2.set_selection_mode(SELECTION_MULTIPLE)
        scrollw2.add_with_viewport(iconlist2)
        for i in xrange(20):
            iconlist2.add_from_data(icons.plot_icon2, "Plot %02d" % i)

        self.show_all()

    def select_icon(self, widget, item, event, *args):
        print "SELECTION:", item.label
        return TRUE
    
    def mainloop(self):
        mainloop()

if __name__ == '__main__':		
    app = Application()
    app.mainloop()