FileFolderNavigator widget.
| 3697 | |
| 3698 | |
| 3699 | class FileFolderNavigator(GridBox): |
| 3700 | """FileFolderNavigator widget.""" |
| 3701 | |
| 3702 | @property |
| 3703 | @editor_attribute_decorator("WidgetSpecific", '''Defines wether it is possible to select multiple items.''', bool, {}) |
| 3704 | def multiple_selection(self): return self._multiple_selection |
| 3705 | @multiple_selection.setter |
| 3706 | def multiple_selection(self, value): self._multiple_selection = value |
| 3707 | |
| 3708 | @property |
| 3709 | @editor_attribute_decorator("WidgetSpecific", '''Defines the actual navigator location.''', str, {}) |
| 3710 | def selection_folder(self): return self._selection_folder |
| 3711 | @selection_folder.setter |
| 3712 | def selection_folder(self, value): |
| 3713 | # fixme: we should use full paths and not all this chdir stuff |
| 3714 | self.chdir(value) # move to actual working directory |
| 3715 | |
| 3716 | @property |
| 3717 | @editor_attribute_decorator("WidgetSpecific", '''Defines if files are selectable.''', bool, {}) |
| 3718 | def allow_file_selection(self): return self._allow_file_selection |
| 3719 | @allow_file_selection.setter |
| 3720 | def allow_file_selection(self, value): self._allow_file_selection = value |
| 3721 | |
| 3722 | @property |
| 3723 | @editor_attribute_decorator("WidgetSpecific", '''Defines if folders are selectable.''', bool, {}) |
| 3724 | def allow_folder_selection(self): return self._allow_folder_selection |
| 3725 | @allow_folder_selection.setter |
| 3726 | def allow_folder_selection(self, value): self._allow_folder_selection = value |
| 3727 | |
| 3728 | def __init__(self, multiple_selection = False, selection_folder = ".", allow_file_selection = True, allow_folder_selection = False, **kwargs): |
| 3729 | super(FileFolderNavigator, self).__init__(**kwargs) |
| 3730 | |
| 3731 | self.css_grid_template_columns = "30px auto 30px" |
| 3732 | self.css_grid_template_rows = "30px auto" |
| 3733 | self.define_grid([('button_back','url_editor','button_go'), ('items','items','items')]) |
| 3734 | |
| 3735 | self.multiple_selection = multiple_selection |
| 3736 | self.allow_file_selection = allow_file_selection |
| 3737 | self.allow_folder_selection = allow_folder_selection |
| 3738 | self.selectionlist = [] |
| 3739 | self.currDir = '' |
| 3740 | self.controlBack = Button('Up') |
| 3741 | self.controlBack.onclick.connect(self.dir_go_back) |
| 3742 | self.controlGo = Button('Go >>') |
| 3743 | self.controlGo.onclick.connect(self.dir_go) |
| 3744 | self.pathEditor = TextInput() |
| 3745 | self.pathEditor.style['resize'] = 'none' |
| 3746 | self.pathEditor.attributes['rows'] = '1' |
| 3747 | self.append(self.controlBack, "button_back") |
| 3748 | self.append(self.pathEditor, "url_editor") |
| 3749 | self.append(self.controlGo, "button_go") |
| 3750 | |
| 3751 | self.itemContainer = Container(width='100%', height='100%') |
| 3752 | |
| 3753 | self.append(self.itemContainer, key='items') # defined key as this is replaced later |
| 3754 | |
| 3755 | self.folderItems = list() |
| 3756 |