class FileBrowseDialog(Dialog): """Dialog to select files from the filesystem.""" def __init__(self, parent, title, provider, message=None, **args): """ From args: message: message tooltip to show when browsing. selected: the item that should be selected. """ self.value = None self.provider = provider self.message = args.get('message', None) Dialog.__init__(self, parent, title, buttons=[('Select', RESULT_YES), ('Cancel', RESULT_CANCEL)]) def body(self, bodyFrame): bodyFrame.config(bg='white') gui.configureWeigths(bodyFrame) self._createTree(bodyFrame) if self.message: label = tk.Label(bodyFrame, text=self.message, bg='white', image=self.getImage('fa-lightbulb-o.png'), compound=tk.LEFT) label.grid(row=1, column=0, sticky='nw', padx=5, pady=5) self.initial_focus = self.tree def _createTree(self, parent): self.tree = BoundTree(parent, self.provider) def apply(self): index = self.tree.index(self.tree.getFirst()) self.value = self.tree._objects[index] def validate(self): if self.tree.getFirst() is None: showError("Validation error", "Please select an element", self) return False return True