Add control for select file
This commit is contained in:
parent
0804c922f1
commit
c6ecd5a83f
|
@ -4248,7 +4248,7 @@ class Paths(object):
|
|||
return path
|
||||
|
||||
@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
|
||||
multiple: True for multiple selected
|
||||
|
|
Binary file not shown.
|
@ -268,8 +268,7 @@ class Controllers(object):
|
|||
self._uninstall(name)
|
||||
return
|
||||
|
||||
@app.catch_exception
|
||||
def cmd_shell_action(self, name):
|
||||
def cmd_shell_action(self, event):
|
||||
if app.IS_WIN:
|
||||
cmd = '"{}"'.format(self.path_python)
|
||||
app.open_file(cmd)
|
||||
|
@ -284,6 +283,13 @@ class Controllers(object):
|
|||
app.run(cmd)
|
||||
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
|
||||
def _create_dialog():
|
||||
|
@ -421,13 +427,25 @@ def _create_dialog():
|
|||
args = {
|
||||
'Type': 'Text',
|
||||
'Name': 'txt_search',
|
||||
'Width': 180,
|
||||
'Width': 165,
|
||||
'Height': 12,
|
||||
'Step': 1,
|
||||
'Border': 0,
|
||||
}
|
||||
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 = {
|
||||
'Type': 'Listbox',
|
||||
'Name': 'lst_package',
|
||||
|
@ -515,11 +533,13 @@ def _create_dialog():
|
|||
dialog.cmd_install, dialog.cmd_uninstall, dialog.cmd_shell)
|
||||
dialog.lbl_package.move(dialog.cmd_home)
|
||||
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.lbl_package.center()
|
||||
dialog.lst_package.center()
|
||||
dialog.txt_search.center()
|
||||
dialog.center(controls)
|
||||
dialog.center((dialog.txt_search, dialog.cmd_explore))
|
||||
|
||||
dialog.step = 10
|
||||
|
||||
|
|
Loading…
Reference in New Issue