Adding many GIFs to PySide6 widget. (Or another implementation of chat with animated emotes)
Unsolved
Qt for Python
-
i'm working on creating a chat, like on a twitch, in my project using PySide6. Is it possible to make a chat widget with animated (and not only) emojis in messages?
There i'm using QTextEdit and insert's gifs as image
https://prnt.sc/21zzy8o (gifs is static)def print_mess(self, mess): self.console.setCurrentFont(self.font) self.console.setTextColor('#C0C0C0') self.console.insertPlainText(" " + mess.formated_time() + " ") for badge in mess.userbadges: if type(badge) != str: self.console.setCurrentFont(self.font) self.cursor.insertImage(badge) self.console.insertPlainText(" ") self.console.setCurrentFont(self.font) self.console.setTextColor(mess.usercolor) self.console.insertPlainText(mess.username) if not mess.isaction: self.console.setCurrentFont(self.font) self.console.setTextColor('#FFFFFF') self.console.insertPlainText(":") for fragment in mess.msg: self.console.setCurrentFont(self.font) if type(fragment) == str: self.console.insertPlainText(f" {fragment}") else: self.console.insertPlainText(" ") self.cursor.insertImage(fragment) self.console.insertPlainText(" ") self.console.insertPlainText('\n') sb = self.console.verticalScrollBar() sb.setValue(sb.maximum())
-
You need a
QMovie
:import sys from PySide6.QtGui import QMovie from PySide6.QtWidgets import QApplication, QLabel app = QApplication() label = QLabel("hello") movie = QMovie("test.gif") print(movie.isValid()) label.setMovie(movie) movie.start() label.show() sys.exit(app.exec())
it's important to not forget the
.start()
-
@CristianMaureira Thanks for the answer, dude, but I already know about QMovie, is it really possible to do a lot of gifs (20-30) with this in one window?