Mercurial > boomslang
comparison pyntnclick/widgets/filechooser.py @ 712:f33dd2093f77 pyntnclick
Hook up image drawing code again
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Sun, 05 Aug 2012 14:55:48 +0200 |
parents | d4f97c8e0dbe |
children | ab489f7e87f8 |
comparison
equal
deleted
inserted
replaced
711:e9265818a96c | 712:f33dd2093f77 |
---|---|
7 from pyntnclick.widgets.text import TextButton, LabelWidget | 7 from pyntnclick.widgets.text import TextButton, LabelWidget |
8 | 8 |
9 | 9 |
10 class FileChooser(Box): | 10 class FileChooser(Box): |
11 | 11 |
12 def __init__(self, rect, gd, curdir, page_length=12, padding=2): | 12 def __init__(self, rect, gd, curdir, ok_callback, |
13 page_length=12, padding=2): | |
13 super(FileChooser, self).__init__(rect, gd) | 14 super(FileChooser, self).__init__(rect, gd) |
14 self.page_length = page_length | 15 self.page_length = page_length |
15 self.page = 0 | 16 self.page = 0 |
17 self.ok_callback = ok_callback | |
16 self.curdir = os.path.realpath(os.path.normpath(curdir)) | 18 self.curdir = os.path.realpath(os.path.normpath(curdir)) |
17 self.selected = None | 19 self.selected = None |
18 self.padding = padding | 20 self.padding = padding |
19 self.dirs = [] | 21 self.dirs = [] |
20 self.files = [] | 22 self.files = [] |
134 | 136 |
135 def cancel(self, ev, widget): | 137 def cancel(self, ev, widget): |
136 if hasattr(self.parent, 'paused'): | 138 if hasattr(self.parent, 'paused'): |
137 self.parent.paused = False | 139 self.parent.paused = False |
138 self.parent.remove(self) | 140 self.parent.remove(self) |
139 self.selected = None | |
140 return True | 141 return True |
141 | 142 |
142 def ok(self, ev, widget): | 143 def ok(self, ev, widget): |
143 if hasattr(self.parent, 'paused'): | 144 if hasattr(self.parent, 'paused'): |
144 self.parent.paused = False | 145 self.parent.paused = False |
145 self.parent.remove(self) | 146 self.parent.remove(self) |
147 if self.selected: | |
148 self.ok_callback(os.path.normpath(os.path.join(self.curdir, | |
149 self.selected))) | |
146 return True | 150 return True |