File: testgtkfilesel.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 (44 lines) | stat: -rwxr-xr-x 1,244 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
#!/usr/bin/env python

from gtk import *
from gtkextra import *

class Application(GtkIconFileSelection):

    def __init__(self):
        GtkIconFileSelection.__init__(self, "Open File")
        hbox = GtkHBox()
        show_button = GtkButton("Show Tree")
        hbox.pack_start(show_button)
        hide_button = GtkButton("Hide Tree")
        hbox.pack_start(hide_button)
        hbox.show_all()
        vbox = self.children()[0]
        vbox.pack_start(hbox)
        self.connect("destroy", mainquit)
        self.cancel_button.connect("clicked", mainquit)
        self.ok_button.connect("clicked", self.ok_clicked)
        show_button.connect("clicked", self.show_tree_clicked)
        hide_button.connect("clicked", self.hide_tree_clicked)
        self.show()

    def ok_clicked(self, *args):
        path = self.file_list.get_path()
        file = self.file_list.get_filename()
        if path:
            print "PATH:", path
        if file:
            print "FILE:", file

    def show_tree_clicked(self, *args):
        self.show_tree(TRUE)

    def hide_tree_clicked(self, *args):
        self.show_tree(FALSE)

    def mainloop(self):
        mainloop()

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