diff --git a/easymacro.py b/easymacro.py index c1d1363..6ddace0 100644 --- a/easymacro.py +++ b/easymacro.py @@ -4207,14 +4207,10 @@ class Paths(object): return cls.to_system(getattr(path, name)) @classmethod - def get(cls, init_dir='', filters=()): + def get(cls, init_dir='', filters: str=''): """ Options: http://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1ui_1_1dialogs_1_1TemplateDescription.html - filters: Example - ( - ('XML', '*.xml'), - ('TXT', '*.txt'), - ) + filters: 'xml' or 'txt,xml' """ if not init_dir: init_dir = cls.documents @@ -4224,6 +4220,7 @@ class Paths(object): file_picker.setDisplayDirectory(init_dir) file_picker.initialize((2,)) if filters: + filters = [(f.upper(), f'*.{f.lower()}') for f in filters.split(',')] file_picker.setCurrentFilter(filters[0][0]) for f in filters: file_picker.appendFilter(f[0], f[1]) diff --git a/files/ZAZPip_v0.6.0.oxt b/files/ZAZPip_v0.6.0.oxt index d5e2e55..439c35e 100644 Binary files a/files/ZAZPip_v0.6.0.oxt and b/files/ZAZPip_v0.6.0.oxt differ diff --git a/source/pythonpath/easymacro.py b/source/pythonpath/easymacro.py index c1d1363..6ddace0 100644 --- a/source/pythonpath/easymacro.py +++ b/source/pythonpath/easymacro.py @@ -4207,14 +4207,10 @@ class Paths(object): return cls.to_system(getattr(path, name)) @classmethod - def get(cls, init_dir='', filters=()): + def get(cls, init_dir='', filters: str=''): """ Options: http://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1ui_1_1dialogs_1_1TemplateDescription.html - filters: Example - ( - ('XML', '*.xml'), - ('TXT', '*.txt'), - ) + filters: 'xml' or 'txt,xml' """ if not init_dir: init_dir = cls.documents @@ -4224,6 +4220,7 @@ class Paths(object): file_picker.setDisplayDirectory(init_dir) file_picker.initialize((2,)) if filters: + filters = [(f.upper(), f'*.{f.lower()}') for f in filters.split(',')] file_picker.setCurrentFilter(filters[0][0]) for f in filters: file_picker.appendFilter(f[0], f[1]) diff --git a/source/pythonpath/main.py b/source/pythonpath/main.py index 9eb9b85..1e85da9 100644 --- a/source/pythonpath/main.py +++ b/source/pythonpath/main.py @@ -207,14 +207,18 @@ class Controllers(object): return @app.run_in_thread - def _install(self, value): + def _install(self, value: str='', path: str=''): self._set_state('install') self.d.lst_package.visible = False self.d.lst_log.visible = True line = '' - name = value.split(' ')[0].strip() - cmd = self._cmd_pip(' install --upgrade --user {}'.format(name)) + cmd = ' install --upgrade --user' + if value: + name = value.split(' ')[0].strip() + cmd = self._cmd_pip(f'{cmd} {name}') + else: + cmd = self._cmd_pip(f'{cmd} -r "{path}"') self.d.lst_log.clear() for line in app.popen(cmd): if self.OK1 in line or self.OK2 in line: @@ -223,7 +227,6 @@ class Controllers(object): self.d.lst_log.insert(line) return - @app.catch_exception def lst_package_double_click(self, event): opt = 'install' if self._states['list']: @@ -285,9 +288,15 @@ class Controllers(object): @app.catch_exception def cmd_explore_action(self, event): - file_name = app.paths.get_file(filters='txt') - self.d.txt_search.value = file_name - app.debug(file_name) + path = app.paths.get_file(filters='txt') + if not path: + return + + msg = _(f'Confirm install from:\n\n{path}') + if not app.question(msg): + return + + self._install(path=path) return