Mercurial > fife-parpg
annotate engine/extensions/filebrowser.py @ 336:16112ef84609
PyChan fixes:
* Previous commits removed the ability to map events to unnamed widgets. Fixed.
author | phoku@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 24 Aug 2009 15:34:23 +0000 |
parents | 48c99636453e |
children | dfd48d49c044 |
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 #!/usr/bin/env python |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
282
diff
changeset
|
2 # -*- coding: utf-8 -*- |
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 # #################################################################### |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
282
diff
changeset
|
5 # 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
|
6 # http://www.fifengine.de |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
282
diff
changeset
|
7 # 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
|
8 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
282
diff
changeset
|
9 # 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
|
10 # 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
|
11 # 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
|
12 # 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
|
13 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
282
diff
changeset
|
14 # 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
|
15 # 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
|
16 # 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
|
17 # 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
|
18 # |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
282
diff
changeset
|
19 # 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
|
20 # 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
|
21 # Free Software Foundation, Inc., |
48c99636453e
Added Licence header to all pypthon modules in extension/
phoku@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
282
diff
changeset
|
22 # 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
|
23 # #################################################################### |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 import pychan |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 import pychan.widgets as widgets |
258
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
27 import sys |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 |
260
a0068e00f076
* Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
258
diff
changeset
|
29 def u2s(string): |
a0068e00f076
* Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
258
diff
changeset
|
30 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
|
31 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 class FileBrowser(object): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 """ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 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
|
35 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
|
36 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
|
37 filename parameter should be optional. |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 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
|
39 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
|
40 """ |
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
|
41 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
|
42 self.engine = engine |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 self.fileSelected = fileSelected |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 self._widget = None |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 self.savefile = savefile |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 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
|
48 |
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
|
49 self.guixmlpath = guixmlpath |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 self.extensions = extensions |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 self.path = './..' |
258
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
53 self.dir_list = [] |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
54 self.file_list = [] |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 def showBrowser(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 if self._widget: |
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 |
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
|
60 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
|
61 self._widget.mapEvents({ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 'dirList' : self._setDirectory, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 'selectButton' : self._selectFile, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 'closeButton' : self._widget.hide |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 }) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 self._setDirectory() |
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) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 self._widget.show() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 def _setDirectory(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 selection = self._widget.collectData('dirList') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 if not (selection < 0): |
260
a0068e00f076
* Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
258
diff
changeset
|
75 new_dir = u2s(self.dir_list[selection]) |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 lst = self.path.split('/') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 if new_dir == '..' and lst[-1] != '..' and lst[-1] != '.': |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 lst.pop() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 else: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 lst.append(new_dir) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
81 self.path = '/'.join(lst) |
258
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
82 |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
83 def decodeList(list): |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
84 fs_encoding = sys.getfilesystemencoding() |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
85 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
|
86 |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
87 newList = [] |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
88 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
|
89 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
|
90 except: |
260
a0068e00f076
* Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
258
diff
changeset
|
91 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
|
92 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
|
93 return newList |
260
a0068e00f076
* Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
258
diff
changeset
|
94 |
a0068e00f076
* Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
258
diff
changeset
|
95 |
0
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 |
258
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
97 self.dir_list = [] |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
98 self.file_list = [] |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
99 |
260
a0068e00f076
* Really fixed proper support for non-ascii filenames for FileBrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
258
diff
changeset
|
100 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
|
101 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
|
102 |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
103 self.dir_list = decodeList(dir_list) |
0b1992a3dfe7
Proper decoding of file names for filebrowser
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
255
diff
changeset
|
104 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
|
105 self._widget.distributeInitialData({ |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
106 'dirList' : self.dir_list, |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 'fileList' : self.file_list |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 }) |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
110 def _selectFile(self): |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
111 self._widget.hide() |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 selection = self._widget.collectData('fileList') |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 if self.savefile: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
115 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
|
116 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
|
117 return |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 |
282
0adf9423062e
* Buttons and functions for importing objects in the editor
cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
260
diff
changeset
|
119 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
|
120 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
|
121 return |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
122 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
123 if self.selectdir: |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
124 self.fileSelected(self.path) |
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 |
4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 print 'FileBrowser: error, no selection.' |