-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (35 loc) · 1.31 KB
/
Copy pathmain.py
File metadata and controls
47 lines (35 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
from pathlib import Path
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QApplication
from app.main_window import MainWindow
from app.runtime_compat import meipass_root
def _resolve_app_icon() -> QIcon:
"""Return the bundled application icon, or an empty QIcon if missing.
In a PyInstaller one-file build the data tree is unpacked under
``sys._MEIPASS``; in a normal source checkout it lives next to the
repository root.
"""
base = meipass_root() or Path(__file__).resolve().parent
icon_path = base / "packaging" / "linux" / "editabletreemodel.png"
if icon_path.is_file():
return QIcon(str(icon_path))
return QIcon()
def main():
filename = ""
if len(sys.argv) == 2:
filename = sys.argv[1]
app = QApplication(sys.argv)
# Force the cross-platform Fusion style so hover/selection palettes are
# consistent and themable on every platform. Notably it tames the bright
# blue native ``State_MouseOver`` highlight on Windows (issue #05).
if sys.platform.startswith("win"):
app.setStyle("Fusion")
icon = _resolve_app_icon()
if not icon.isNull():
app.setWindowIcon(icon)
window = MainWindow(filename)
window.show_with_restored_mode()
sys.exit(app.exec())
if __name__ == "__main__":
main()