From 68f2b020a79aca8d287cb67f8e2ae4f319921f97 Mon Sep 17 00:00:00 2001 From: "jitender.singh" Date: Mon, 12 Jul 2021 21:17:26 +0530 Subject: [PATCH] #97 - using spin icon internal to stop the timer. --- ui/customwidgets/pushbutton.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/customwidgets/pushbutton.py b/ui/customwidgets/pushbutton.py index b06d3a5..602e645 100644 --- a/ui/customwidgets/pushbutton.py +++ b/ui/customwidgets/pushbutton.py @@ -7,6 +7,7 @@ class CustomPushButton(QPushButton): def __init__(self): super().__init__() + self.spin_icon = None pass def changeEvent(self, event: QEvent) -> None: @@ -26,11 +27,12 @@ def apply_current_palette(self, animate=False): text_color = QApplication.palette().color(QPalette.Text) if animate: + self.spin_icon = qta.Spin(self, interval=100, step=2) qicon = qta.icon( self.objectName(), color=text_color, color_active=highlight_color, - animation=qta.Spin(self, interval=100, step=2) + animation=self.spin_icon, ) else: qicon = qta.icon( @@ -38,4 +40,9 @@ def apply_current_palette(self, animate=False): color=text_color, color_active=highlight_color, ) + if self.spin_icon: + # hacky-ish way to stop the spin icon from updating + # till the issue is fixed. https://github.com/spyder-ide/qtawesome/issues/165 + self.spin_icon.info[self][0].stop() + self.spin_icon = None super().setIcon(qicon)