-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (44 loc) · 1.46 KB
/
Copy pathmain.py
File metadata and controls
54 lines (44 loc) · 1.46 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
48
49
50
51
52
53
54
from PySide6.QtGui import QIcon, QAction
from PySide6.QtWidgets import QApplication, QSystemTrayIcon, QMenu, QMessageBox
import subprocess
import os
import sys
basedir = os.path.dirname(__file__)
script_base_path = os.path.join(basedir, "scripts")
script_path = (os.path.join(basedir, "scripts", "launch.sh"))
result = subprocess.run(['/bin/bash', script_path, script_base_path])
app = QApplication([])
app.setQuitOnLastWindowClosed(False)
if result.returncode == 1:
QMessageBox.critical(
None, # Parent widget (None means it will be a top-level window)
"Error", # Title of the message box
"PyOMlx cannot be started due to some error. Check logs in /tmp/pyomlx-*.log", # Message text
QMessageBox.Ok # Buttons to display
)
sys.exit(1)
def stopServer():
stop_script_path = (os.path.join(basedir, "scripts", "stop.sh"))
subprocess.run(['/bin/sh', stop_script_path])
app.quit()
def showAbout():
ab = QMessageBox()
ab.setText("PyOMlx \n\n Version 0.1.2 \n Copyright Viswa Kumar ©️ 2025")
ab.exec()
# Create the icon
icon = QIcon(os.path.join(basedir, "logo.png"))
# Create the tray
tray = QSystemTrayIcon()
tray.setIcon(icon)
tray.setVisible(True)
# Add a Quit option to the menu.
menu = QMenu()
quit = QAction("Quit")
about = QAction('About')
quit.triggered.connect(stopServer)
about.triggered.connect(showAbout)
menu.addAction(about)
menu.addAction(quit)
# Add the menu to the tray
tray.setContextMenu(menu)
app.exec()