GUI development
This commit is contained in:
15
horsygui.py
15
horsygui.py
@@ -9,7 +9,6 @@ from modules.console import cls
|
|||||||
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
|
||||||
from modules.search import search, info
|
|
||||||
import modules.vars as horsy_vars
|
import modules.vars as horsy_vars
|
||||||
|
|
||||||
# Initialize GUI
|
# Initialize GUI
|
||||||
@@ -47,12 +46,26 @@ def uninstall_app():
|
|||||||
uninstall(app_name)
|
uninstall(app_name)
|
||||||
installed_apps()
|
installed_apps()
|
||||||
|
|
||||||
|
def search_gui():
|
||||||
|
from modules.search import search
|
||||||
|
search_query = ui.search_box.toPlainText()
|
||||||
|
if search_query == "":
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
found = search(search_query, True)
|
||||||
|
ui.search_table.clear()
|
||||||
|
ui.search_table.setColumnCount(4)
|
||||||
|
ui.search_table.setRowCount(math.ceil(len(found) / 4))
|
||||||
|
for i in range(len(found)):
|
||||||
|
ui.search_table.setItem(i // 4, i % 4, QtWidgets.QTableWidgetItem(str(found[i])))
|
||||||
|
|
||||||
# Run functions on startup
|
# Run functions on startup
|
||||||
installed_apps()
|
installed_apps()
|
||||||
|
|
||||||
# Binds
|
# Binds
|
||||||
ui.update_button.clicked.connect(update_app)
|
ui.update_button.clicked.connect(update_app)
|
||||||
ui.delete_button.clicked.connect(uninstall_app)
|
ui.delete_button.clicked.connect(uninstall_app)
|
||||||
|
ui.search_button.clicked.connect(search_gui)
|
||||||
|
|
||||||
|
|
||||||
# Handle GUI exiting to exit whole program
|
# Handle GUI exiting to exit whole program
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import json
|
import json
|
||||||
|
import modules.vars as horsy_vars
|
||||||
|
|
||||||
|
|
||||||
def get_auth():
|
def get_auth():
|
||||||
with open('config.cfg') as f:
|
with open(horsy_vars.horsypath + 'config.cfg') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -17,17 +18,17 @@ def get_auth():
|
|||||||
print('password')
|
print('password')
|
||||||
password = input('> ')
|
password = input('> ')
|
||||||
config['auth'] = {'email': email, 'password': password}
|
config['auth'] = {'email': email, 'password': password}
|
||||||
with open('config.cfg', 'w') as f:
|
with open(horsy_vars.horsypath + 'config.cfg', 'w') as f:
|
||||||
json.dump(config, f)
|
json.dump(config, f)
|
||||||
print('[OK] Auth created')
|
print('[OK] Auth created')
|
||||||
return config['auth']
|
return config['auth']
|
||||||
|
|
||||||
|
|
||||||
def del_auth():
|
def del_auth():
|
||||||
with open('config.cfg') as f:
|
with open(horsy_vars.horsypath + 'config.cfg') as f:
|
||||||
config = json.load(f)
|
config = json.load(f)
|
||||||
if config['auth']:
|
if config['auth']:
|
||||||
config['auth'] = None
|
config['auth'] = None
|
||||||
with open('config.cfg', 'w') as f:
|
with open(horsy_vars.horsypath + 'config.cfg', 'w') as f:
|
||||||
json.dump(config, f)
|
json.dump(config, f)
|
||||||
print('[OK] Auth deleted')
|
print('[OK] Auth deleted')
|
||||||
|
|||||||
@@ -12,11 +12,17 @@ client = SearchClient.create(
|
|||||||
index = client.init_index('packages')
|
index = client.init_index('packages')
|
||||||
|
|
||||||
|
|
||||||
def search(query):
|
def search(query, is_gui=False):
|
||||||
res = index.search(query)['hits']
|
res = index.search(query)['hits']
|
||||||
|
ret_res = list()
|
||||||
for i in res:
|
for i in res:
|
||||||
print(textwrap.shorten(f"{i['name']} by {i['authorName']} - {i['description']}",
|
if not is_gui:
|
||||||
width=os.get_terminal_size().columns))
|
print(textwrap.shorten(f"{i['name']} by {i['authorName']} - {i['description']}",
|
||||||
|
width=os.get_terminal_size().columns))
|
||||||
|
else:
|
||||||
|
ret_res.append(i['name'])
|
||||||
|
|
||||||
|
return ret_res
|
||||||
|
|
||||||
|
|
||||||
def info(package):
|
def info(package):
|
||||||
|
|||||||
Reference in New Issue
Block a user