mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-06 08:46:21 +01:00
Moved to dialog_box file
This commit is contained in:
parent
7907f90cdb
commit
d43039eb0d
2 changed files with 39 additions and 12 deletions
27
slpkg/dialog_box.py
Normal file
27
slpkg/dialog_box.py
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import locale
|
||||||
|
|
||||||
|
from dialog import Dialog
|
||||||
|
from slpkg.configs import Configs
|
||||||
|
from slpkg.views.version import Version
|
||||||
|
|
||||||
|
|
||||||
|
locale.setlocale(locale.LC_ALL, '')
|
||||||
|
|
||||||
|
|
||||||
|
class DialogBox:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.configs = Configs()
|
||||||
|
self.d = Dialog(dialog="dialog")
|
||||||
|
self.d.set_background_title(f'{self.configs.prog_name} {Version().version}')
|
||||||
|
|
||||||
|
def checklist(self, text, title, height, width, list_height, choices):
|
||||||
|
""" Choose packages for upgrade. """
|
||||||
|
|
||||||
|
code, tags = self.d.checklist(text, title=title, height=height, width=width,
|
||||||
|
list_height=list_height, choices=choices)
|
||||||
|
|
||||||
|
return code, tags
|
|
@ -2,19 +2,15 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import locale
|
|
||||||
from dialog import Dialog
|
|
||||||
from distutils.version import LooseVersion
|
from distutils.version import LooseVersion
|
||||||
|
|
||||||
from slpkg.configs import Configs
|
from slpkg.configs import Configs
|
||||||
|
from slpkg.dialog_box import DialogBox
|
||||||
from slpkg.queries import SBoQueries
|
from slpkg.queries import SBoQueries
|
||||||
from slpkg.utilities import Utilities
|
from slpkg.utilities import Utilities
|
||||||
from slpkg.blacklist import Blacklist
|
from slpkg.blacklist import Blacklist
|
||||||
from slpkg.dependencies import Requires
|
from slpkg.dependencies import Requires
|
||||||
from slpkg.views.version import Version
|
|
||||||
|
|
||||||
|
|
||||||
locale.setlocale(locale.LC_ALL, '')
|
|
||||||
|
|
||||||
|
|
||||||
class Upgrade:
|
class Upgrade:
|
||||||
|
@ -23,8 +19,7 @@ class Upgrade:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.configs = Configs
|
self.configs = Configs
|
||||||
self.utils = Utilities()
|
self.utils = Utilities()
|
||||||
self.d = Dialog(dialog="dialog")
|
self.dialog = DialogBox()
|
||||||
self.d.set_background_title(f'{self.configs.prog_name} {Version().version}')
|
|
||||||
|
|
||||||
def search(self):
|
def search(self):
|
||||||
""" Compares version of packages and returns the maximum. """
|
""" Compares version of packages and returns the maximum. """
|
||||||
|
@ -53,6 +48,7 @@ class Upgrade:
|
||||||
|
|
||||||
def packages(self):
|
def packages(self):
|
||||||
""" Choose packages for upgrade. """
|
""" Choose packages for upgrade. """
|
||||||
|
title = ' Choose packages you want to upgrade '
|
||||||
choices = []
|
choices = []
|
||||||
packages = list(self.search())
|
packages = list(self.search())
|
||||||
|
|
||||||
|
@ -63,11 +59,15 @@ class Upgrade:
|
||||||
repo_ver = SBoQueries(package).version()
|
repo_ver = SBoQueries(package).version()
|
||||||
choices += [(package, f'{inst_ver} -> {repo_ver}', True)]
|
choices += [(package, f'{inst_ver} -> {repo_ver}', True)]
|
||||||
|
|
||||||
code, tags = self.d.checklist(f'There are {len(choices)} packages for upgrade:',
|
text = f'There are {len(choices)} packages for upgrade:'
|
||||||
title=' Choose packages you want to upgrade ',
|
height = 10
|
||||||
height=10, width=70, list_height=0, choices=choices)
|
width = 70
|
||||||
|
list_height = 0
|
||||||
|
|
||||||
|
code, tags = self.dialog.checklist(text, title, height, width, list_height, choices)
|
||||||
|
|
||||||
os.system('clear')
|
os.system('clear')
|
||||||
if code == self.d.OK:
|
if code == 'ok':
|
||||||
if not tags:
|
if not tags:
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
return tags
|
return tags
|
||||||
|
|
Loading…
Add table
Reference in a new issue