From fb61005fe4f2daff07a280efdea18d131d183fbb Mon Sep 17 00:00:00 2001 From: Darius Berghe Date: Thu, 31 Oct 2024 10:49:25 +0200 Subject: [PATCH] float -> int where needed --- game-of-life.py | 4 ++-- universeview.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/game-of-life.py b/game-of-life.py index 7940021..742c752 100644 --- a/game-of-life.py +++ b/game-of-life.py @@ -1,6 +1,6 @@ import sys from PyQt5.QtWidgets import QApplication, QMainWindow -from PyQt5.QtCore import Qt +from PyQt5.QtCore import Qt, QSize import design from random import randint @@ -13,7 +13,7 @@ def __init__(self, screen_width, screen_height, c1, c2): self.ui.setupUi(self) # resize the main window to a sensible value - self.resize(screen_width / 2, screen_height / 2) + self.resize(QSize(int(screen_width / 2), int(screen_height / 2))) # resize the graphics scene to match the window uv = self.ui.graphicsView diff --git a/universeview.py b/universeview.py index c434c30..6fd96f5 100644 --- a/universeview.py +++ b/universeview.py @@ -43,7 +43,7 @@ def seed(self, state): self.universe.seed(state) def start(self): - self._timer.start(constants.DefaultAtomicTick * 1000) + self._timer.start(int(constants.DefaultAtomicTick * 1000)) self.frame_timestamps = [] self.start_t = perf_counter() @@ -189,7 +189,7 @@ def keyPressEvent(self, QKeyEvent): if self._timer.isActive(): self.stop() else: - self._timer.start(self._timerTickPeriod * 1000) + self._timer.start(int(self._timerTickPeriod * 1000)) elif QKeyEvent.key() == Qt.Key_S: self._showStatus = not self._showStatus @@ -211,11 +211,11 @@ def keyPressEvent(self, QKeyEvent): elif QKeyEvent.key() == Qt.Key_Minus: self._timerTickPeriod *= 1.05 - self._timer.setInterval(self._timerTickPeriod * 1000) + self._timer.setInterval(int(self._timerTickPeriod * 1000)) elif QKeyEvent.key() == Qt.Key_Plus: self._timerTickPeriod /= 1.05 - self._timer.setInterval(self._timerTickPeriod * 1000) + self._timer.setInterval(int(self._timerTickPeriod * 1000)) self.reDraw() QGraphicsView.keyPressEvent(self, QKeyEvent)