-
Notifications
You must be signed in to change notification settings - Fork 1
/
0000000000000000000openFile3.py
69 lines (56 loc) · 1.89 KB
/
0000000000000000000openFile3.py
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
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
#-------------- P Jat (open and read Mask File) ----------------
from numpy import *
from pylab import find
import os
import copy
from tgisiocls import *
from tgisdatacls import *
from tgiserrcls import *
from tgissys import *
from tgiserrmsg import *
import scipy.stats
#--------------------------------------------------------------
import pygtk
pygtk.require('2.0')
import gtk
# Check for new pygtk: this is new class in PyGtk 2.4
if gtk.pygtk_version < (2,3,90):
print "PyGtk 2.3.90 or later required for this example"
raise SystemExit
dialog = gtk.FileChooserDialog(" Please Select Mask File (Shape File)..",
None,
gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
dialog.set_default_response(gtk.RESPONSE_OK)
filter = gtk.FileFilter()
filter.set_name("All files")
filter.add_pattern("*")
dialog.add_filter(filter)
filter = gtk.FileFilter()
filter.set_name("Images")
filter.add_mime_type("image/png")
filter.add_mime_type("image/jpeg")
filter.add_mime_type("image/gif")
filter.add_pattern("*.png")
filter.add_pattern("*.jpg")
filter.add_pattern("*.gif")
filter.add_pattern("*.tif")
filter.add_pattern("*.xpm")
dialog.add_filter(filter)
response = dialog.run()
if response == gtk.RESPONSE_OK:
print dialog.get_filename(), 'selected'
#--------------------- P Jat Write file with file address
# Create param file
paramFileName='maskFileName.txt'
objDataWriter = DataWriter()
objDataWriter.openFile('maskFileName.txt')
print dialog.get_filename()
objDataWriter.writeStr(dialog.get_filename())
objDataWriter.closeFile()
#--------------------------------------------------------
elif response == gtk.RESPONSE_CANCEL:
print 'Closed, no files selected'
dialog.destroy()