개정판 96e1acab
Feature: Tcp로 들어온 사용자 작업이 끝났을때 트레이 아이콘에 메시지를 출력한다.
Change-Id: I492a3fce9fe2f46e572a1fceb1e96135335344b9
DTI_PID/DTI_PID/TcpServer.py | ||
---|---|---|
1 | 1 |
import sys |
2 | 2 |
import json |
3 | 3 |
from PyQt5.QtCore import * |
4 |
from PyQt5.QtWidgets import QApplication, QDialog |
|
4 |
from PyQt5.QtWidgets import QApplication, QDialog, QSystemTrayIcon
|
|
5 | 5 |
from PyQt5.QtNetwork import QHostAddress, QTcpServer, QTcpSocket |
6 |
from PyQt5.QtGui import * |
|
6 | 7 |
|
7 | 8 |
|
8 | 9 |
class TcpSocket(QDialog): |
... | ... | |
27 | 28 |
|
28 | 29 |
|
29 | 30 |
class TcpServer(QDialog): |
31 |
tray_icon = None |
|
30 | 32 |
def __init__(self, port): |
33 |
from App import App |
|
34 |
|
|
31 | 35 |
super().__init__() |
32 | 36 |
self.tcpServer = None |
33 | 37 |
self.port = port |
34 | 38 |
|
39 |
if not TcpServer.tray_icon: |
|
40 |
TcpServer.tray_icon = QSystemTrayIcon(App.mainWnd()) |
|
41 |
TcpServer.tray_icon.setIcon(QIcon(':/newPrefix/ID2.png')) |
|
42 |
TcpServer.tray_icon.show() |
|
43 |
|
|
35 | 44 |
def sessionOpened(self): |
36 | 45 |
self.tcpServer = QTcpServer(self) |
37 | 46 |
PORT = self.port |
... | ... | |
151 | 160 |
rows = cursor.fetchall() |
152 | 161 |
for row in rows: |
153 | 162 |
docData._arsColors[row['UID']] = '#' + row['Color'] |
154 |
# Catch the exception |
|
155 | 163 |
except Exception as ex: |
156 | 164 |
from App import App |
157 |
message = 'error occurred({}) in {}:{}'.format(ex, sys.exc_info()[-1].tb_frame.f_code.co_filename,
|
|
158 |
sys.exc_info()[-1].tb_lineno)
|
|
165 |
message = f'error occurred({ex}) in {sys.exc_info()[-1].tb_frame.f_code.co_filename}:' \
|
|
166 |
f'{sys.exc_info()[-1].tb_lineno}'
|
|
159 | 167 |
App.mainWnd().addMessage.emit(MessageType.Error, message) |
160 | 168 |
|
161 | 169 |
dis_option = DisplayColors.instance().option |
... | ... | |
166 | 174 |
DisplayColors.instance().option = dis_option |
167 | 175 |
else: |
168 | 176 |
pass |
177 |
|
|
178 |
'''트레이 아이콘에 메시지를 표시하여 사용자에게 작업이 끝났다는 것을 알림''' |
|
179 |
QApplication.alert(App.mainWnd(), 0) |
|
180 |
TcpServer.tray_icon.showMessage('Information', 'Request is finished.', QSystemTrayIcon.Information, 100) |
|
169 | 181 |
else: |
170 | 182 |
print('no data from') |
171 | 183 |
|
내보내기 Unified diff