SoFunction
Updated on 2024-11-19

python+pyqt implementation of the bottom-right popup box

In this article, we share the example of pyqt to achieve the specific code of the bottom-right corner pop-up box for your reference, the details are as follows

in the constructor:

=QDesktopWidget() 
((().width()-()),().height()) # Initialize position to lower right corner
() 
# Pop-up animation
def showAnimation(self): 
  # Show popup box animation
  =QPropertyAnimation(self,"pos") 
  (1000) 
  (QPoint((),())) 
  (QPoint((().width()-()),(().height()-()+self.SHADOW_WIDTH))) 
  () 
 
  #Set the popup box to pop up in 1 second and then fade out
  =QTimer() 
  (,SIGNAL("timeout()"),self,SLOT("closeAnimation()")) 
  (10000) # Timer 10 seconds
#Close animation
@pyqtSlot() 
def closeAnimation(self): 
  # Clear Timer and Signal Slots
  () 
  (,SIGNAL("timeout()"),self,SLOT("closeAnimation()")) 
  () 
  =None 
  #Popup box fading
   =QPropertyAnimation(self,"windowOpacity") 
  (1000) 
  (1) 
  (0) 
  () 
  #Clean up after animation is complete
  (,SIGNAL("finished()"),self,SLOT("clearAll()")) 
 
#Cleanup and exit
@pyqtSlot() 
def clearAll(self): 
  (,SIGNAL("finished()"),self,SLOT("clearAll()")) 
  ()    #abort 

Or just: (,SIGNAL("finished()"),self,SLOT("close()"))

The effect is as follows:

This is the whole content of this article.