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 9134587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:41:20+00:00 2026-06-17T08:41:20+00:00

In this program I get an error when I use a while True loop

  • 0

In this program I get an error when I use a while True loop in the thread. Without the loop I get no error. Of course in the real program I don’t update a label continuously. Any idea what I’m doing wrong?

This is the program:

import wx
import thread

class Example(wx.Frame):

    def __init__(self, parent): 
        wx.Frame.__init__(self,parent)
        self.InitUI()

    def InitUI(self):
        self.SetSize((250, 200))
        self.Show(True)

        self.text = wx.StaticText(self, label='',pos=(20,30))

        thread.start_new_thread(self.watch,(self,None))

    def watch(self,dummy,e):
        while True:
            self.text.SetLabel('Closed')


def main():
    ex = wx.App()
    Example(None)
    ex.MainLoop()    

if __name__ == '__main__':
    main() 

And this is the error:

Pango:ERROR:/build/pango1.0-LVHqeM/pango1.0-1.30.0/./pango/pango-            layout.c:3801:pango_layout_check_lines: assertion failed: (!layout->log_attrs) Aborted

Any suggestions as to what I’m doing wrong? I’m (obviously) new to threading.

  • 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-06-17T08:41:21+00:00Added an answer on June 17, 2026 at 8:41 am

    I am not exactly sure if that is what causes you problem, but… You should not interact with the GUI from another thread. You should use wx.CallAfter(). I would consider adding sleep inside the loop also.

    wx.CallAfter() documentation says:

    Call the specified function after the current and pending event handlers have been completed. This is also good for making GUI method calls from non-GUI threads. Any extra positional or keyword args are passed on to the callable when it is called.

    Updated code would than be:

    import wx
    import thread
    import time
    
    class Example(wx.Frame):
        def __init__(self, parent): 
            wx.Frame.__init__(self,parent)
            self.InitUI()
    
        def InitUI(self):
            self.SetSize((250, 200))
            self.Show(True)
    
            self.text = wx.StaticText(self, label='',pos=(20,30))
    
            thread.start_new_thread(self.watch,(self,None))
    
        def watch(self,dummy,e):
            while True:
                time.sleep(0.1)
                wx.CallAfter(self.text.SetLabel, 'Closed')
    
    def main():
        ex = wx.App()
        Example(None)
        ex.MainLoop()    
    
    if __name__ == '__main__':
        main() 
    

    Maybe you can also consider using wx.Timer.

    BTW: Your code runs OK on my PC with Windows 7 and wxPython 2.8.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my code below. The program runs fine. I don't get any exceptions.
This program is to use the keyboard keys to play notes. I get a
i'm trying to get this program to break down a user defined amount of
I'm trying to get this simple program to work on windows, but it crashes:
I got a C# program which opens a EventWaitHandle like this to get triggered
I have written a program that uses qhttp to get a webpage. This works
This program I use has it's own variables to set when you run it,
1>Project : error PRJ0003 : Error spawning 'rc.exe'.. this is the error i get
I'm having trouble with conversion. I cannot use strings in this program so I
i'm trying to use boost regex within my program the problem is i get

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.