擅长:python、mysql、java
<p>我找到了一个可行的解决方案,但它可能不是最有效的:我断开所有单个信号,然后在设置所有策略后重新连接。在</p>
<pre><code>def _onKeepAspectRatioChanged(self, isKeepAspectRatio, row, col):
with self._disconnectAllAspectRatioSignals():
for r, c in self._plots:
self._plots[(r, c)].plot.setKeepDataAspectRatio(isKeepAspectRatio)
@contextlib.contextmanager
def _disconnectAllAspectRatioSignals(self):
for r, c in self._plots:
self._plots[(r, c)].sigKeepAspectRatioChanged.disconnect(
self._onKeepAspectRatioChanged)
yield
for r, c in self._plots:
self._plots[(r, c)].sigKeepAspectRatioChanged.connect(
self._onKeepAspectRatioChanged)
</code></pre>