Fix some parameter issues and replace tkinter messagebox with Qt-based messagebox.
This commit is contained in:
@@ -151,7 +151,7 @@ class Launcher(QApplication, LauncherObject):
|
|||||||
full_path = self.styles_path / qss_relative_path
|
full_path = self.styles_path / qss_relative_path
|
||||||
if not full_path.exists():
|
if not full_path.exists():
|
||||||
messagebox.error(
|
messagebox.error(
|
||||||
self.main_window,
|
None,
|
||||||
"Resource Error",
|
"Resource Error",
|
||||||
"Missing stylesheet file: {}".format(full_path),
|
"Missing stylesheet file: {}".format(full_path),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from PySide6.QtWidgets import QMessageBox, QMainWindow, QWidget, QDialog, QVBoxL
|
|||||||
QDialogButtonBox, QSizePolicy
|
QDialogButtonBox, QSizePolicy
|
||||||
|
|
||||||
|
|
||||||
def create_messagebox(parent: QWidget, title: str, message: str,
|
def create_messagebox(parent: QWidget | None, title: str, message: str,
|
||||||
icon: QMessageBox.Icon = QMessageBox.Icon.Information,
|
icon: QMessageBox.Icon = QMessageBox.Icon.Information,
|
||||||
button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> QMessageBox:
|
button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> QMessageBox:
|
||||||
msg = QMessageBox(parent)
|
msg = QMessageBox(parent)
|
||||||
@@ -13,7 +13,7 @@ def create_messagebox(parent: QWidget, title: str, message: str,
|
|||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
|
||||||
def error(parent: QWidget, title: str, message: str,
|
def error(parent: QWidget | None, title: str, message: str,
|
||||||
button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> None:
|
button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> None:
|
||||||
create_messagebox(
|
create_messagebox(
|
||||||
parent,
|
parent,
|
||||||
@@ -24,7 +24,7 @@ def error(parent: QWidget, title: str, message: str,
|
|||||||
).exec()
|
).exec()
|
||||||
|
|
||||||
|
|
||||||
def info(parent: QWidget, title: str, message: str,
|
def info(parent: QWidget | None, title: str, message: str,
|
||||||
button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> None:
|
button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> None:
|
||||||
create_messagebox(
|
create_messagebox(
|
||||||
parent,
|
parent,
|
||||||
@@ -35,7 +35,7 @@ def info(parent: QWidget, title: str, message: str,
|
|||||||
).exec()
|
).exec()
|
||||||
|
|
||||||
|
|
||||||
def warning(parent: QWidget, title: str, message: str,
|
def warning(parent: QWidget | None, title: str, message: str,
|
||||||
button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> None:
|
button: QMessageBox.StandardButton = QMessageBox.StandardButton.Ok) -> None:
|
||||||
create_messagebox(
|
create_messagebox(
|
||||||
parent,
|
parent,
|
||||||
@@ -47,7 +47,7 @@ def warning(parent: QWidget, title: str, message: str,
|
|||||||
|
|
||||||
|
|
||||||
def error_with_plain_text(
|
def error_with_plain_text(
|
||||||
parent: QWidget,
|
parent: QWidget | None,
|
||||||
title: str,
|
title: str,
|
||||||
message: str,
|
message: str,
|
||||||
content: str,
|
content: str,
|
||||||
@@ -78,7 +78,7 @@ def error_with_plain_text(
|
|||||||
dialog.exec()
|
dialog.exec()
|
||||||
|
|
||||||
|
|
||||||
def ask_yes_no_with_plain_text(parent: QWidget, title: str, message: str, content: str):
|
def ask_yes_no_with_plain_text(parent: QWidget | None, title: str, message: str, content: str):
|
||||||
dialog = QDialog(parent)
|
dialog = QDialog(parent)
|
||||||
dialog.setWindowTitle(title)
|
dialog.setWindowTitle(title)
|
||||||
dialog.resize(720, 420)
|
dialog.resize(720, 420)
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from PySide6.QtWidgets import QApplication, QMainWindow
|
||||||
|
|
||||||
from app import Launcher
|
from app import Launcher
|
||||||
from tkinter import messagebox
|
|
||||||
|
|
||||||
from core_lib.log.default import DEFAULT_FORMAT, DEFAULT_DATE_FORMAT, get_colorful_handler
|
from core_lib.log.default import DEFAULT_FORMAT, DEFAULT_DATE_FORMAT, get_colorful_handler
|
||||||
|
from core_lib.qt import messagebox
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
@@ -43,9 +45,13 @@ def main():
|
|||||||
|
|
||||||
# check workdir
|
# check workdir
|
||||||
if not os.path.exists(args.work_dir) or not os.path.isdir(args.work_dir):
|
if not os.path.exists(args.work_dir) or not os.path.isdir(args.work_dir):
|
||||||
messagebox.showerror("Error", f"Specified work directory \"{args.work_dir}\" does not exist or"
|
app = QApplication(sys.argv)
|
||||||
|
app.setApplicationName("Launcher Bootstrapper")
|
||||||
|
window = QMainWindow()
|
||||||
|
messagebox.error(window, "Error", f"Specified work directory \"{args.work_dir}\" does not exist or"
|
||||||
" is not a directory.")
|
" is not a directory.")
|
||||||
logger.error("Work directory '%s' does not exist. Exiting..." % args.work_dir)
|
logger.error("Work directory '%s' does not exist. Exiting..." % args.work_dir)
|
||||||
|
app.exit()
|
||||||
sys.exit(-1)
|
sys.exit(-1)
|
||||||
|
|
||||||
if os.getcwd() != args.work_dir:
|
if os.getcwd() != args.work_dir:
|
||||||
|
|||||||
Reference in New Issue
Block a user