Add control for select file

This commit is contained in:
Mauricio Baeza 2020-11-17 23:16:06 -06:00
parent 0804c922f1
commit c6ecd5a83f
3 changed files with 24 additions and 4 deletions

View File

@ -4248,7 +4248,7 @@ 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=(), multiple: bool=False):
""" """
init_folder: folder default open init_folder: folder default open
multiple: True for multiple selected multiple: True for multiple selected

Binary file not shown.

View File

@ -268,8 +268,7 @@ class Controllers(object):
self._uninstall(name) self._uninstall(name)
return return
@app.catch_exception def cmd_shell_action(self, event):
def cmd_shell_action(self, name):
if app.IS_WIN: if app.IS_WIN:
cmd = '"{}"'.format(self.path_python) cmd = '"{}"'.format(self.path_python)
app.open_file(cmd) app.open_file(cmd)
@ -284,6 +283,13 @@ class Controllers(object):
app.run(cmd) app.run(cmd)
return return
@app.catch_exception
def cmd_explore_action(self, event):
file_name = app.paths.get_file(filters=(('TXT', '*.txt'),))
self.d.txt_search.value = file_name
app.debug(file_name)
return
@app.catch_exception @app.catch_exception
def _create_dialog(): def _create_dialog():
@ -421,13 +427,25 @@ def _create_dialog():
args = { args = {
'Type': 'Text', 'Type': 'Text',
'Name': 'txt_search', 'Name': 'txt_search',
'Width': 180, 'Width': 165,
'Height': 12, 'Height': 12,
'Step': 1, 'Step': 1,
'Border': 0, 'Border': 0,
} }
dialog.add_control(args) dialog.add_control(args)
args = {
'Type': 'Button',
'Name': 'cmd_explore',
'Label': '...',
'Width': 12,
'Height': 12,
'Step': 1,
# ~ 'ImageURL': 'close.svg',
# ~ 'ImagePosition': 1,
}
dialog.add_control(args)
args = { args = {
'Type': 'Listbox', 'Type': 'Listbox',
'Name': 'lst_package', 'Name': 'lst_package',
@ -515,11 +533,13 @@ def _create_dialog():
dialog.cmd_install, dialog.cmd_uninstall, dialog.cmd_shell) dialog.cmd_install, dialog.cmd_uninstall, dialog.cmd_shell)
dialog.lbl_package.move(dialog.cmd_home) dialog.lbl_package.move(dialog.cmd_home)
dialog.txt_search.move(dialog.lbl_package) dialog.txt_search.move(dialog.lbl_package)
dialog.cmd_explore.move(dialog.txt_search, x=0, y=0)
dialog.lst_package.move(dialog.txt_search) dialog.lst_package.move(dialog.txt_search)
dialog.lbl_package.center() dialog.lbl_package.center()
dialog.lst_package.center() dialog.lst_package.center()
dialog.txt_search.center() dialog.txt_search.center()
dialog.center(controls) dialog.center(controls)
dialog.center((dialog.txt_search, dialog.cmd_explore))
dialog.step = 10 dialog.step = 10