diff --git a/KOTIKOT_launcher.py b/KOTIKOT_launcher.py index 96e9ebd..8fe66fb 100644 --- a/KOTIKOT_launcher.py +++ b/KOTIKOT_launcher.py @@ -44,7 +44,7 @@ if __name__ == "__main__": # ---------------- Launching GUI ---------------- import OfficialProjects.LAUNCHERFILES.KOTIKOTlauncherMain as kkui import OfficialProjects.LAUNCHERFILES.KOTIKOTlauncherSettings as kkset -import OfficialProjects.LAUNCHERFILES.KOTIKOTlauncherReminder as kkrem +from OfficialProjects.LAUNCHERFILES.KOTIKOTlauncherReminder import popup app = kkui.QtWidgets.QApplication(sys.argv) KOTIKOTlauncher = kkui.QtWidgets.QMainWindow() @@ -57,17 +57,13 @@ KOTIKOTsettings = kkset.QtWidgets.QMainWindow() uiset = kkset.Ui_Form() uiset.setupUi(KOTIKOTsettings) -KOTIKOTreminder = kkrem.QtWidgets.QMainWindow() -uirem = kkrem.Ui_Form() -uirem.setupUi(KOTIKOTreminder) - # ---------------- Launching programs ---------------- def openSettings(): KOTIKOTsettings.show() -def download_app(app): +def downloadApp(app): for url in app['urls']: print('Downloading ' + url) urllib.request.urlretrieve(url, offprojects + app['dir'] + "/" + url.split("/")[-1]) @@ -83,7 +79,7 @@ def launchApp(): if not os.path.exists(directory): os.mkdir(directory) - download_app(app) + downloadApp(app) else: try: @@ -95,14 +91,19 @@ def launchApp(): print('Current app version is ' + str(v) + ' and new version is ' + requests.get('/'.join(app['urls'][0].split('/')[:-1]) + '/v').text) print('Updating...') - download_app(app) + downloadApp(app) urllib.request.urlretrieve('/'.join(app['urls'][0].split('/')[:-1]) + '/v', offprojects + app['dir'] + "/v") display_name = name.replace('\n', '') print(f"---------------- {display_name} ----------------") - subprocess.Popen(str(sys.executable + " " if app['runtime'] == "python" else "") + app['run'], cwd=directory, - shell=True, close_fds=True) + try: + subprocess.Popen(str(sys.executable + " " if app['runtime'] == "python" else "") + app['run'], cwd=directory, + shell=True, close_fds=True) + except: + popup('Could not launch ' + display_name + ', please try again', 'Error') + if not app['window']: + popup('This app opened in terminal') # ---------------- Checking buttons ---------------- diff --git a/OfficialProjects/LAUNCHERFILES/KOTIKOTlauncherReminder.py b/OfficialProjects/LAUNCHERFILES/KOTIKOTlauncherReminder.py index 951cc80..988b10c 100644 --- a/OfficialProjects/LAUNCHERFILES/KOTIKOTlauncherReminder.py +++ b/OfficialProjects/LAUNCHERFILES/KOTIKOTlauncherReminder.py @@ -1,31 +1,15 @@ -from PyQt5 import QtCore, QtGui, QtWidgets +import ctypes -class Ui_Form(object): - def setupUi(self, Form): - Form.setObjectName("Form") - Form.resize(436, 98) - self.label = QtWidgets.QLabel(Form) - self.label.setGeometry(QtCore.QRect(10, 10, 411, 81)) - font = QtGui.QFont() - font.setPointSize(20) - self.label.setFont(font) - self.label.setObjectName("label") - - self.retranslateUi(Form) - QtCore.QMetaObject.connectSlotsByName(Form) - - def retranslateUi(self, Form): - _translate = QtCore.QCoreApplication.translate - Form.setWindowTitle(_translate("Form", "ALWAYS CHECK TERMINAL")) - self.label.setText(_translate("Form", "This app opened in terminal")) - - -if __name__ == "__main__": - import sys - app = QtWidgets.QApplication(sys.argv) - Form = QtWidgets.QWidget() - ui = Ui_Form() - ui.setupUi(Form) - Form.show() - sys.exit(app.exec_()) +def popup(text, title="KOTIKOT_launcher", style=0): + """ + Styles: + 0 : OK + 1 : OK | Cancel + 2 : Abort | Retry | Ignore + 3 : Yes | No | Cancel + 4 : Yes | No + 5 : Retry | Cancel + 6 : Cancel | Try Again | Continue + """ + return ctypes.windll.user32.MessageBoxW(0, text, title, style) diff --git a/OfficialProjects/LAUNCHERFILES/v b/OfficialProjects/LAUNCHERFILES/v index d8263ee..e440e5c 100644 --- a/OfficialProjects/LAUNCHERFILES/v +++ b/OfficialProjects/LAUNCHERFILES/v @@ -1 +1 @@ -2 \ No newline at end of file +3 \ No newline at end of file