PyQt/Demo/SingleApplication.py

36 lines
750 B
Python
Raw Normal View History

2017-03-30 22:26:58 +08:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
2021-07-13 14:52:26 +08:00
"""
2017-03-30 22:26:58 +08:00
Created on 2017年3月30日
2021-07-13 14:52:26 +08:00
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
2017-03-30 22:26:58 +08:00
@email: 892768447@qq.com
@file: TestQSingleApplication
@description:
2021-07-13 14:52:26 +08:00
"""
2017-03-30 22:26:58 +08:00
from PyQt5.QtWidgets import QTextEdit
2019-01-01 17:04:10 +08:00
from Lib.Application import QSingleApplication # @UnresolvedImport
2017-03-30 22:26:58 +08:00
class Widget(QTextEdit):
2021-07-13 14:52:26 +08:00
2017-03-30 22:26:58 +08:00
def __init__(self, *args, **kwargs):
super(Widget, self).__init__(*args, **kwargs)
2021-07-13 14:52:26 +08:00
2017-03-30 22:26:58 +08:00
if __name__ == "__main__":
import sys
2021-07-13 14:52:26 +08:00
2017-03-30 22:26:58 +08:00
app = QSingleApplication(sys.argv)
if app.isRunning():
app.sendMessage("app is running")
sys.exit(0)
t = Widget()
app.setActivationWindow(t)
app.messageReceived.connect(t.append)
t.show()
sys.exit(app.exec_())