Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wxPython StaticText widget "flickering"

I'm trying to make a digital clock. One of the problems with it is that the display will "flicker". In other words the wx.StaticText widget (self.ST in this case), will go blank for very short periods. I believe the cause may find it's root in how self.ST updates (ie, SetLabel()). Is there a way to provide smoother transitions, in an effort to stop the flickering?

This is the function where self.ST is updated:

def tick (self):
    ''' Continually updates the time. '''

    TimeStr = '%I:%M %S %p'
    DateStr = '%A, %B %d, %Y'


    Time = time.strftime(TimeStr)
    Date = time.strftime(DateStr)

    self.TimeDate =  Time + '\t\t' + Date

    self.ST.SetLabel(Time)

    wx.CallLater(1000, self.tick)
like image 365
rectangletangle Avatar asked Nov 07 '25 06:11

rectangletangle


1 Answers

One way to fix the flickering is to enable double buffering in the top container for your widget. Normally this is done by calling self.SetDoubleBuffered(True) within the initialiser, for example within Panel container for your StaticText class.

like image 146
Oleksiy Avatar answered Nov 08 '25 20:11

Oleksiy