GUI development

This commit is contained in:
BarsTiger
2022-01-26 19:56:07 +02:00
parent c8b409f0de
commit 4217fcccbc
2 changed files with 30 additions and 12 deletions

View File

@@ -6,7 +6,6 @@ from PyQt5 import QtCore, QtGui, QtWidgets
import modules.gui as gui import modules.gui as gui
from modules.console import cls from modules.console import cls
from modules.manager import install, uninstall, apps_list
from modules.virustotal import add_to_cfg from modules.virustotal import add_to_cfg
from modules.uploader import upload from modules.uploader import upload
from modules.source import get_source from modules.source import get_source
@@ -23,17 +22,37 @@ MainWindow.show()
# Functions # Functions
def installed_apps(): def installed_apps():
from modules.manager import apps_list
ui.installed_table.clear()
apps = apps_list(True) apps = apps_list(True)
ui.installed_table.setColumnCount(4) ui.installed_table.setColumnCount(4)
ui.installed_table.setRowCount(math.ceil(len(apps) / 4)) ui.installed_table.setRowCount(math.ceil(len(apps) / 4))
for i in range(len(apps)): for i in range(len(apps)):
ui.installed_table.setItem(i // 4, i % 4, QtWidgets.QTableWidgetItem(str(apps[i]))) ui.installed_table.setItem(i // 4, i % 4, QtWidgets.QTableWidgetItem(str(apps[i])))
def update_app():
app_name = ui.installed_table.currentItem().text()
if app_name == "":
return
else:
from modules.manager import install
install(app_name)
def uninstall_app():
app_name = ui.installed_table.currentItem().text()
if app_name == "":
return
else:
from modules.manager import uninstall
uninstall(app_name)
installed_apps()
# Run functions on startup # Run functions on startup
installed_apps() installed_apps()
# Binds # Binds
ui.update_button.clicked.connect(update_app)
ui.delete_button.clicked.connect(uninstall_app)
# Handle GUI exiting to exit whole program # Handle GUI exiting to exit whole program

View File

@@ -126,17 +126,16 @@ def install(package, is_gui=False):
def uninstall(package, is_gui=False): def uninstall(package, is_gui=False):
if not is_gui: if os.path.exists('{1}apps/{0}'.format(package, horsy_vars.horsypath)):
if os.path.exists('{1}apps/{0}'.format(package, horsy_vars.horsypath)): os.system('rmdir /s /q "{1}apps/{0}"'.format(package, horsy_vars.horsypath))
os.system('rmdir /s /q "{1}apps/{0}"'.format(package, horsy_vars.horsypath)) print(f"[green][OK] Files deleted[/]")
print(f"[green][OK] Files deleted[/]") else:
else: print(f"[red]App {package} is not installed or doesn't have files[/]")
print(f"[red]App {package} is not installed or doesn't have files[/]") if os.path.isfile('{1}apps/{0}.bat'.format(package, horsy_vars.horsypath)):
if os.path.isfile('{1}apps/{0}.bat'.format(package, horsy_vars.horsypath)): os.remove("{1}apps/{0}.bat".format(package, horsy_vars.horsypath))
os.remove("{1}apps/{0}.bat".format(package, horsy_vars.horsypath)) print(f"[green][OK] Launch script deleted[/]")
print(f"[green][OK] Launch script deleted[/]") else:
else: print(f"[red]App {package} is not installed or doesn't have launch script[/]")
print(f"[red]App {package} is not installed or doesn't have launch script[/]")
def apps_list(is_gui=False): def apps_list(is_gui=False):