From 8b9803bc406b83342998692d6de867beb302c59c Mon Sep 17 00:00:00 2001 From: Irony <892768447@qq.com> Date: Fri, 26 Apr 2019 18:06:27 +0800 Subject: [PATCH] IsSignalConnected --- .settings/org.eclipse.core.resources.prefs | 1 + Demo/IsSignalConnected.py | 63 +++++++++++++++++++++ Demo/README.md | 10 +++- Demo/ScreenShot/IsSignalConnected.png | Bin 0 -> 8633 bytes README.md | 1 + 5 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 Demo/IsSignalConnected.py create mode 100644 Demo/ScreenShot/IsSignalConnected.png diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs index cfd34c0..7439a6e 100644 --- a/.settings/org.eclipse.core.resources.prefs +++ b/.settings/org.eclipse.core.resources.prefs @@ -6,6 +6,7 @@ encoding//Demo/FacePoints.py=utf-8 encoding//Demo/FollowWindow.py=utf-8 encoding//Demo/FramelessDialog.py=utf-8 encoding//Demo/FramelessWindow.py=utf-8 +encoding//Demo/IsSignalConnected.py=utf-8 encoding//Demo/Lib/Application.py=utf-8 encoding//Demo/Lib/FramelessWindow.py=utf-8 encoding//Demo/NativeEvent.py=utf-8 diff --git a/Demo/IsSignalConnected.py b/Demo/IsSignalConnected.py new file mode 100644 index 0000000..4dbb19e --- /dev/null +++ b/Demo/IsSignalConnected.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +""" +Created on 2019年2月24日 +@author: Irony +@site: https://pyqt5.com https://github.com/892768447 +@email: 892768447@qq.com +@file: IsSignalConnected +@description: 判断信号是否连接 +""" + +from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton, QTextBrowser + + +__Author__ = """By: Irony +QQ: 892768447 +Email: 892768447@qq.com""" +__Copyright__ = 'Copyright (c) 2019 Irony' +__Version__ = 1.0 + + +class Window(QWidget): + + def __init__(self, *args, **kwargs): + super(Window, self).__init__(*args, **kwargs) + layout = QVBoxLayout(self) + self.button1 = QPushButton('已连接', self, clicked=self.doTest) + self.button2 = QPushButton('未连接', self) + self.retView = QTextBrowser(self) + layout.addWidget(self.button1) + layout.addWidget(self.button2) + layout.addWidget(self.retView) + + def doTest(self): + self.retView.append(""" + # button1 clicked 是否连接: %s + # button2 clicked 是否连接: %s + """ % ( + self.isSignalConnected(self.button1, 'clicked()'), + self.isSignalConnected(self.button2, 'clicked()') + )) + + def isSignalConnected(self, obj, name): + """判断信号是否连接 + :param obj: 对象 + :param name: 信号名,如 clicked() + """ + index = obj.metaObject().indexOfMethod(name) + if index > -1: + method = obj.metaObject().method(index) + if method: + return obj.isSignalConnected(method) + return False + + +if __name__ == '__main__': + import sys + from PyQt5.QtWidgets import QApplication + app = QApplication(sys.argv) + w = Window() + w.show() + sys.exit(app.exec_()) diff --git a/Demo/README.md b/Demo/README.md index a3c3cb9..00ed0be 100644 --- a/Demo/README.md +++ b/Demo/README.md @@ -19,6 +19,7 @@ - [背景连线动画](#17、背景连线动画) - [无边框圆角对话框](#18、无边框圆角对话框) - [调整窗口显示边框](#19、调整窗口显示边框) + - [判断信号是否连接](#20、判断信号是否连接) ## 1、重启窗口Widget [运行 RestartWindow.py](RestartWindow.py) @@ -194,4 +195,11 @@ PyQt 结合 Opencv 进行人脸检测; 好处在于可以减少窗口更新的次数(用途有频繁渲染的界面) -![ShowFrameWhenDrag](ScreenShot/ShowFrameWhenDrag.gif) \ No newline at end of file +![ShowFrameWhenDrag](ScreenShot/ShowFrameWhenDrag.gif) + +## 20、判断信号是否连接 +[运行 IsSignalConnected.py](IsSignalConnected.py) + +通过 `isSignalConnected` 判断是否连接 + +![IsSignalConnected](ScreenShot/IsSignalConnected.png) \ No newline at end of file diff --git a/Demo/ScreenShot/IsSignalConnected.png b/Demo/ScreenShot/IsSignalConnected.png new file mode 100644 index 0000000000000000000000000000000000000000..e87aaeff9f4ad77ea9b55dc1e54992d69fae430a GIT binary patch literal 8633 zcmd6NX*`?j+V6v^wx-TS4b`RErOQyIs+CY}(VD8J3Nf@|iqIlRh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l>vngd zz8tr>fN8a*;F;NpBfI_GNs>eAG$d(KE`v?-ATgQ+DDeB}VM!PYB;Fg+iLTqtV5R7? zi(c9h1Iy^?sp`s>(|Jtn%9S8t^vn^n)I`T+vgS(5i})%_Evn)p-5_TL zh3(EWUa7Ew=(HZM)<#GPyRw%IkVi=HX~s9(ElAFh;33sP?{j0s^caVnAb9u%cQ_*e za$|oB;bl8{lf2x>_HCA-?>^Jfh_`*vf*|P)W4_tE+U3NB&S&M*t1oqIjajo6Ks)11 z-8pjD6v@y#;i6ecK~pVsc`e`8QD;Hp%=b*9onx;^jW2i|zjdnIrhf5u(xH^u@nJSe zV>I0*H4wgzt$ugUxch<(K4Io0;Yj(gS!)}naU4w!D)N1ulqTesSK3lNhO{lVbML{H z`y~I^g{da8g|d?Krn6e1x<0fa@M>oUx*~q9y!Yx;S7V;I>o;;aCY&*&M3?3LM?(fdDX($a6E0cNlUIa1=!zR4$5+eul4FTR-$3mi& zx{;Hg{6ePv+nYYq%bKn_?Go2lpSN;H*c4qn%g~dA1*tMh2DjztwRL$~7~mFk=k2>jqg*D7vQ(URf{%39y@)@^bdB(209SfD3-@%M__oE7RdQIy3A zSe@|2g|_*vw^`^Bh7ISXy-(=2{Ul3EMm05aNwjKh;Oc}->+D7-+mh@-e)JVvZiU-5 ztox~MyKMz#>CgEPl9j;9X3MatFLz@@wG6k_3bB(t{#e-3*wFGD;zUywO4~Xses_qg z-?)C3^2$8?`~#5lo&Z%K1#oxJvDN!c`ZFtbLC8+;L?C72dpCLhyv zN&&U@#BzBk+Lw~`qk!C>*q&mUpE}79*IjyFzsJD5tJ-+=JDIymwd#$5Qg4K~|J_KsP|h};xb`9z7^tYwEp{%tCR2&pNt(#^yO7)!|{|9;b-@pI> literal 0 HcmV?d00001 diff --git a/README.md b/README.md index 74a2ab8..0f4eed4 100644 --- a/README.md +++ b/README.md @@ -182,6 +182,7 @@ https://pyqt5.com 社区是专门针对PyQt5学习和提升开设的博客网站 - [人脸特征点](Demo/FacePoints.py) - [使用Threading](Demo/QtThreading.py) - [背景连线动画](Demo/CircleLine.py) + - [判断信号是否连接](Demo/IsSignalConnected.py) # QQ群