Add signal to QCollapsible (#142)

* add signal when toggle button is clicked

* emit signal when expand/collapse are called. emit bool. add to test.

* fix signal emission

Co-authored-by: Talley Lambert <talley.lambert@gmail.com>
This commit is contained in:
Pam
2022-11-27 19:43:05 -06:00
committed by GitHub
parent e98936e8d8
commit 3df7f49706
2 changed files with 29 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
"""A test module for testing collapsible"""
from qtpy.QtCore import QEasingCurve
from qtpy.QtCore import QEasingCurve, Qt
from qtpy.QtWidgets import QPushButton
from superqt import QCollapsible
@@ -85,3 +85,16 @@ def test_changing_text(qtbot):
wdg.setText("Hi new text")
assert wdg.text() == "Hi new text"
assert wdg._toggle_btn.text() == QCollapsible._COLLAPSED + "Hi new text"
def test_toggle_signal(qtbot):
"""Test that signal is emitted when widget expanded/collapsed."""
wdg = QCollapsible()
with qtbot.waitSignal(wdg.toggled, timeout=500):
qtbot.mouseClick(wdg._toggle_btn, Qt.LeftButton)
with qtbot.waitSignal(wdg.toggled, timeout=500):
wdg.expand()
with qtbot.waitSignal(wdg.toggled, timeout=500):
wdg.collapse()