-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrawing_app.py
More file actions
76 lines (58 loc) · 2.65 KB
/
Copy pathdrawing_app.py
File metadata and controls
76 lines (58 loc) · 2.65 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from PyQt5.QtWidgets import QMainWindow, QApplication
from PyQt5.QtCore import Qt, QEvent
from PyQt5.QtWinExtras import QtWin # Добавляем для Windows
from canvas import Canvas
from control_window import ControlWindow
import sys
class DrawingApp(QMainWindow):
def __init__(self):
super().__init__(None, Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool)
self.init_ui()
# Создаем окно управления
self.control_window = ControlWindow(self)
self.control_window.show()
# Понижаем z-order холста
self.lower()
# Добавляем обработчик горячих клавиш
self.installEventFilter(self)
self.setFocusPolicy(Qt.NoFocus)
def init_ui(self):
screen = QApplication.primaryScreen().geometry()
self.setGeometry(screen)
self.canvas = Canvas(self)
self.setCentralWidget(self.canvas)
self.setAttribute(Qt.WA_TranslucentBackground)
self.is_clickthrough = False
def toggle_click_through(self):
self.is_clickthrough = not self.is_clickthrough
if self.is_clickthrough:
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool | Qt.WindowTransparentForInput)
else:
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool)
self.show()
self.showFullScreen()
self.lower() # Снова понижаем z-order после переключения флагов
def eventFilter(self, obj, event):
if event.type() == QEvent.KeyPress: # Changed from Qt.KeyPress to QEvent.KeyPress
# Alt+H для показа/скрытия окна настроек
if event.key() == Qt.Key_H and event.modifiers() == Qt.AltModifier:
self.control_window.toggle_visibility()
return True
return super().eventFilter(obj, event)
def focusInEvent(self, event):
# Игнорируем попытки получения фокуса основным окном
event.ignore()
def main():
app = QApplication(sys.argv)
# Загружаем стили
with open('styles.qss', 'r') as f:
style = f.read()
app.setStyleSheet(style)
if hasattr(sys, 'frozen'):
# Устанавливаем иконку для exe файла
QtWin.setCurrentProcessExplicitAppUserModelID('UVScreenNotes')
window = DrawingApp()
window.showFullScreen()
sys.exit(app.exec_())
if __name__ == '__main__':
main()