mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
GUI: Framless, auto-close when out of focus
This commit is contained in:
parent
6a50f724d2
commit
7cf03b6d4c
1 changed files with 7 additions and 6 deletions
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os, re
|
import os, re, time
|
||||||
from PyQt5.QtGui import QIcon, QCursor
|
from PyQt5.QtGui import QIcon, QCursor, QFocusEvent
|
||||||
from PyQt5.QtCore import pyqtSlot, Qt
|
from PyQt5.QtCore import pyqtSlot, Qt, QEvent
|
||||||
from PyQt5.QtWidgets import (QAction, QApplication, QCheckBox, QComboBox,
|
from PyQt5.QtWidgets import (QAction, QApplication, QCheckBox, QComboBox,
|
||||||
QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
||||||
QMessageBox, QMenu, QPushButton, QSpinBox, QStyle, QSystemTrayIcon,
|
QMessageBox, QMenu, QPushButton, QSpinBox, QStyle, QSystemTrayIcon,
|
||||||
|
@ -335,12 +335,11 @@ class Window(QDialog):
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def showMessage(self):
|
def showMessage(self):
|
||||||
icon = QSystemTrayIcon.MessageIcon(QSystemTrayIcon.Information)
|
|
||||||
self.trayIcon.showMessage("VirtScreen is running",
|
self.trayIcon.showMessage("VirtScreen is running",
|
||||||
"The program will keep running in the system tray. To \n"
|
"The program will keep running in the system tray. To \n"
|
||||||
"terminate the program, choose \"Quit\" in the \n"
|
"terminate the program, choose \"Quit\" in the \n"
|
||||||
"context menu of the system tray entry.",
|
"context menu of the system tray entry.",
|
||||||
icon,
|
QSystemTrayIcon.MessageIcon(QSystemTrayIcon.Information),
|
||||||
7 * 1000)
|
7 * 1000)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
|
@ -608,6 +607,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
QApplication.setQuitOnLastWindowClosed(False)
|
QApplication.setQuitOnLastWindowClosed(False)
|
||||||
window = Window()
|
window = Window()
|
||||||
window.show()
|
window.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
|
||||||
|
time.sleep(2) # Otherwise the trayicon message will be shown in weird position
|
||||||
|
window.showMessage()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
reactor.run()
|
reactor.run()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue