def gmxmmpbsa_ana(): try: from PyQt6.QtWidgets import QApplication pyqt = True except: try: from PyQt5.QtWidgets import QApplication pyqt = True except: pyqt = False finally: if not pyqt: GMXMMPBSA_ERROR( 'Could not import PyQt5/PyQt6. gmx_MMPBSA_ana will be disabled until PyQt5/PyQt6 is ' 'installed') from GMXMMPBSA.analyzer.gui import GMX_MMPBSA_ANA from GMXMMPBSA.analyzer.utils import get_files app = QApplication(sys.argv) app.setApplicationName('gmx_MMPBSA Analyzer (gmx_MMPBSA_ana)') try: parser = anaparser.parse_args(sys.argv[1:]) except CommandlineError as e: GMXMMPBSA_ERROR('%s: %s' % (type(e).__name__, e)) sys.exit(1) ifiles = get_files(parser) w = GMX_MMPBSA_ANA() w.gettting_data(ifiles) w.show() sys.exit(app.exec())
def makeApp(): app = QApplication(sys.argv) app.setQuitOnLastWindowClosed(False) app.setWindowIcon(makeIcon("tomato")) app.setApplicationName("Pomodoro") app.setOrganizationName("Burak Martin") app.setOrganizationDomain("https://github.com/burakmartin") return app
import sys from PyQt6.QtWidgets import QApplication from src.wordprocessor import MainWindow if __name__ == "__main__": app = QApplication(sys.argv) app.setApplicationName("Free text editor") window = MainWindow() app.exec()
class Application: def __init__(self, args): Log.append('app_init', 'Info', 'version: %s' % Const.version) set_default(default_zone=Zone(home_dir=pyinstaller.get_runtime_dir())) self.qt = QApplication(args) self.qt.setApplicationName(Const.app_name) self.qt.setWindowIcon( QIcon('%s/app/res/icon.png' % pyinstaller.get_runtime_dir())) self.hook_exception() self.config = Config() self.config.load() self.lang = None # type: English self.load_language(Config.language) self.events = { 'process_events': self.qt.processEvents, 'export_log': self.export_log, 'check_update': self.check_update, 'load_language': self.load_language, 'get_language': lambda: self.lang, 'set_language': self.set_language, 'get_config': lambda: self.config, } def load_language(self, language): self.lang = load_language(language) def set_language(self, language): self.lang = load_language(language) self.config.language = language self.config.save() def run(self): init_app(events=self.events) return self.qt.exec() def callback_exception(self, exc=None): if exc is None: exc = common.get_exception() Log.append(self.callback_exception, 'Error', exc) if QMessageBox.warning(None, self.lang.title_crash, self.lang.description_crash): self.export_log() def export_log(self): folder = QFileDialog.getExistingDirectory( None, caption=self.lang.menu_export_log) if folder is not None: log = Log.extract_log() err = Log.extract_err() for f in Config._protect_fields: v = getattr(Config, f, '') if v != '': log = log.replace(v, Const.protector) err = err.replace(v, Const.protector) if log != '': with open('%s/%s' % (folder, '%s.log' % Const.app_name), 'w') as io: io.write(log) if err != '': with open('%s/%s' % (folder, '%s.err' % Const.app_name), 'w') as io: io.write(err) def check_update(self, test=False): try: release = github.get_latest_release(Const.author, Const.app_name, timeout=5) Log.append(self.check_update, 'Info', release) if test or common.compare_version(Const.version, release['tag_name']): if len(release['assets']) > 0: QMessageBox.information( self.lang.title_check_update, '%s\n%s\n\n%s' % (self.lang.description_new_version, release['body'], release['assets'][0]['browser_download_url'])) else: QMessageBox.information( self.lang.title_check_update, '%s\n%s\n\n%s' % (self.lang.description_new_version, release['body'], release['assets'][0]['browser_download_url'])) except: Log.append(self.check_update, 'Warning', common.get_exception()) def hook_exception(self): def boom(type, value, tb): from io import StringIO from app.util import io_helper import traceback with StringIO() as io: traceback.print_exception(type, value, tb, file=io) exc = io_helper.read_all(io) self.callback_exception(exc) sys.excepthook = boom
# -*- coding: utf-8 -*- # image_manager/__init__.py # Import necessary modules from PyQt6.QtWidgets import QApplication """This module sets up the budget_tracker package.""" QApplication.setApplicationName("Budget Tracker") __version__ = QApplication.setApplicationVersion('1.1.0')
# -*- coding: utf-8 -*- # image_manager/__init__.py # Import necessary modules from PyQt6.QtWidgets import QApplication """This module sets up the image_manager package.""" QApplication.setApplicationName("Image Manager") __version__ = QApplication.setApplicationVersion('1.1.0')
import os import sys from PyQt6.QtGui import QIcon from PyQt6.QtWidgets import QApplication from dashboad import SwaVanMainWindow from shared.recorder import SwaVanLogRecorder from shared.widgets.builder import full_path if __name__ == "__main__": app = QApplication(sys.argv) app.setApplicationDisplayName("SwaVan") app.setApplicationName("SwaVan") app.setDesktopFileName("SwaVan") app.setWindowIcon(QIcon(full_path("assets/images/logo/swavan_one_ui.icns"))) with open(full_path("assets/style/dark.qss"), 'r') as file: qss = file.read() app.setStyleSheet(qss) if os.path.exists(full_path("data/logs/swavan.log")): open(full_path("data/logs/swavan.log"), 'w').close() widget = SwaVanMainWindow() widget.show() SwaVanLogRecorder.init() sys.exit(app.exec())