Mercurial > urwid-satext
comparison urwid_satext/files_management.py @ 112:b3e8edbe0a1e
FileDialog: a message can now be displayed above the file selector
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 25 Sep 2015 18:32:32 +0200 |
parents | 5bb3b7e25bf6 |
children | 00b012549f88 |
comparison
equal
deleted
inserted
replaced
111:1cdf4a00b68d | 112:b3e8edbe0a1e |
---|---|
128 | 128 |
129 | 129 |
130 | 130 |
131 class FileDialog(urwid.WidgetWrap): | 131 class FileDialog(urwid.WidgetWrap): |
132 | 132 |
133 def __init__(self, ok_cb, cancel_cb, title=_("Please select a file"), style=[]): | 133 def __init__(self, ok_cb, cancel_cb, message=None, title=_("Please select a file"), style=[]): |
134 """Create file dialog | 134 """Create file dialog |
135 | |
135 @param title: title of the window/popup | 136 @param title: title of the window/popup |
137 @param message: message to display, or None to only show title and file dialog | |
138 message will be passed to a Text widget, so markup can be used | |
136 @param style: list of string: | 139 @param style: list of string: |
137 - 'dir' if a dir path must be selected | 140 - 'dir' if a dir path must be selected |
138 """ | 141 """ |
139 self.ok_cb = ok_cb | 142 self.ok_cb = ok_cb |
140 self._type = 'dir' if 'dir' in style else 'normal' | 143 self._type = 'dir' if 'dir' in style else 'normal' |
141 self.__home_path = os.path.expanduser('~') | 144 self.__home_path = os.path.expanduser('~') |
145 widgets = [] | |
146 if message: | |
147 widgets.append(urwid.Text(message)) | |
148 widgets.append(urwid.Divider(u'─')) | |
142 self.path_wid = PathEdit(_('Path: ')) | 149 self.path_wid = PathEdit(_('Path: ')) |
143 self.path_wid.setCompletionMethod(self._directory_completion) | 150 self.path_wid.setCompletionMethod(self._directory_completion) |
144 urwid.connect_signal(self.path_wid, 'change', self.onPathChange) | 151 urwid.connect_signal(self.path_wid, 'change', self.onPathChange) |
145 header = urwid.Pile([self.path_wid, urwid.Divider(u'─')]) | 152 widgets.append(self.path_wid) |
153 widgets.append(urwid.Divider(u'─')) | |
154 header = urwid.Pile(widgets) | |
146 bookm_list = urwid.SimpleListWalker([]) | 155 bookm_list = urwid.SimpleListWalker([]) |
147 self.bookmarks = list(self.getBookmarks()) | 156 self.bookmarks = list(self.getBookmarks()) |
148 self.bookmarks.sort() | 157 self.bookmarks.sort() |
149 for bookmark in self.bookmarks: | 158 for bookmark in self.bookmarks: |
150 if bookmark.startswith(self.__home_path): | 159 if bookmark.startswith(self.__home_path): |