Mercurial > fife-parpg
comparison engine/extensions/filebrowser.py @ 170:f55979111ba1
- minor change to filebrowser - you now can specify the directory and the filename (!) of the xml file for the filebrowser
(previous one was hardcoded)
FEATURES:
- use guixmlpath="my_path_to/my_filebrowser.xml" as argument when creating a new filebrowser instance
NOTE:
- if you create your own filebrowser.xml, make sure to meet the names / widgets the browser needs to work
author | chewie@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 21 Jan 2009 15:35:44 +0000 |
parents | 4a0efb7baf70 |
children | 28532ae6f9f6 |
comparison
equal
deleted
inserted
replaced
169:49e0633b7dd2 | 170:f55979111ba1 |
---|---|
10 signature must be fileSelected(path,filename). If selectdir is set, fileSelected's | 10 signature must be fileSelected(path,filename). If selectdir is set, fileSelected's |
11 filename parameter should be optional. | 11 filename parameter should be optional. |
12 The savefile option provides a box for supplying a new filename that doesn't exist yet. | 12 The savefile option provides a box for supplying a new filename that doesn't exist yet. |
13 The selectdir option allows directories to be selected as well as files. | 13 The selectdir option allows directories to be selected as well as files. |
14 """ | 14 """ |
15 def __init__(self, engine, fileSelected, savefile=False, selectdir=False, extensions=('xml',)): | 15 def __init__(self, engine, fileSelected, savefile=False, selectdir=False, extensions=('xml',), guixmlpath="content/gui/filebrowser.xml"): |
16 self.engine = engine | 16 self.engine = engine |
17 self.fileSelected = fileSelected | 17 self.fileSelected = fileSelected |
18 | 18 |
19 self._widget = None | 19 self._widget = None |
20 self.savefile = savefile | 20 self.savefile = savefile |
21 self.selectdir = selectdir | 21 self.selectdir = selectdir |
22 | |
23 self.guixmlpath = guixmlpath | |
22 | 24 |
23 self.extensions = extensions | 25 self.extensions = extensions |
24 self.path = './..' | 26 self.path = './..' |
25 self.dir_list = ('..',) + self.engine.getVFS().listDirectories(self.path) | 27 self.dir_list = ('..',) + self.engine.getVFS().listDirectories(self.path) |
26 self.file_list = self.engine.getVFS().listFiles(self.path) | 28 self.file_list = self.engine.getVFS().listFiles(self.path) |
27 | 29 |
28 def showBrowser(self): | 30 def showBrowser(self): |
29 if self._widget: | 31 if self._widget: |
30 self._widget.show() | 32 self._widget.show() |
31 return | 33 return |
32 self._widget = pychan.loadXML('content/gui/filebrowser.xml') | 34 self._widget = pychan.loadXML(self.guixmlpath) |
33 self._widget.mapEvents({ | 35 self._widget.mapEvents({ |
34 'dirList' : self._setDirectory, | 36 'dirList' : self._setDirectory, |
35 'selectButton' : self._selectFile, | 37 'selectButton' : self._selectFile, |
36 'closeButton' : self._widget.hide | 38 'closeButton' : self._widget.hide |
37 }) | 39 }) |