GUI development
This commit is contained in:
36
horsygui.py
36
horsygui.py
@@ -20,6 +20,9 @@ MainWindow.show()
|
||||
|
||||
|
||||
# Functions
|
||||
def refresh_gui():
|
||||
installed_apps()
|
||||
|
||||
def installed_apps():
|
||||
from modules.manager import apps_list
|
||||
ui.installed_table.clear()
|
||||
@@ -30,14 +33,18 @@ def installed_apps():
|
||||
ui.installed_table.setItem(i // 4, i % 4, QtWidgets.QTableWidgetItem(str(apps[i])))
|
||||
|
||||
def update_app():
|
||||
try:
|
||||
app_name = ui.installed_table.currentItem().text()
|
||||
if app_name == "":
|
||||
return
|
||||
else:
|
||||
from modules.manager import install
|
||||
install(app_name)
|
||||
install(app_name, True)
|
||||
except:
|
||||
return
|
||||
|
||||
def uninstall_app():
|
||||
try:
|
||||
app_name = ui.installed_table.currentItem().text()
|
||||
if app_name == "":
|
||||
return
|
||||
@@ -45,6 +52,8 @@ def uninstall_app():
|
||||
from modules.manager import uninstall
|
||||
uninstall(app_name)
|
||||
installed_apps()
|
||||
except:
|
||||
return
|
||||
|
||||
def search_gui():
|
||||
from modules.search import search
|
||||
@@ -59,13 +68,38 @@ def search_gui():
|
||||
for i in range(len(found)):
|
||||
ui.search_table.setItem(i // 4, i % 4, QtWidgets.QTableWidgetItem(str(found[i])))
|
||||
|
||||
def install_app():
|
||||
from modules.manager import install
|
||||
try:
|
||||
app_name = ui.search_table.currentItem().text()
|
||||
if app_name == "":
|
||||
return
|
||||
else:
|
||||
install(app_name, True)
|
||||
except:
|
||||
return
|
||||
|
||||
def get_source_gui():
|
||||
from modules.source import get_source
|
||||
try:
|
||||
app_name = ui.search_table.currentItem().text()
|
||||
if app_name == "":
|
||||
return
|
||||
else:
|
||||
get_source(app_name)
|
||||
except:
|
||||
return
|
||||
|
||||
# Run functions on startup
|
||||
installed_apps()
|
||||
|
||||
# Binds
|
||||
ui.tabWidget.currentChanged.connect(refresh_gui)
|
||||
ui.update_button.clicked.connect(update_app)
|
||||
ui.delete_button.clicked.connect(uninstall_app)
|
||||
ui.search_button.clicked.connect(search_gui)
|
||||
ui.install_button.clicked.connect(install_app)
|
||||
ui.source_button.clicked.connect(get_source_gui)
|
||||
|
||||
|
||||
# Handle GUI exiting to exit whole program
|
||||
|
||||
@@ -201,13 +201,7 @@ class Ui_MainWindow(object):
|
||||
self.manage_packages_table.setDragDropOverwriteMode(False)
|
||||
self.manage_packages_table.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
|
||||
self.manage_packages_table.setShowGrid(False)
|
||||
self.manage_packages_table.setRowCount(1)
|
||||
self.manage_packages_table.setColumnCount(4)
|
||||
self.manage_packages_table.setObjectName("manage_packages_table")
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
self.manage_packages_table.setItem(0, 0, item)
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
self.manage_packages_table.setItem(0, 1, item)
|
||||
self.manage_packages_table.horizontalHeader().setVisible(False)
|
||||
self.manage_packages_table.horizontalHeader().setDefaultSectionSize(203)
|
||||
self.manage_packages_table.horizontalHeader().setHighlightSections(False)
|
||||
@@ -344,13 +338,7 @@ class Ui_MainWindow(object):
|
||||
self.search_table.setDragDropOverwriteMode(False)
|
||||
self.search_table.setSelectionMode(QtWidgets.QAbstractItemView.SingleSelection)
|
||||
self.search_table.setShowGrid(False)
|
||||
self.search_table.setRowCount(1)
|
||||
self.search_table.setColumnCount(4)
|
||||
self.search_table.setObjectName("search_table")
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
self.search_table.setItem(0, 0, item)
|
||||
item = QtWidgets.QTableWidgetItem()
|
||||
self.search_table.setItem(0, 1, item)
|
||||
self.search_table.horizontalHeader().setVisible(False)
|
||||
self.search_table.horizontalHeader().setDefaultSectionSize(203)
|
||||
self.search_table.horizontalHeader().setHighlightSections(False)
|
||||
|
||||
@@ -32,7 +32,7 @@ def install(package, is_gui=False):
|
||||
if not os.path.exists('{1}apps/{0}'.format(r['name'], horsy_vars.horsypath)):
|
||||
os.makedirs('{1}apps/{0}'.format(r['name'], horsy_vars.horsypath))
|
||||
|
||||
if not is_gui:
|
||||
# if not is_gui:
|
||||
print(f"Downloading {r['url'].split('/')[-1]}")
|
||||
|
||||
chunk_size = 1024
|
||||
@@ -74,7 +74,7 @@ def install(package, is_gui=False):
|
||||
|
||||
if r['download']:
|
||||
print(f"Found dependency")
|
||||
if not is_gui:
|
||||
# if not is_gui:
|
||||
print(f"Downloading {r['download'].split('/')[-1]}")
|
||||
|
||||
chunk_size = 1024
|
||||
|
||||
Reference in New Issue
Block a user