mirror of
https://github.com/shizand/statapp.git
synced 2024-12-23 20:22:58 +03:00
52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
#
|
|
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko.
|
|
#
|
|
# This file is part of Statapp
|
|
# (see https://github.com/shizand/statapp).
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
import os
|
|
import sys
|
|
|
|
from PySide2.QtWidgets import QMessageBox
|
|
|
|
|
|
def resource_path(relative):
|
|
if getattr(sys, 'frozen', False):
|
|
bundle_dir = sys._MEIPASS
|
|
else:
|
|
# we are running in a normal Python environment
|
|
bundle_dir = os.path.dirname(os.path.abspath(__file__))
|
|
return os.path.join(bundle_dir, relative)
|
|
|
|
|
|
def safe_list_get(l, idx, default):
|
|
try:
|
|
return l[idx]
|
|
except IndexError:
|
|
return default
|
|
|
|
|
|
def buildMessageBox(title, text, icon, buttons, defaultButton):
|
|
msgBox = QMessageBox()
|
|
|
|
msgBox.setIcon(icon)
|
|
msgBox.setWindowTitle(title)
|
|
msgBox.setText(text)
|
|
msgBox.setStandardButtons(buttons)
|
|
msgBox.setDefaultButton(defaultButton)
|
|
|
|
return msgBox
|