Skip to content

Commit

Permalink
Add docs/examples about how to use the Spin start/stop methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Dec 7, 2023
1 parent 025e59b commit 80bd2de
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 19 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,30 @@ drawn_image_button = QtWidgets.QPushButton(drawn_image_icon,
```python
# Spining icons
spin_button = QtWidgets.QPushButton(' Spinning icon')
spin_icon = qta.icon('fa5s.spinner', color='red',
animation=qta.Spin(spin_button))
animation = qta.Spin(spin_button)
spin_icon = qta.icon('fa5s.spinner', color='red', animation=animation)
spin_button.setIcon(spin_icon)

# Stop the animation when needed
animation.stop()
```

- Display Icon as a widget

```python
# Spining icon widget
spin_widget = qta.IconWidget()
spin_icon = qta.icon('mdi.loading', color='red',
animation=qta.Spin(spin_widget))
animation = qta.Spin(spin_widget, autostart=False)
spin_icon = qta.icon('mdi.loading', color='red', animation=animation)
spin_widget.setIcon(spin_icon)

# Simple icon widget
simple_widget = qta.IconWidget('mdi.web', color='blue',
size=QtCore.QSize(16, 16))

# Start and stop the animation when needed
animation.start()
animation.stop()
```

- Screenshot
Expand Down
38 changes: 26 additions & 12 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -172,28 +172,39 @@ Examples

.. code:: python
# Spin icons
# -- Spin icons
spin_button = QtWidgets.QPushButton(' Spinning icon')
spin_icon = qta.icon('fa5s.spinner', color='red',
animation=qta.Spin(spin_button))
animation = qta.Spin(spin_button)
spin_icon = qta.icon('fa5s.spinner', color='red', animation=animation)
spin_button.setIcon(spin_icon)
# Pulse icons
# Stop animation when needed
animation.stop()
# -- Pulse icons
pulse_button = QtWidgets.QPushButton(' Pulsing icon')
pulse_icon = qta.icon('fa5s.spinner', color='green',
animation=qta.Pulse(pulse_button))
animation = qta.Pulse(pulse_button, autostart=False)
pulse_icon = qta.icon('fa5s.spinner', color='green', animation=animation)
pulse_button.setIcon(pulse_icon)
# Stacked spin icons
# Start and stop the animation when needed
animation.start()
animation.stop()
# -- Stacked spin icons
stack_spin_button = QtWidgets.QPushButton('Stack spin')
animation = qta.Spin(stack_spin_button)
options = [{'scale_factor': 0.4,
'animation': qta.Spin(stack_spin_button)},
'animation': animation},
{'color': 'blue'}]
stack_spin_icon = qta.icon('ei.asl', 'fa5.square',
options=options)
stack_spin_button.setIcon(stack_spin_icon)
stack_spin_button.setIconSize(QtCore.QSize(32, 32))
# Stop animation when needed
animation.stop()
- Apply font label rendering:

.. code:: python
Expand All @@ -206,13 +217,16 @@ Examples

.. code:: python
# Spinning icon widget
# -- Spinning icon widget
spin_widget = qta.IconWidget()
spin_icon = qta.icon('mdi.loading', color='red',
animation=qta.Spin(spin_widget))
animation = qta.Spin(spin_widget)
spin_icon = qta.icon('mdi.loading', color='red', animation=animation)
spin_widget.setIcon(spin_icon)
# simple widget
# Stop animation when needed
animation.stop()
# -- Simple widget
simple_widget = qta.IconWidget('mdi.web', color='blue',
size=QtCore.QSize(16, 16))
Expand Down
15 changes: 12 additions & 3 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,25 @@ def __init__(self):

# Spin icons
spin_button = QtWidgets.QPushButton(' Spinning icon')
spin_icon = qta.icon('fa5s.spinner', color='red',
animation=qta.Spin(spin_button))
animation1 = qta.Spin(spin_button)
spin_icon = qta.icon('fa5s.spinner', color='red', animation=animation1)
spin_button.setIcon(spin_icon)

timer1 = QtCore.QTimer()
timer1.singleShot(3000, animation1.stop)

# Pulse icons
pulse_button = QtWidgets.QPushButton(' Pulsing icon')
animation2 = qta.Pulse(pulse_button, autostart=False)
pulse_icon = qta.icon('fa5s.spinner', color='green',
animation=qta.Pulse(pulse_button))
animation=animation2)
pulse_button.setIcon(pulse_icon)

timer2 = QtCore.QTimer()
timer2.singleShot(1500, animation2.start)
timer3 = QtCore.QTimer()
timer3.singleShot(6000, animation2.stop)

# Stacked spin icons
stack_spin_button = QtWidgets.QPushButton('Stack spin')
options = [{'scale_factor': 0.4,
Expand Down

0 comments on commit 80bd2de

Please sign in to comment.