GUI development
This commit is contained in:
14
horsy.py
14
horsy.py
@@ -4,11 +4,7 @@ import sys
|
||||
|
||||
import modules.tui as tui
|
||||
from modules.console import cls
|
||||
from modules.manager import install, uninstall, apps_list
|
||||
from modules.virustotal import add_to_cfg
|
||||
from modules.uploader import upload
|
||||
from modules.source import get_source
|
||||
from modules.search import search, info
|
||||
import modules.vars as horsy_vars
|
||||
|
||||
# Getting the arguments
|
||||
@@ -64,32 +60,38 @@ if not args.option:
|
||||
'upload your app', 'search for app', 'get information about app'])]
|
||||
isNoArgs = True
|
||||
|
||||
|
||||
# Checking user option (Yanderedev method)
|
||||
if not args.app:
|
||||
if option not in ['list', 'upload', 'update']:
|
||||
print('\n')
|
||||
app = tui.get(f'Select app to {option}')
|
||||
|
||||
# Checking user option (Yanderedev method)
|
||||
if option in 'upload':
|
||||
from modules.uploader import upload
|
||||
upload()
|
||||
|
||||
if option in ['install', 'i']:
|
||||
from modules.manager import install
|
||||
install(app)
|
||||
|
||||
if option in ['uninstall', 'un']:
|
||||
from modules.manager import uninstall
|
||||
uninstall(app)
|
||||
|
||||
if option in ['source', 's']:
|
||||
from modules.source import get_source
|
||||
get_source(app)
|
||||
|
||||
if option in ['search']:
|
||||
from modules.search import search
|
||||
search(app)
|
||||
|
||||
if option in ['info']:
|
||||
from modules.search import info
|
||||
info(app)
|
||||
|
||||
if option in ['list', 'l']:
|
||||
from modules.manager import apps_list
|
||||
apps_list()
|
||||
|
||||
if isNoArgs:
|
||||
|
||||
19
horsygui.py
19
horsygui.py
@@ -1,6 +1,7 @@
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import math
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
|
||||
import modules.gui as gui
|
||||
@@ -12,11 +13,6 @@ from modules.source import get_source
|
||||
from modules.search import search, info
|
||||
import modules.vars as horsy_vars
|
||||
|
||||
|
||||
# Functions
|
||||
def installed_apps():
|
||||
|
||||
|
||||
# Initialize GUI
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
MainWindow = QtWidgets.QMainWindow()
|
||||
@@ -24,6 +20,19 @@ ui = gui.Ui_MainWindow()
|
||||
ui.setupUi(MainWindow)
|
||||
MainWindow.show()
|
||||
|
||||
|
||||
# Functions
|
||||
def installed_apps():
|
||||
apps = apps_list(True)
|
||||
ui.installed_table.setColumnCount(4)
|
||||
ui.installed_table.setRowCount(math.ceil(len(apps) / 4))
|
||||
for i in range(len(apps)):
|
||||
ui.installed_table.setItem(i // 4, i % 4, QtWidgets.QTableWidgetItem(str(apps[i])))
|
||||
|
||||
|
||||
# Run functions on startup
|
||||
installed_apps()
|
||||
|
||||
# Binds
|
||||
|
||||
|
||||
|
||||
@@ -584,13 +584,7 @@ class Ui_MainWindow(object):
|
||||
self.installed_table.setDragDropOverwriteMode(False)
|
||||
self.installed_table.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
|
||||
self.installed_table.setShowGrid(False)
|
||||
self.installed_table.setRowCount(1)
|
||||
self.installed_table.setColumnCount(4)
|
||||
self.installed_table.setObjectName("installed_table")
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
self.installed_table.setItem(0, 0, item)
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
self.installed_table.setItem(0, 1, item)
|
||||
self.installed_table.horizontalHeader().setVisible(False)
|
||||
self.installed_table.horizontalHeader().setDefaultSectionSize(203)
|
||||
self.installed_table.horizontalHeader().setHighlightSections(False)
|
||||
|
||||
@@ -142,11 +142,12 @@ def uninstall(package, is_gui=False):
|
||||
def apps_list(is_gui=False):
|
||||
apps = list()
|
||||
if os.path.exists('{0}apps'.format(horsy_vars.horsypath)):
|
||||
print(f"[green]Installed apps:[/]")
|
||||
if not is_gui:
|
||||
print(f"[green]Installed apps:[/]")
|
||||
for file in os.listdir('{0}apps'.format(horsy_vars.horsypath)):
|
||||
if file.endswith(".bat") and not is_gui:
|
||||
print(f"{file.split('.')[0]}")
|
||||
else:
|
||||
elif file.endswith(".bat"):
|
||||
apps.append(file.split('.')[0])
|
||||
if is_gui:
|
||||
return apps
|
||||
|
||||
@@ -6,8 +6,9 @@ import modules.vars as horsy_vars
|
||||
import json
|
||||
from rich import print
|
||||
|
||||
|
||||
client = SearchClient.create('VBUJO9OW62', '759f6c7986842fd8218e79e3b9ddb964')
|
||||
client = SearchClient.create(
|
||||
requests.get('https://raw.githubusercontent.com/BarsTiger/horsy/master/web_vars/search_app').json()['APP_ID'],
|
||||
requests.get('https://raw.githubusercontent.com/BarsTiger/horsy/master/web_vars/search_app').json()['API_KEY'])
|
||||
index = client.init_index('packages')
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user