2020-11-12 19:35:29 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2021-06-12 23:04:37 -05:00
|
|
|
import os
|
2020-11-12 19:35:29 -06:00
|
|
|
import easymacro as app
|
|
|
|
|
|
|
|
|
|
|
|
ID_EXTENSION = ''
|
2020-11-12 23:10:42 -06:00
|
|
|
_ = None
|
2020-11-12 19:35:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
TITLE = 'ZAZ-PIP'
|
|
|
|
URL_PIP = 'https://bootstrap.pypa.io/get-pip.py'
|
2021-06-05 23:03:36 -05:00
|
|
|
URL_TEST = 'http://duckduckgo.com'
|
2020-11-12 19:35:29 -06:00
|
|
|
PIP = 'pip'
|
2021-06-05 23:03:36 -05:00
|
|
|
URL_GIT = 'https://git.cuates.net/elmau/zaz-pip'
|
2020-11-17 22:54:10 -06:00
|
|
|
ICON_OK = 'ok.svg'
|
|
|
|
ICON_QUESTION = 'question.svg'
|
2020-11-12 19:35:29 -06:00
|
|
|
|
|
|
|
PACKAGES = {
|
2020-11-17 22:54:10 -06:00
|
|
|
'cffi': ICON_OK,
|
|
|
|
'cryptography': ICON_OK,
|
|
|
|
'httpx': ICON_OK,
|
|
|
|
'lxml': ICON_OK,
|
|
|
|
'numpy': ICON_OK,
|
|
|
|
'pandas': ICON_OK,
|
|
|
|
'psycopg2-binary': ICON_OK,
|
|
|
|
'peewee': ICON_OK,
|
|
|
|
'pillow': ICON_OK,
|
|
|
|
'pytesseract': ICON_OK,
|
|
|
|
'sounddevice': ICON_OK,
|
2020-11-12 19:35:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def open_dialog_pip():
|
|
|
|
dialog = _create_dialog()
|
2021-06-12 23:04:37 -05:00
|
|
|
|
|
|
|
proxy = app.get_config('proxy', {}, TITLE)
|
|
|
|
if proxy:
|
|
|
|
app.debug(proxy)
|
|
|
|
HOST = proxy['txt_proxy_host']
|
|
|
|
PORT = proxy['txt_proxy_port']
|
|
|
|
USER = proxy['txt_proxy_user']
|
|
|
|
PASS = proxy['txt_proxy_pass']
|
|
|
|
os.environ['http_proxy'] = f'http://{USER}:{PASS}@{HOST}:{PORT}'
|
|
|
|
os.environ['https_proxy'] = f'http://{USER}:{PASS}@{HOST}:{PORT}'
|
|
|
|
|
2020-11-12 19:35:29 -06:00
|
|
|
dialog.open()
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2022-01-27 09:43:00 -06:00
|
|
|
def run(path_locales):
|
2020-11-12 23:10:42 -06:00
|
|
|
global _
|
2022-01-27 09:43:00 -06:00
|
|
|
|
2020-11-12 23:10:42 -06:00
|
|
|
_ = app.install_locales(path_locales)
|
2022-01-27 09:43:00 -06:00
|
|
|
|
|
|
|
open_dialog_pip()
|
|
|
|
|
2020-11-12 19:35:29 -06:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
class Controllers(object):
|
|
|
|
OK1 = 'Successfully installed'
|
|
|
|
OK2 = 'Requirement already'
|
|
|
|
OK3 = 'Successfully uninstalled'
|
|
|
|
|
|
|
|
def __init__(self, dialog):
|
|
|
|
self.d = dialog
|
|
|
|
self.path_python = app.paths.python
|
2020-11-12 23:10:42 -06:00
|
|
|
|
|
|
|
def _set_state(self, state):
|
2020-11-12 19:35:29 -06:00
|
|
|
self._states = {
|
|
|
|
'list': False,
|
|
|
|
'install': False,
|
|
|
|
'search': False,
|
|
|
|
'versions': False,
|
|
|
|
}
|
|
|
|
self._states[state] = True
|
|
|
|
return
|
|
|
|
|
|
|
|
def cmd_install_pip_action(self, event):
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _("Do you want to install 'Python installer package' (PIP)?")
|
2020-11-12 23:10:42 -06:00
|
|
|
if not app.question(msg, TITLE):
|
2020-11-12 19:35:29 -06:00
|
|
|
return
|
|
|
|
|
|
|
|
self._install_pip()
|
|
|
|
return
|
|
|
|
|
|
|
|
@app.run_in_thread
|
|
|
|
def _install_pip(self):
|
|
|
|
self.d.link_proyect.visible = False
|
|
|
|
self.d.lst_log.visible = True
|
2020-11-12 23:10:42 -06:00
|
|
|
path_pip = app.paths.tmp()
|
2022-01-27 07:53:37 -06:00
|
|
|
self.d.lst_log.insert(_('Downloading PIPā¦'))
|
2020-11-12 23:10:42 -06:00
|
|
|
data, h, err = app.url_open(URL_PIP, verify=False)
|
2020-11-12 19:35:29 -06:00
|
|
|
if err:
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('Unable to connect to internet')
|
2020-11-12 19:35:29 -06:00
|
|
|
app.errorbox('{}\n\n{}'.format(msg, err))
|
|
|
|
return
|
|
|
|
|
2020-11-12 23:10:42 -06:00
|
|
|
app.paths.save_bin(path_pip, data)
|
|
|
|
if not app.paths.exists(path_pip):
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('Unable to copy PIP installation file')
|
2020-11-12 19:35:29 -06:00
|
|
|
app.errorbox(msg)
|
|
|
|
return
|
2022-01-27 07:53:37 -06:00
|
|
|
self.d.lst_log.insert(_('PIP installation file has been saved'))
|
2020-11-12 19:35:29 -06:00
|
|
|
|
|
|
|
try:
|
2022-01-27 07:53:37 -06:00
|
|
|
self.d.lst_log.insert(_("Starting PIP installationā¦"))
|
2020-11-12 23:10:42 -06:00
|
|
|
cmd = f'"{self.path_python}" "{path_pip}" --user'
|
2020-11-12 19:35:29 -06:00
|
|
|
for line in app.popen(cmd):
|
|
|
|
if isinstance(line, tuple):
|
|
|
|
app.errorbox(line)
|
|
|
|
break
|
|
|
|
self.d.lst_log.insert(line)
|
|
|
|
|
|
|
|
cmd = self._cmd_pip('-V')
|
|
|
|
label = app.run(cmd, True)
|
|
|
|
if label:
|
|
|
|
self.d.lbl_pip.value = label
|
|
|
|
self.d.cmd_install_pip.visible = False
|
|
|
|
self.d.cmd_admin_pip.visible = True
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('PIP was installed sucessfully')
|
2020-11-12 19:35:29 -06:00
|
|
|
app.msgbox(msg)
|
|
|
|
else:
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('PIP installation has failed, see log')
|
2020-11-12 19:35:29 -06:00
|
|
|
app.warning(msg)
|
|
|
|
except Exception as e:
|
|
|
|
app.errorbox(e)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
def _cmd_pip(self, args):
|
|
|
|
cmd = '"{}" -m pip {}'.format(self.path_python, args)
|
|
|
|
return cmd
|
|
|
|
|
|
|
|
def cmd_admin_pip_action(self, event):
|
|
|
|
self.d.lst_log.ps_from(self.d.lst_package)
|
|
|
|
self.d.lst_log.step = 1
|
|
|
|
self.d.step = 1
|
|
|
|
self.cmd_home_action(None)
|
|
|
|
return
|
|
|
|
|
|
|
|
def cmd_close_action(self, event):
|
|
|
|
self.d.close()
|
|
|
|
return
|
|
|
|
|
|
|
|
def cmd_home_action(self, event):
|
|
|
|
self.d.txt_search.value = ''
|
|
|
|
self._list()
|
|
|
|
return
|
|
|
|
|
|
|
|
def txt_search_key_released(self, event):
|
|
|
|
if event.KeyCode == app.KEY['enter']:
|
|
|
|
self.cmd_search_action(None)
|
|
|
|
return
|
|
|
|
|
|
|
|
if not self.d.txt_search.value.strip():
|
|
|
|
self.cmd_home_action(None)
|
|
|
|
return
|
|
|
|
|
|
|
|
@app.run_in_thread
|
|
|
|
def _list(self):
|
|
|
|
self._set_state('list')
|
|
|
|
self.d.lst_log.visible = False
|
|
|
|
self.d.lst_package.visible = True
|
|
|
|
|
|
|
|
cmd = self._cmd_pip(' list --format=json')
|
|
|
|
self.d.lst_package.clear()
|
|
|
|
result = app.run(cmd, True)
|
|
|
|
packages = app.json_loads(result)
|
|
|
|
|
|
|
|
for p in packages:
|
|
|
|
t = '{} - ({})'.format(p['name'], p['version'])
|
2020-11-17 22:54:10 -06:00
|
|
|
self.d.lst_package.insert(t, ICON_OK)
|
2020-11-12 19:35:29 -06:00
|
|
|
self.d.lst_package.select()
|
|
|
|
self.d.txt_search.set_focus()
|
|
|
|
return
|
|
|
|
|
|
|
|
@app.run_in_thread
|
|
|
|
def _search(self, value):
|
|
|
|
self._set_state('search')
|
|
|
|
line = ''
|
|
|
|
cmd = self._cmd_pip(' search {}'.format(value))
|
|
|
|
self.d.lst_package.clear()
|
|
|
|
for line in app.popen(cmd):
|
|
|
|
parts = line.split(')')
|
|
|
|
name = parts[0].strip() + ')'
|
|
|
|
description = parts[-1].strip()
|
|
|
|
parts = name.split('(')
|
|
|
|
name_verify = parts[0].strip()
|
|
|
|
package = '{} {}'.format(name, description)
|
2020-11-17 22:54:10 -06:00
|
|
|
image = PACKAGES.get(name_verify, ICON_QUESTION)
|
2020-11-12 19:35:29 -06:00
|
|
|
self.d.lst_package.insert(package, image)
|
|
|
|
|
|
|
|
if line:
|
|
|
|
self.d.lst_package.select()
|
|
|
|
else:
|
2022-01-27 07:53:37 -06:00
|
|
|
self.d.lst_package.insert(_('Package not foundā¦'), 'error.png', show=False)
|
2020-11-12 19:35:29 -06:00
|
|
|
return
|
|
|
|
|
|
|
|
def cmd_search_action(self, event):
|
|
|
|
search = self.d.txt_search.value.strip()
|
|
|
|
if not search:
|
|
|
|
self.d.txt_search.set_focus()
|
|
|
|
return
|
|
|
|
|
|
|
|
self._search(search)
|
|
|
|
return
|
|
|
|
|
2020-11-17 22:54:10 -06:00
|
|
|
def cmd_install_action(self, event):
|
|
|
|
name = self.d.txt_search.value.strip()
|
|
|
|
if not name:
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('Enter the package name to install')
|
2020-11-17 22:54:10 -06:00
|
|
|
app.warning(msg)
|
|
|
|
self.d.txt_search.set_focus()
|
|
|
|
return
|
|
|
|
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _(f'Do you really want to install package: {name}?')
|
2020-11-17 22:54:10 -06:00
|
|
|
if not app.question(msg):
|
|
|
|
return
|
|
|
|
|
|
|
|
self._install(name)
|
|
|
|
return
|
|
|
|
|
2020-11-12 19:35:29 -06:00
|
|
|
@app.run_in_thread
|
2020-11-18 12:47:12 -06:00
|
|
|
def _install(self, value: str='', path: str=''):
|
2020-11-12 19:35:29 -06:00
|
|
|
self._set_state('install')
|
|
|
|
self.d.lst_package.visible = False
|
|
|
|
self.d.lst_log.visible = True
|
|
|
|
|
|
|
|
line = ''
|
2020-11-18 12:47:12 -06:00
|
|
|
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}"')
|
2020-11-12 19:35:29 -06:00
|
|
|
self.d.lst_log.clear()
|
|
|
|
for line in app.popen(cmd):
|
|
|
|
if self.OK1 in line or self.OK2 in line:
|
|
|
|
self.d.lst_log.insert(line, 'ok.png')
|
|
|
|
else:
|
|
|
|
self.d.lst_log.insert(line)
|
|
|
|
return
|
|
|
|
|
|
|
|
def lst_package_double_click(self, event):
|
|
|
|
opt = 'install'
|
|
|
|
if self._states['list']:
|
|
|
|
opt = 'upgrade'
|
|
|
|
|
|
|
|
name = self.d.lst_package.value
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('Do you want to {}:\n\n{}?').format(opt, name)
|
2020-11-12 19:35:29 -06:00
|
|
|
if not app.question(msg, TITLE):
|
|
|
|
return
|
|
|
|
|
|
|
|
self._install(name)
|
|
|
|
return
|
|
|
|
|
|
|
|
@app.run_in_thread
|
|
|
|
def _uninstall(self, value):
|
|
|
|
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(' uninstall -y {}'.format(name))
|
|
|
|
self.d.lst_log.clear()
|
|
|
|
for line in app.popen(cmd):
|
|
|
|
if self.OK3 in line:
|
|
|
|
self.d.lst_log.insert(line, 'ok.png')
|
|
|
|
else:
|
|
|
|
self.d.lst_log.insert(line)
|
|
|
|
return
|
|
|
|
|
|
|
|
def cmd_uninstall_action(self, event):
|
|
|
|
if not self._states['list']:
|
|
|
|
msg = _('Select installed package')
|
|
|
|
app.warning(msg)
|
|
|
|
return
|
|
|
|
|
|
|
|
name = self.d.lst_package.value
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('Do you want to uninstall:\n\n{}?').format(name)
|
2020-11-12 19:35:29 -06:00
|
|
|
if not app.question(msg):
|
|
|
|
return
|
|
|
|
|
|
|
|
self._uninstall(name)
|
|
|
|
return
|
|
|
|
|
2020-11-17 23:16:06 -06:00
|
|
|
def cmd_shell_action(self, event):
|
2020-11-12 19:35:29 -06:00
|
|
|
if app.IS_WIN:
|
|
|
|
cmd = '"{}"'.format(self.path_python)
|
2020-11-18 16:47:07 -06:00
|
|
|
app.paths.open(cmd)
|
2020-11-12 19:35:29 -06:00
|
|
|
else:
|
|
|
|
cmd = 'exec "{}"'
|
|
|
|
if app.IS_MAC:
|
|
|
|
cmd = 'open "{}"'
|
|
|
|
elif app.DESKTOP == 'gnome':
|
2022-02-04 21:26:17 -06:00
|
|
|
cmd = 'gnome-terminal -- {}'
|
2020-11-12 19:35:29 -06:00
|
|
|
|
|
|
|
cmd = cmd.format(self.path_python)
|
|
|
|
app.run(cmd)
|
|
|
|
return
|
|
|
|
|
2020-11-17 23:16:06 -06:00
|
|
|
def cmd_explore_action(self, event):
|
2020-11-18 12:47:12 -06:00
|
|
|
path = app.paths.get_file(filters='txt')
|
|
|
|
if not path:
|
|
|
|
return
|
|
|
|
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _(f'Do you want to install from:\n\n{path}')
|
2020-11-18 12:47:12 -06:00
|
|
|
if not app.question(msg):
|
|
|
|
return
|
|
|
|
|
|
|
|
self._install(path=path)
|
2020-11-17 23:16:06 -06:00
|
|
|
return
|
|
|
|
|
2021-06-05 23:03:36 -05:00
|
|
|
def cmd_proxy_action(self, event):
|
2021-06-12 23:04:37 -05:00
|
|
|
dialog = _create_dialog_proxy()
|
|
|
|
data = app.get_config('proxy', {}, TITLE)
|
|
|
|
dialog.set_values(data)
|
|
|
|
dialog.open()
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
class ControllersProxy(object):
|
|
|
|
|
|
|
|
def __init__(self, dialog):
|
|
|
|
self.d = dialog
|
|
|
|
|
|
|
|
def cmd_proxy_save_action(self, event):
|
|
|
|
data = dict(
|
|
|
|
txt_proxy_host = self.d.txt_proxy_host.value,
|
|
|
|
txt_proxy_port = self.d.txt_proxy_port.value,
|
|
|
|
txt_proxy_user = self.d.txt_proxy_user.value,
|
|
|
|
txt_proxy_pass = self.d.txt_proxy_pass.value,
|
|
|
|
)
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('Do you want to save this Proxy settings?')
|
2021-06-12 23:04:37 -05:00
|
|
|
if not app.question(msg):
|
|
|
|
return
|
|
|
|
|
|
|
|
app.set_config('proxy', data, TITLE)
|
|
|
|
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('Proxy settings saved sucessfully')
|
2021-06-12 23:04:37 -05:00
|
|
|
app.msgbox(msg)
|
|
|
|
self.d.close()
|
|
|
|
return
|
|
|
|
|
|
|
|
def cmd_proxy_delete_action(self, event):
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _("Do you want to remove Proxy settings?")
|
2021-06-12 23:04:37 -05:00
|
|
|
if not app.question(msg):
|
|
|
|
return
|
|
|
|
|
|
|
|
app.set_config('proxy', {}, TITLE)
|
|
|
|
|
2022-01-27 07:53:37 -06:00
|
|
|
msg = _('Proxy settings deleted sucessfully')
|
2021-06-12 23:04:37 -05:00
|
|
|
app.msgbox(msg)
|
|
|
|
self.d.close()
|
2021-06-05 23:03:36 -05:00
|
|
|
return
|
|
|
|
|
2020-11-12 19:35:29 -06:00
|
|
|
|
|
|
|
def _create_dialog():
|
2020-11-12 23:10:42 -06:00
|
|
|
BUTTON_WH = 20
|
2020-11-12 19:35:29 -06:00
|
|
|
args= {
|
|
|
|
'Name': 'dialog',
|
|
|
|
'Title': 'Zaz-Pip',
|
|
|
|
'Width': 200,
|
|
|
|
'Height': 220,
|
|
|
|
}
|
|
|
|
dialog = app.create_dialog(args)
|
|
|
|
dialog.id = ID_EXTENSION
|
|
|
|
dialog.events = Controllers
|
|
|
|
|
|
|
|
lbl_title = '{} {} - {}'.format(app.NAME, app.VERSION, app.OS)
|
|
|
|
args = {
|
|
|
|
'Type': 'Label',
|
|
|
|
'Name': 'lbl_title',
|
|
|
|
'Label': lbl_title,
|
|
|
|
'Width': 100,
|
|
|
|
'Height': 15,
|
|
|
|
'Border': 1,
|
|
|
|
'Align': 1,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
'Step': 10,
|
|
|
|
'FontHeight': 12,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
dialog.center(dialog.lbl_title, y=5)
|
|
|
|
|
|
|
|
path_python = app.paths.python
|
|
|
|
cmd = '"{}" -V'.format(path_python)
|
|
|
|
label = app.run(cmd, True)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Label',
|
|
|
|
'Name': 'lbl_python',
|
|
|
|
'Label': str(label),
|
|
|
|
'Width': 100,
|
|
|
|
'Height': 15,
|
|
|
|
'Border': 1,
|
|
|
|
'Align': 1,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
'Step': 10,
|
|
|
|
'FontHeight': 11,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
dialog.center(dialog.lbl_python, y=25)
|
|
|
|
|
|
|
|
cmd = '"{}" -m pip -V'.format(path_python)
|
|
|
|
label = app.run(cmd, True)
|
|
|
|
exists_pip = True
|
|
|
|
if not label:
|
|
|
|
exists_pip = False
|
2022-01-27 07:53:37 -06:00
|
|
|
label = _("'Python installer package' (PIP) is not installed")
|
2020-11-12 19:35:29 -06:00
|
|
|
args = {
|
|
|
|
'Type': 'Label',
|
|
|
|
'Name': 'lbl_pip',
|
|
|
|
'Label': label,
|
|
|
|
'Width': 160,
|
|
|
|
'Height': 30,
|
|
|
|
'Border': 1,
|
|
|
|
'Align': 1,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
'Step': 10,
|
|
|
|
'MultiLine': True,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
dialog.center(dialog.lbl_pip, y=45)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_admin_pip',
|
|
|
|
'Label': _('Admin PIP'),
|
2020-11-12 23:10:42 -06:00
|
|
|
'Width': 70,
|
|
|
|
'Height': BUTTON_WH,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Step': 10,
|
2020-11-17 22:54:10 -06:00
|
|
|
'ImageURL': 'python.svg',
|
2020-11-12 19:35:29 -06:00
|
|
|
'ImagePosition': 1,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
dialog.center(dialog.cmd_admin_pip, y=80)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_install_pip',
|
|
|
|
'Label': _('Install PIP'),
|
|
|
|
'Width': 60,
|
2020-11-12 23:10:42 -06:00
|
|
|
'Height': BUTTON_WH,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Step': 10,
|
2020-11-18 16:47:07 -06:00
|
|
|
'ImageURL': 'install.svg',
|
2020-11-12 19:35:29 -06:00
|
|
|
'ImagePosition': 1,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
dialog.center(dialog.cmd_install_pip, y=80)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Link',
|
|
|
|
'Name': 'link_proyect',
|
|
|
|
'URL': URL_GIT,
|
|
|
|
'Label': URL_GIT,
|
|
|
|
'Border': 1,
|
|
|
|
'Width': 130,
|
|
|
|
'Height': 15,
|
|
|
|
'Align': 1,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
'Step': 10,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
dialog.center(dialog.link_proyect, y=-5)
|
|
|
|
|
2021-06-05 23:03:36 -05:00
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_proxy',
|
|
|
|
'Width': 15,
|
|
|
|
'Height': 15,
|
|
|
|
'Step': 10,
|
|
|
|
'ImageURL': 'proxy.svg',
|
|
|
|
'FocusOnClick': False,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
2020-11-12 19:35:29 -06:00
|
|
|
args = {
|
|
|
|
'Type': 'Listbox',
|
|
|
|
'Name': 'lst_log',
|
|
|
|
'Width': 160,
|
|
|
|
'Height': 105,
|
|
|
|
'Step': 10,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
dialog.center(dialog.lst_log, y=105)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Label',
|
|
|
|
'Name': 'lbl_package',
|
|
|
|
'Label': _('Packages'),
|
|
|
|
'Width': 100,
|
|
|
|
'Height': 15,
|
|
|
|
'Border': 1,
|
|
|
|
'Align': 1,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
'Step': 1,
|
|
|
|
}
|
|
|
|
lbl = dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Text',
|
|
|
|
'Name': 'txt_search',
|
2020-11-17 23:16:06 -06:00
|
|
|
'Width': 165,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Height': 12,
|
|
|
|
'Step': 1,
|
|
|
|
'Border': 0,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
2020-11-17 23:16:06 -06:00
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_explore',
|
|
|
|
'Label': '...',
|
|
|
|
'Width': 12,
|
|
|
|
'Height': 12,
|
|
|
|
'Step': 1,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
2020-11-12 19:35:29 -06:00
|
|
|
args = {
|
|
|
|
'Type': 'Listbox',
|
|
|
|
'Name': 'lst_package',
|
|
|
|
'Width': 180,
|
|
|
|
'Height': 128,
|
|
|
|
'Step': 1,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_close',
|
|
|
|
'Label': _('~Close'),
|
2020-11-12 23:10:42 -06:00
|
|
|
'Width': 70,
|
|
|
|
'Height': BUTTON_WH,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Step': 1,
|
2020-11-17 22:54:10 -06:00
|
|
|
'ImageURL': 'close.svg',
|
2020-11-12 19:35:29 -06:00
|
|
|
'ImagePosition': 1,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
dialog.center(dialog.cmd_close, y=-5)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_home',
|
2020-11-12 23:10:42 -06:00
|
|
|
'Width': BUTTON_WH,
|
|
|
|
'Height': BUTTON_WH,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Step': 1,
|
2020-11-17 22:54:10 -06:00
|
|
|
'ImageURL': 'home.svg',
|
2020-11-12 19:35:29 -06:00
|
|
|
'FocusOnClick': False,
|
|
|
|
'Y': 2,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_search',
|
2020-11-12 23:10:42 -06:00
|
|
|
'Width': BUTTON_WH,
|
|
|
|
'Height': BUTTON_WH,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Step': 1,
|
2020-11-17 22:54:10 -06:00
|
|
|
'ImageURL': 'search.svg',
|
2020-11-12 19:35:29 -06:00
|
|
|
'FocusOnClick': False,
|
2021-01-08 21:14:15 -06:00
|
|
|
'Enabled': False,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Y': 2,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_uninstall',
|
2020-11-12 23:10:42 -06:00
|
|
|
'Width': BUTTON_WH,
|
|
|
|
'Height': BUTTON_WH,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Step': 1,
|
2020-11-17 22:54:10 -06:00
|
|
|
'ImageURL': 'uninstall.svg',
|
2020-11-12 19:35:29 -06:00
|
|
|
'FocusOnClick': False,
|
|
|
|
'Y': 2,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_install',
|
2020-11-12 23:10:42 -06:00
|
|
|
'Width': BUTTON_WH,
|
|
|
|
'Height': BUTTON_WH,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Step': 1,
|
2020-11-17 22:54:10 -06:00
|
|
|
'ImageURL': 'install.svg',
|
2020-11-12 19:35:29 -06:00
|
|
|
'FocusOnClick': False,
|
|
|
|
'Y': 2,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_shell',
|
2020-11-12 23:10:42 -06:00
|
|
|
'Width': BUTTON_WH,
|
|
|
|
'Height': BUTTON_WH,
|
2020-11-12 19:35:29 -06:00
|
|
|
'Step': 1,
|
2020-11-17 22:54:10 -06:00
|
|
|
'ImageURL': 'shell.svg',
|
2020-11-12 19:35:29 -06:00
|
|
|
'FocusOnClick': False,
|
|
|
|
'Y': 2,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
2021-06-05 23:03:36 -05:00
|
|
|
dialog.cmd_proxy.move(dialog.link_proyect, x=5, y=0)
|
|
|
|
controls = (dialog.link_proyect, dialog.cmd_proxy)
|
|
|
|
dialog.center(controls)
|
|
|
|
|
2020-11-12 19:35:29 -06:00
|
|
|
controls = (dialog.cmd_home, dialog.cmd_search,
|
|
|
|
dialog.cmd_install, dialog.cmd_uninstall, dialog.cmd_shell)
|
|
|
|
dialog.lbl_package.move(dialog.cmd_home)
|
|
|
|
dialog.txt_search.move(dialog.lbl_package)
|
2020-11-17 23:16:06 -06:00
|
|
|
dialog.cmd_explore.move(dialog.txt_search, x=0, y=0)
|
2020-11-12 19:35:29 -06:00
|
|
|
dialog.lst_package.move(dialog.txt_search)
|
|
|
|
dialog.lbl_package.center()
|
|
|
|
dialog.lst_package.center()
|
|
|
|
dialog.txt_search.center()
|
|
|
|
dialog.center(controls)
|
2021-06-05 23:03:36 -05:00
|
|
|
controls = (dialog.txt_search, dialog.cmd_explore)
|
|
|
|
dialog.center(controls)
|
2020-11-12 19:35:29 -06:00
|
|
|
|
|
|
|
dialog.step = 10
|
|
|
|
dialog.cmd_install_pip.visible = not exists_pip
|
|
|
|
dialog.cmd_admin_pip.visible = exists_pip
|
|
|
|
dialog.lst_log.visible = False
|
|
|
|
|
|
|
|
return dialog
|
2021-06-12 23:04:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
def _create_dialog_proxy():
|
|
|
|
args= {
|
|
|
|
'Name': 'dlg_proxy',
|
2022-01-27 07:53:37 -06:00
|
|
|
'Title': 'Zaz-Pip - Proxy settings',
|
2021-06-12 23:04:37 -05:00
|
|
|
'Width': 150,
|
|
|
|
'Height': 100,
|
|
|
|
}
|
|
|
|
dialog = app.create_dialog(args)
|
|
|
|
dialog.id = ID_EXTENSION
|
|
|
|
dialog.events = ControllersProxy
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Label',
|
|
|
|
'Name': 'lbl_proxy_host',
|
2022-01-28 13:45:10 -06:00
|
|
|
'Label': _('Host: '),
|
2021-06-12 23:04:37 -05:00
|
|
|
'Width': 40,
|
|
|
|
'Height': 12,
|
|
|
|
'Border': 1,
|
|
|
|
'Align': 2,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
'X': 5,
|
|
|
|
'Y': 5,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Text',
|
|
|
|
'Name': 'txt_proxy_host',
|
|
|
|
'Width': 95,
|
|
|
|
'Height': 12,
|
|
|
|
'Border': 0,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Label',
|
|
|
|
'Name': 'lbl_proxy_port',
|
2022-01-28 13:45:10 -06:00
|
|
|
'Label': _('Port: '),
|
2021-06-12 23:04:37 -05:00
|
|
|
'Width': 40,
|
|
|
|
'Height': 12,
|
|
|
|
'Border': 1,
|
|
|
|
'Align': 2,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Text',
|
|
|
|
'Name': 'txt_proxy_port',
|
|
|
|
'Width': 95,
|
|
|
|
'Height': 12,
|
|
|
|
'Border': 0,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Label',
|
|
|
|
'Name': 'lbl_proxy_user',
|
2022-01-28 13:45:10 -06:00
|
|
|
'Label': _('User: '),
|
2021-06-12 23:04:37 -05:00
|
|
|
'Width': 40,
|
|
|
|
'Height': 12,
|
|
|
|
'Border': 1,
|
|
|
|
'Align': 2,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Text',
|
|
|
|
'Name': 'txt_proxy_user',
|
|
|
|
'Width': 95,
|
|
|
|
'Height': 12,
|
|
|
|
'Border': 0,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Label',
|
|
|
|
'Name': 'lbl_proxy_pass',
|
2022-01-28 13:45:10 -06:00
|
|
|
'Label': _('Password: '),
|
2021-06-12 23:04:37 -05:00
|
|
|
'Width': 40,
|
|
|
|
'Height': 12,
|
|
|
|
'Border': 1,
|
|
|
|
'Align': 2,
|
|
|
|
'VerticalAlign': 1,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Text',
|
|
|
|
'Name': 'txt_proxy_pass',
|
|
|
|
'Width': 95,
|
|
|
|
'Height': 12,
|
|
|
|
'Border': 0,
|
|
|
|
}
|
|
|
|
txt = dialog.add_control(args)
|
|
|
|
txt.echochar = '*'
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_proxy_save',
|
|
|
|
'Label': _('Save'),
|
|
|
|
'Width': 50,
|
|
|
|
'Height': 15,
|
|
|
|
'ImageURL': 'save.svg',
|
|
|
|
'ImagePosition': 1,
|
|
|
|
'FocusOnClick': False,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
args = {
|
|
|
|
'Type': 'Button',
|
|
|
|
'Name': 'cmd_proxy_delete',
|
|
|
|
'Label': _('Delete'),
|
|
|
|
'Width': 50,
|
|
|
|
'Height': 15,
|
|
|
|
'ImageURL': 'delete.svg',
|
|
|
|
'ImagePosition': 1,
|
|
|
|
'FocusOnClick': False,
|
|
|
|
}
|
|
|
|
dialog.add_control(args)
|
|
|
|
|
|
|
|
dialog.txt_proxy_host.move(dialog.lbl_proxy_host, x=5, y=0)
|
|
|
|
dialog.lbl_proxy_port.move(dialog.lbl_proxy_host)
|
|
|
|
dialog.txt_proxy_port.move(dialog.lbl_proxy_port, x=5, y=0)
|
|
|
|
dialog.lbl_proxy_user.move(dialog.lbl_proxy_port)
|
|
|
|
dialog.txt_proxy_user.move(dialog.lbl_proxy_user, x=5, y=0)
|
|
|
|
dialog.lbl_proxy_pass.move(dialog.lbl_proxy_user)
|
|
|
|
dialog.txt_proxy_pass.move(dialog.lbl_proxy_pass, x=5, y=0)
|
|
|
|
|
|
|
|
dialog.cmd_proxy_save.move(dialog.lbl_proxy_pass, y=10)
|
|
|
|
dialog.cmd_proxy_delete.move(dialog.lbl_proxy_pass, y=10)
|
|
|
|
controls = (dialog.cmd_proxy_save, dialog.cmd_proxy_delete)
|
|
|
|
dialog.center(controls)
|
|
|
|
|
|
|
|
return dialog
|