Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6821999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:36:40+00:00 2026-05-26T21:36:40+00:00

I have a program (time lapse maker) which has two threads that updates a

  • 0

I have a program (time lapse maker) which has two threads that updates a wx.StaticBitmap. When the two threads access the wx.StaticBitmap it crashes with the error

python: xcb_io.c:221: poll_for_event: Assertion `(((long)
(event_sequence) – (long) (dpy->request)) <= 0)’ failed.

I tried a Google search for the answer and I tried to solve it myself but I still can’t figure it out.

Simple piece of code that reproduces this error (this is not the actual program):

#!/usr/bin/env python

import wx
import time,os.path,glob,threading

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):

        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.bitmap_1 = wx.StaticBitmap(self, -1, wx.NullBitmap)

        self.__set_properties()
        self.__do_layout()

        wx.CallAfter(self._img)
    def __set_properties(self):

        self.SetTitle("frame_1")


    def __do_layout(self):

        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_1.Add(self.bitmap_1, 0, 0, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()



    def _img(self):
             Thread1= threading.Thread(target=self._img1)
             Thread1.start()
             Thread2 = threading.Thread(target=self._img2)
             Thread2.start()

    def _img1(self):
            frames = glob.glob("/path/to/pngs/*.png")
        frames.sort()
        for i in range(len(frames)):
            if os.path.isfile(frames[i]) and i%2 == 0:
                print frames[i]
                wx.Yield()
                ##time.sleep(0.5)
                wx.CallAfter(self.bitmap_1.SetBitmap,wx.Bitmap(frames[i], wx.BITMAP_TYPE_ANY))
                wx.CallAfter(self.Update)
    def _img2(self):
            frames = glob.glob("/path/to/pngs/*.png")
        frames.sort()
        for i in range(len(frames)):
            if os.path.isfile(frames[i]) and i%2 == 1:
                print frames[i]
                wx.Yield()
                ##time.sleep(0.5)
                wx.CallAfter(self.bitmap_1.SetBitmap,wx.Bitmap(frames[i], wx.BITMAP_TYPE_ANY))
                wx.CallAfter(self.Update)

if __name__ == "__main__":
    app = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    app.SetTopWindow(frame_1)
    frame_1.Show()
    app.MainLoop()

I solved it with wx.PostEvent See my answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:36:41+00:00Added an answer on May 26, 2026 at 9:36 pm

    I solved it with wx.PostEvent:

    #!/usr/bin/env python
    # -*- coding: utf-8 -*-
    # generated by wxGlade 0.6.3 on Mon Oct 17 19:59:55 2011
    
    import wx
    import time,os.path,glob,threading
    # begin wxGlade: extracode
    # end wxGlade
    
    
    ID_START = wx.NewId()
    ID_STOP = wx.NewId()
    
    # Define notification event for thread completion
    EVT_RESULT_ID = wx.NewId()
    
    def EVT_RESULT(win, func):
        """Define Result Event."""
        win.Connect(-1, -1, EVT_RESULT_ID, func)
    
    class ResultEvent(wx.PyEvent):
        """Simple event to carry arbitrary result data."""
        def __init__(self, data):
            """Init Result Event."""
            wx.PyEvent.__init__(self)
            self.SetEventType(EVT_RESULT_ID)
            self.data = data
    class MyFrame(wx.Frame):
        def __init__(self, *args, **kwds):
            # begin wxGlade: MyFrame.__init__
            kwds["style"] = wx.DEFAULT_FRAME_STYLE
            wx.Frame.__init__(self, *args, **kwds)
            self.bitmap_1 = wx.StaticBitmap(self, -1, wx.NullBitmap)
            self.__set_properties()
            self.__do_layout()
            # end wxGlade
        self.frames = ""
        EVT_RESULT(self,self.OnResult)
            wx.CallAfter(self._img)
        def __set_properties(self):
            # begin wxGlade: MyFrame.__set_properties
            self.SetTitle("frame_1")
            # end wxGlade
    
        def __do_layout(self):
            # begin wxGlade: MyFrame.__do_layout
            sizer_1 = wx.BoxSizer(wx.VERTICAL)
            sizer_1.Add(self.bitmap_1, 0, 0, 0)
            self.SetSizer(sizer_1)
            sizer_1.Fit(self)
            self.Layout()
            # end wxGlade
        def OnResult(self, event):
            """Show Result status."""
            if event.data is None:
                pass
            else:
            self.bitmap_1.SetBitmap(wx.Bitmap(event.data, wx.BITMAP_TYPE_ANY))
    # end of class MyFrame
        def _img(self):
                 Thread1= threading.Thread(target=self._img1)
                 Thread1.start()
                 Thread2 = threading.Thread(target=self._img2)
                 Thread2.start()
    
        def _img1(self):
                frames = glob.glob("/home/mitch/Pictures/*.png")
            frames.sort()
    
            for i in range(len(frames)):
                if os.path.isfile(frames[i]) and i%2 == 0:
                    print frames[i]
                    ##wx.Yield()
                    ##time.sleep(0.5)
                    wx.PostEvent(self, ResultEvent(frames[i]))
    
        def _img2(self):
                frames = glob.glob("/home/mitch/Pictures/*.png")
            frames.sort()
    
            for i in range(len(frames)):
                if os.path.isfile(frames[i]) and i%2 == 1:
                    print frames[i]
                    ##wx.Yield()
                    ##time.sleep(0.5)
                    wx.PostEvent(self, ResultEvent(frames[i]))
    
    if __name__ == "__main__":
        app = wx.PySimpleApp(0)
        wx.InitAllImageHandlers()
        frame_1 = MyFrame(None, -1, "")
        app.SetTopWindow(frame_1)
        frame_1.Show()
        app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that is throwing a run-time error dialog. Is there a
I have a program which simulates a physical system that changes over time. I
I have program that constantly query a mysql server. Each time I access the
I have a program that uses threads to perform time-consuming processes sequentially. I want
I have a program that receives real time data on 1000 topics. It receives
I have a program which takes a long time to complete. I would like
I have a program, that takes a long time to load. Because of this,
I have a benchmarking program that calculates the time (in milliseconds and ticks), for
I have a clock feature in a VB.NET program that displays the time including
I have program that has a variable that should never change. However, somehow, it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.