blob: 25bbf32b5d449ac6cf7433e05cfbfbdb7693f1ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
"""Dialogue to pick a file or directory.
Part of the tagit module.
A copy of the license is provided with the project.
Author: Matthias Baumgartner, 2022
"""
# standard imports
import os
# kivy imports
from kivy.lang import Builder
import kivy.properties as kp
# inner-module imports
from .dialogue import Dialogue
from .error import Error
# exports
__all__ = ('PathPicker', )
## code ##
# load kv
Builder.load_file(os.path.join(os.path.dirname(__file__), 'path_picker.kv'))
# classes
class PathPicker(Dialogue):
"""Dialogue with a file browser to select a file or directory."""
title = kp.StringProperty('')
path = kp.StringProperty('')
filters = kp.ListProperty()
def ok(self):
if not os.path.exists(self.path):
Error(text='Please select a file or directory').open()
else:
super(PathPicker, self).ok()
## EOF ##
|