annotate engine/extensions/filebrowser.py @ 374:1115f7cae9a3

Editor: * The editor will now force filenames to be lowercase, as VFS does not like uppercase path names. * If a map filename does not have a .xml extension on save, it will be automatically added. * Log modules set to "all" by default. Only new users will be affected by this without having to modify or remove their configuration file. * Log level set to LOGLEVEL_WARN
author cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 21 Nov 2009 13:11:56 +0000
parents dcf6f6091868
children
rev   line source
331
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
1 # -*- coding: utf-8 -*-
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
2
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
3 # ####################################################################
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
4 # Copyright (C) 2005-2009 by the FIFE team
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
5 # http://www.fifengine.de
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
6 # This file is part of FIFE.
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
7 #
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
8 # FIFE is free software; you can redistribute it and/or
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
10 # License as published by the Free Software Foundation; either
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
12 #
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
13 # This library is distributed in the hope that it will be useful,
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
16 # Lesser General Public License for more details.
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
17 #
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
19 # License along with this library; if not, write to the
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
20 # Free Software Foundation, Inc.,
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
48c99636453e Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 282
diff changeset
22 # ####################################################################
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 import pychan
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 import pychan.widgets as widgets
258
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
26 import sys
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27
260
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
28 def u2s(string):
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
29 return string.encode(sys.getfilesystemencoding())
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
30
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 class FileBrowser(object):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 """
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 FileBrowser displays directory and file listings from the vfs.
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 The fileSelected parameter is a callback invoked when a file selection has been made; its
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 signature must be fileSelected(path,filename). If selectdir is set, fileSelected's
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 filename parameter should be optional.
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 The savefile option provides a box for supplying a new filename that doesn't exist yet.
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 The selectdir option allows directories to be selected as well as files.
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 """
179
28532ae6f9f6 Moved all editor content out of content, as chewie says it's deprecated as hell ;-)
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 170
diff changeset
40 def __init__(self, engine, fileSelected, savefile=False, selectdir=False, extensions=('xml',), guixmlpath="gui/filebrowser.xml"):
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 self.engine = engine
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 self.fileSelected = fileSelected
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 self._widget = None
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 self.savefile = savefile
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 self.selectdir = selectdir
170
f55979111ba1 - minor change to filebrowser - you now can specify the directory and the filename (!) of the xml file for the filebrowser
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
47
f55979111ba1 - minor change to filebrowser - you now can specify the directory and the filename (!) of the xml file for the filebrowser
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
48 self.guixmlpath = guixmlpath
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 self.extensions = extensions
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 self.path = './..'
258
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
52 self.dir_list = []
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
53 self.file_list = []
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 def showBrowser(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 if self._widget:
366
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
57 self.setDirectory(self.path)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 self._widget.show()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 return
366
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
60
170
f55979111ba1 - minor change to filebrowser - you now can specify the directory and the filename (!) of the xml file for the filebrowser
chewie@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
61 self._widget = pychan.loadXML(self.guixmlpath)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 self._widget.mapEvents({
366
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
63 'dirList' : self._selectDir,
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 'selectButton' : self._selectFile,
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 'closeButton' : self._widget.hide
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 })
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 if self.savefile:
255
51cc05d862f2 Merged editor_rewrite branch to trunk.
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 179
diff changeset
68 self._file_entry = widgets.TextField(name='saveField', text=u'')
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 self._widget.findChild(name="fileColumn").addChild(self._file_entry)
366
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
70
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
71 self.setDirectory(self.path)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 self._widget.show()
366
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
73
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
74 def setDirectory(self, path):
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
75 self.path = path
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
76 if not self._widget: return
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
77
258
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
78 def decodeList(list):
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
79 fs_encoding = sys.getfilesystemencoding()
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
80 if fs_encoding is None: fs_encoding = "ascii"
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
81
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
82 newList = []
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
83 for i in list:
260
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
84 try: newList.append(unicode(i, fs_encoding))
258
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
85 except:
260
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
86 newList.append(unicode(i, fs_encoding, 'replace'))
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
87 print "WARNING: Could not decode item:", i
258
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
88 return newList
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89
258
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
90 self.dir_list = []
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
91 self.file_list = []
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
92
260
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
93 dir_list = ('..',) + filter(lambda d: not d.startswith('.'), self.engine.getVFS().listDirectories(self.path))
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
94 file_list = filter(lambda f: f.split('.')[-1] in self.extensions, self.engine.getVFS().listFiles(self.path))
258
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
95
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
96 self.dir_list = decodeList(dir_list)
0b1992a3dfe7 Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 255
diff changeset
97 self.file_list = decodeList(file_list)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 self._widget.distributeInitialData({
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 'dirList' : self.dir_list,
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 'fileList' : self.file_list
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 })
366
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
102
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
103 self._widget.adaptLayout()
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
104
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
105 def _selectDir(self):
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
106 selection = self._widget.collectData('dirList')
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
107 if selection >= 0 and selection < len(self.dir_list):
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
108 new_dir = u2s(self.dir_list[selection])
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
109 lst = self.path.split('/')
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
110 if new_dir == '..' and lst[-1] != '..' and lst[-1] != '.':
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
111 lst.pop()
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
112 else:
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
113 lst.append(new_dir)
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
114
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
115 path = '/'.join(lst)
dcf6f6091868 Filebrowser:
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 354
diff changeset
116 self.setDirectory(path)
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 def _selectFile(self):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 self._widget.hide()
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 selection = self._widget.collectData('fileList')
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 if self.savefile:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 if self._widget.collectData('saveField'):
260
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
124 self.fileSelected(self.path, u2s(self._widget.collectData('saveField')))
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 return
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126
282
0adf9423062e * Buttons and functions for importing objects in the editor
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 260
diff changeset
127 if selection >= 0 and selection < len(self.file_list):
260
a0068e00f076 * Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 258
diff changeset
128 self.fileSelected(self.path, u2s(self.file_list[selection]))
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 return
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 if self.selectdir:
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132 self.fileSelected(self.path)
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133 return
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 print 'FileBrowser: error, no selection.'