Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Adding many GIFs to PySide6 widget. (Or another implementation of chat with animated emotes)
Qt 6.11 is out! See what's new in the release blog

Adding many GIFs to PySide6 widget. (Or another implementation of chat with animated emotes)

Scheduled Pinned Locked Moved Unsolved Qt for Python
pysidepythonqt for python
4 Posts 2 Posters 3.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KaiZER
    wrote on last edited by KaiZER
    #1

    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())
    
    1 Reply Last reply
    0
    • CristianMaureiraC Offline
      CristianMaureiraC Offline
      CristianMaureira
      wrote on last edited by
      #2

      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()

      K 1 Reply Last reply
      0
      • K Offline
        K Offline
        KaiZER
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • CristianMaureiraC CristianMaureira

          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()

          K Offline
          K Offline
          KaiZER
          wrote on last edited by
          #4

          @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?

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved