mirror of
https://github.com/pyapp-kit/superqt.git
synced 2025-12-15 18:50:05 +01:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user