Skip to content

Commit

Permalink
Merge pull request #4 from andreasgriffin/bug_fix_timer
Browse files Browse the repository at this point in the history
Bug Fix QTimer
  • Loading branch information
andreasgriffin authored Jun 30, 2024
2 parents f5291bd + 8c407f3 commit 978c30e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions bitcoin_qr_tools/qr_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@

from PIL import Image
from PyQt6.QtCore import QByteArray, QEvent, QRectF, QSize, Qt, QTimer
from PyQt6.QtGui import QImage, QKeyEvent, QMouseEvent, QPainter, QPaintEvent, QPixmap
from PyQt6.QtGui import (
QCloseEvent,
QImage,
QKeyEvent,
QMouseEvent,
QPainter,
QPaintEvent,
QPixmap,
)
from PyQt6.QtSvg import QSvgRenderer
from PyQt6.QtWidgets import QApplication, QDialog, QWidget

Expand Down Expand Up @@ -121,6 +129,11 @@ def enlarge_image(self):
def mousePressEvent(self, event: QMouseEvent):
self.enlarge_image()

def closeEvent(self, event: QCloseEvent) -> None:
if self.enlarged_image:
self.enlarged_image.close()
super().closeEvent(event)


class EnlargedImage(ImageWidget):
def __init__(self, pil_image: Image, parent=None, screen_fraction=0.4):
Expand Down Expand Up @@ -191,7 +204,7 @@ def __init__(self, always_animate=False, clickable=True, parent=None):
if clickable:
self.setCursor(Qt.CursorShape.PointingHandCursor)

self.timer = QTimer(self)
self.timer = QTimer()
self.timer.timeout.connect(self.next_svg)

def sizeHint(self) -> QSize:
Expand Down Expand Up @@ -346,6 +359,11 @@ def as_pil_images(self):
if renderer.isValid()
]

def closeEvent(self, event: QCloseEvent) -> None:
self.timer.stop()
self.enlarged_image.close()
super().closeEvent(event)


class EnlargedSVG(QDialog):
def __init__(self, svg_renderer: QSvgRenderer, parent=None, screen_fraction=0.5):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ disable_error_code = "assignment"

[tool.poetry]
name = "bitcoin-qr-tools"
version = "0.10.2"
version = "0.10.3"
authors = ["andreasgriffin <[email protected]>"]
license = "GPL-3.0"
readme = "README.md"
Expand Down

0 comments on commit 978c30e

Please sign in to comment.