refactor(lib): change PyQT5 to PySide6 (#62)

* refactor(lib): change PyQT5 to PySide6

This, hopefully, should now add support for M1 chips

* chore: update README and change imports
This commit is contained in:
Jérome Eertmans
2022-10-31 14:55:03 +01:00
committed by GitHub
parent 8f519ed134
commit 3eb9fa0b74
5 changed files with 19 additions and 22 deletions

View File

@ -26,8 +26,6 @@ Tool for live presentations using either [Manim (community edition)](https://www
While installing Manim Slides and its dependencies on your global Python is fine, I recommend using a [virtualenv](https://docs.python.org/3/tutorial/venv.html) for a local installation. While installing Manim Slides and its dependencies on your global Python is fine, I recommend using a [virtualenv](https://docs.python.org/3/tutorial/venv.html) for a local installation.
> **_NOTE:_** Startin with version 4.2, Manim Slides seems to have **troubles installing on mac M1 chips**. An issue has been created [#53](https://github.com/jeertmans/manim-slides/issues/53), and we recommend following its evolution for any update.
### Dependencies ### Dependencies
Manim Slides requires either Manim or ManimGL to be installed. Having both packages installed is fine too. Manim Slides requires either Manim or ManimGL to be installed. Having both packages installed is fine too.
@ -90,7 +88,7 @@ class Example(Slide):
self.play(dot.animate.move_to(ORIGIN)) self.play(dot.animate.move_to(ORIGIN))
self.pause() # Waits user to press continue to go to the next slide self.pause() # Waits user to press continue to go to the next slide
self.wait() # The presentation directly exits after last animation self.wait()
``` ```
You **must** end your `Slide` with a `self.play(...)` or a `self.wait(...)`. You **must** end your `Slide` with a `self.play(...)` or a `self.wait(...)`.

View File

@ -3,7 +3,7 @@ from enum import Enum
from typing import List, Optional, Set from typing import List, Optional, Set
from pydantic import BaseModel, root_validator, validator from pydantic import BaseModel, root_validator, validator
from PyQt5.QtCore import Qt from PySide6.QtCore import Qt
from .manim import logger from .manim import logger

View File

@ -9,10 +9,10 @@ import click
import cv2 import cv2
import numpy as np import numpy as np
from pydantic import ValidationError from pydantic import ValidationError
from PyQt5 import QtGui from PySide6 import QtGui
from PyQt5.QtCore import Qt, QThread, pyqtSignal, pyqtSlot from PySide6.QtCore import Qt, QThread, Signal, Slot
from PyQt5.QtGui import QPixmap from PySide6.QtGui import QPixmap
from PyQt5.QtWidgets import QApplication, QGridLayout, QLabel, QWidget from PySide6.QtWidgets import QApplication, QGridLayout, QLabel, QWidget
from tqdm import tqdm from tqdm import tqdm
from .commons import config_path_option, verbosity_option from .commons import config_path_option, verbosity_option
@ -282,9 +282,9 @@ class Presentation:
class Display(QThread): class Display(QThread):
"""Displays one or more presentations one after each other.""" """Displays one or more presentations one after each other."""
change_video_signal = pyqtSignal(np.ndarray) change_video_signal = Signal(np.ndarray)
change_info_signal = pyqtSignal(dict) change_info_signal = Signal(dict)
finished = pyqtSignal() finished = Signal()
def __init__( def __init__(
self, self,
@ -409,7 +409,7 @@ class Display(QThread):
} }
) )
@pyqtSlot(int) @Slot(int)
def set_key(self, key: int) -> None: def set_key(self, key: int) -> None:
"""Sets the next key to be handled.""" """Sets the next key to be handled."""
self.key = key self.key = key
@ -484,7 +484,7 @@ class Info(QWidget):
self.update_info({}) self.update_info({})
@pyqtSlot(dict) @Slot(dict)
def update_info(self, info: dict): def update_info(self, info: dict):
self.animationLabel.setText("Animation: {}".format(info.get("animation", "na"))) self.animationLabel.setText("Animation: {}".format(info.get("animation", "na")))
self.stateLabel.setText("State: {}".format(info.get("state", "unknown"))) self.stateLabel.setText("State: {}".format(info.get("state", "unknown")))
@ -517,7 +517,7 @@ class InfoThread(QThread):
class App(QWidget): class App(QWidget):
send_key_signal = pyqtSignal(int) send_key_signal = Signal(int)
def __init__( def __init__(
self, self,
@ -603,13 +603,13 @@ class App(QWidget):
self.closeAll() self.closeAll()
event.accept() event.accept()
@pyqtSlot(np.ndarray) @Slot(np.ndarray)
def update_image(self, cv_img: dict): def update_image(self, cv_img: dict):
"""Updates the image_label with a new opencv image""" """Updates the image_label with a new opencv image"""
self.pixmap = self.convert_cv_qt(cv_img) self.pixmap = self.convert_cv_qt(cv_img)
self.label.setPixmap(self.pixmap) self.label.setPixmap(self.pixmap)
@pyqtSlot(dict) @Slot(dict)
def update_info(self, info: dict): def update_info(self, info: dict):
"""Updates the image_label with a new opencv image""" """Updates the image_label with a new opencv image"""
pass pass

View File

@ -4,8 +4,8 @@ from functools import partial
from typing import Any from typing import Any
import click import click
from PyQt5.QtCore import Qt from PySide6.QtCore import Qt
from PyQt5.QtWidgets import ( from PySide6.QtWidgets import (
QApplication, QApplication,
QDialog, QDialog,
QDialogButtonBox, QDialogButtonBox,
@ -25,9 +25,8 @@ from .manim import logger
WINDOW_NAME: str = "Configuration Wizard" WINDOW_NAME: str = "Configuration Wizard"
keymap = {} keymap = {}
for key, value in vars(Qt).items(): for key in Qt.Key:
if isinstance(value, Qt.Key): keymap[key.value] = key.name.partition("_")[2]
keymap[value] = key.partition("_")[2]
class KeyInput(QDialog): class KeyInput(QDialog):

View File

@ -39,7 +39,7 @@ setuptools.setup(
"click-default-group>=1.2", "click-default-group>=1.2",
"numpy>=1.19.3", "numpy>=1.19.3",
"pydantic>=1.9.1", "pydantic>=1.9.1",
"pyqt5>=5.15", "pyside6>=6.4",
"opencv-python>=4.6", "opencv-python>=4.6",
"tqdm>=4.62.3", "tqdm>=4.62.3",
], ],