Change filters
This commit is contained in:
parent
c6ecd5a83f
commit
3d10072e9a
11
easymacro.py
11
easymacro.py
|
@ -50,7 +50,7 @@ from functools import wraps
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from string import Template
|
from string import Template
|
||||||
from typing import Any
|
from typing import Any, Union
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
from urllib.error import URLError, HTTPError
|
from urllib.error import URLError, HTTPError
|
||||||
|
|
||||||
|
@ -4248,15 +4248,11 @@ class Paths(object):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_file(cls, init_dir: str='', filters=(), multiple: bool=False):
|
def get_file(cls, init_dir: str='', filters: str='', multiple: bool=False):
|
||||||
"""
|
"""
|
||||||
init_folder: folder default open
|
init_folder: folder default open
|
||||||
multiple: True for multiple selected
|
multiple: True for multiple selected
|
||||||
filters: Example
|
filters: 'xml' or 'xml,txt'
|
||||||
(
|
|
||||||
('XML', '*.xml'),
|
|
||||||
('TXT', '*.txt'),
|
|
||||||
)
|
|
||||||
"""
|
"""
|
||||||
if not init_dir:
|
if not init_dir:
|
||||||
init_dir = cls.documents
|
init_dir = cls.documents
|
||||||
|
@ -4268,6 +4264,7 @@ class Paths(object):
|
||||||
file_picker.setMultiSelectionMode(multiple)
|
file_picker.setMultiSelectionMode(multiple)
|
||||||
|
|
||||||
if filters:
|
if filters:
|
||||||
|
filters = [(f.upper(), f'*.{f.lower()}') for f in filters.split(',')]
|
||||||
file_picker.setCurrentFilter(filters[0][0])
|
file_picker.setCurrentFilter(filters[0][0])
|
||||||
for f in filters:
|
for f in filters:
|
||||||
file_picker.appendFilter(f[0], f[1])
|
file_picker.appendFilter(f[0], f[1])
|
||||||
|
|
Binary file not shown.
|
@ -50,7 +50,7 @@ from functools import wraps
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pprint import pprint
|
from pprint import pprint
|
||||||
from string import Template
|
from string import Template
|
||||||
from typing import Any
|
from typing import Any, Union
|
||||||
from urllib.request import Request, urlopen
|
from urllib.request import Request, urlopen
|
||||||
from urllib.error import URLError, HTTPError
|
from urllib.error import URLError, HTTPError
|
||||||
|
|
||||||
|
@ -4248,15 +4248,11 @@ class Paths(object):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_file(cls, init_dir='', filters=(), multiple=False):
|
def get_file(cls, init_dir: str='', filters: str='', multiple: bool=False):
|
||||||
"""
|
"""
|
||||||
init_folder: folder default open
|
init_folder: folder default open
|
||||||
multiple: True for multiple selected
|
multiple: True for multiple selected
|
||||||
filters: Example
|
filters: 'xml' or 'xml,txt'
|
||||||
(
|
|
||||||
('XML', '*.xml'),
|
|
||||||
('TXT', '*.txt'),
|
|
||||||
)
|
|
||||||
"""
|
"""
|
||||||
if not init_dir:
|
if not init_dir:
|
||||||
init_dir = cls.documents
|
init_dir = cls.documents
|
||||||
|
@ -4268,6 +4264,7 @@ class Paths(object):
|
||||||
file_picker.setMultiSelectionMode(multiple)
|
file_picker.setMultiSelectionMode(multiple)
|
||||||
|
|
||||||
if filters:
|
if filters:
|
||||||
|
filters = [(f.upper(), f'*.{f.lower()}') for f in filters.split(',')]
|
||||||
file_picker.setCurrentFilter(filters[0][0])
|
file_picker.setCurrentFilter(filters[0][0])
|
||||||
for f in filters:
|
for f in filters:
|
||||||
file_picker.appendFilter(f[0], f[1])
|
file_picker.appendFilter(f[0], f[1])
|
||||||
|
|
|
@ -285,7 +285,7 @@ class Controllers(object):
|
||||||
|
|
||||||
@app.catch_exception
|
@app.catch_exception
|
||||||
def cmd_explore_action(self, event):
|
def cmd_explore_action(self, event):
|
||||||
file_name = app.paths.get_file(filters=(('TXT', '*.txt'),))
|
file_name = app.paths.get_file(filters='txt')
|
||||||
self.d.txt_search.value = file_name
|
self.d.txt_search.value = file_name
|
||||||
app.debug(file_name)
|
app.debug(file_name)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue