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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:03:31+00:00 2026-05-15T17:03:31+00:00

I have the following python modules. Sorry if the code is ugly. This is

  • 0

I have the following python modules. Sorry if the code is ugly. This is my first python GUI app and I’m fairly new to python as well. It’s some sort of a count down timer with a todo list. It works kinda well except that after two minutes after running the program, it crashes with the following error:

Pango:ERROR:/build/buildd/pango1.0-1.28.0/pango/pango-layout.c:3739:pango_layout_check_lines: assertion failed: (!layout->log_attrs)

I have absolutely no idea what that even means. One I’m confused about is that it works after the first minute, ie. the timer label counts down ok but on the next minute, it crashes immediately.

After googling a bit, I think the issue might be related to multithreading? Any ideas?

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Fri Jul  9 17:00:08 2010

import wx
import settimer

# begin wxGlade: extracode
# end wxGlade

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.todo1 = wx.TextCtrl(self, -1, "")
        self.timer_label1 = wx.StaticText(self, -1, "00:00")
        self.set_timer1 = wx.Button(self, -1, "Set Timer")
        self.todo2 = wx.TextCtrl(self, -1, "")
        self.timer_label2 = wx.StaticText(self, -1, "00:00")
        self.set_timer2 = wx.Button(self, -1, "Set Timer")
        self.todo3 = wx.TextCtrl(self, -1, "")
        self.timer_label3 = wx.StaticText(self, -1, "00:00")
        self.set_timer3 = wx.Button(self, -1, "Set Timer")
        self.todo4 = wx.TextCtrl(self, -1, "")
        self.timer_label4 = wx.StaticText(self, -1, "00:00")
        self.set_timer4 = wx.Button(self, -1, "Set Timer")
        self.todo5 = wx.TextCtrl(self, -1, "")
        self.timer_label5 = wx.StaticText(self, -1, "00:00")
        self.set_timer5 = wx.Button(self, -1, "Set Timer")
        self.hours = 0
        self.minutes = 0

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.on_set1, self.set_timer1)
        self.Bind(wx.EVT_BUTTON, self.on_set2, self.set_timer2)
        self.Bind(wx.EVT_BUTTON, self.on_set3, self.set_timer3)
        self.Bind(wx.EVT_BUTTON, self.on_set4, self.set_timer4)
        self.Bind(wx.EVT_BUTTON, self.on_set5, self.set_timer5)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("Track Work")
        self.todo1.SetMinSize((300, 25))
        self.timer_label1.SetMinSize((100, 30))
        self.timer_label1.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.set_timer1.SetMinSize((85, 27))
        self.todo2.SetMinSize((300, 25))
        self.timer_label2.SetMinSize((100, 30))
        self.timer_label2.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.set_timer2.SetMinSize((85, 27))
        self.todo3.SetMinSize((300, 25))
        self.timer_label3.SetMinSize((100, 30))
        self.timer_label3.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.set_timer3.SetMinSize((85, 27))
        self.todo4.SetMinSize((300, 25))
        self.timer_label4.SetMinSize((100, 30))
        self.timer_label4.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.set_timer4.SetMinSize((85, 27))
        self.todo5.SetMinSize((300, 25))
        self.timer_label5.SetMinSize((100, 30))
        self.timer_label5.SetFont(wx.Font(15, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.set_timer5.SetMinSize((85, 27))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        flex_sizer = wx.FlexGridSizer(5, 3, 2, 25)
        flex_sizer.Add(self.todo1, 0, 0, 0)
        flex_sizer.Add(self.timer_label1, 0, 0, 0)
        flex_sizer.Add(self.set_timer1, 0, 0, 0)
        flex_sizer.Add(self.todo2, 0, 0, 0)
        flex_sizer.Add(self.timer_label2, 0, 0, 0)
        flex_sizer.Add(self.set_timer2, 0, 0, 0)
        flex_sizer.Add(self.todo3, 0, 0, 0)
        flex_sizer.Add(self.timer_label3, 0, 0, 0)
        flex_sizer.Add(self.set_timer3, 0, 0, 0)
        flex_sizer.Add(self.todo4, 0, 0, 0)
        flex_sizer.Add(self.timer_label4, 0, 0, 0)
        flex_sizer.Add(self.set_timer4, 0, 0, 0)
        flex_sizer.Add(self.todo5, 0, 0, 0)
        flex_sizer.Add(self.timer_label5, 0, 0, 0)
        flex_sizer.Add(self.set_timer5, 0, 0, 0)
        self.SetSizer(flex_sizer)
        flex_sizer.Fit(self)
        self.Layout()
        # end wxGlade
    def on_set1(self, event): # wxGlade: MyFrame.<event_handler>
        app = wx.PySimpleApp(0)
        wx.InitAllImageHandlers()
        MyTimer = settimer.Timer(None, -1, "")
        MyTimer.get_out_instance(self)
        app.SetTopWindow(MyTimer)
        MyTimer.Show()
        app.MainLoop()
        event.Skip()

    def set_label(self):
        self.timer_label1.SetLabel("%02d:%02d" % (self.hours, self.minutes))
        self.minutes -= 1

# end of class MyFrame

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

timer.py

import threading
import time

class Timer(threading.Thread):
    def __init__(self, seconds, track):
        threading.Thread.__init__(self)
        self.total_time = seconds
        self.track = track

    def run(self):
        for sec in range(self.total_time):
            time.sleep(60)
            self.track.set_label()

settimer.py

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Fri Jul  9 16:49:11 2010

import wx
import timer

# begin wxGlade: extracode
# end wxGlade



class Timer(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: Timer.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.hours_text = wx.TextCtrl(self, -1, "")
        self.hours = wx.StaticText(self, -1, "HH")
        self.minutes_text = wx.TextCtrl(self, -1, "")
        self.minutes = wx.StaticText(self, -1, "MM")
        self.set = wx.Button(self, -1, "Set")
        self.out_instance = None
        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.on_set, self.set)
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: Timer.__set_properties
        self.SetTitle("Set Timer")
        self.hours_text.SetMinSize((40, 25))
        self.hours.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.minutes_text.SetMinSize((40, 25))
        self.minutes.SetFont(wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.BOLD, 0, ""))
        self.set.SetMinSize((50, 27))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: Timer.__do_layout
        flex_sizer = wx.FlexGridSizer(1, 5, 0, 4)
        flex_sizer.Add(self.hours_text, 0, 0, 0)
        flex_sizer.Add(self.hours, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        flex_sizer.Add(self.minutes_text, 0, 0, 0)
        flex_sizer.Add(self.minutes, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        flex_sizer.Add(self.set, 0, wx.ALIGN_CENTER_VERTICAL, 0)
        self.SetSizer(flex_sizer)
        flex_sizer.Fit(self)
        flex_sizer.AddGrowableRow(1)
        flex_sizer.AddGrowableCol(3)
        self.Layout()
        # end wxGlade

    def get_out_instance(self, out):
        # get the instance of trackwork 
        # this method is meant to be called outside this class
        self.out_instance = out

    def on_set(self, event): # wxGlade: Timer.<event_handler>
        self.out_instance.hours = int(self.hours_text.GetValue())
        self.out_instance.minutes = int(self.minutes_text.GetValue())
        self.out_instance.set_label()
        t = timer.Timer(self.out_instance.minutes, self.out_instance)
        t.start()
        self.Destroy()
        event.Skip()

# end of class Timer
  • 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-15T17:03:32+00:00Added an answer on May 15, 2026 at 5:03 pm

    You should have used wx.Timer instead of starting a thread that will be most of the time waiting.

    wx.Timer will call your code in the specified interval.

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

Sidebar

Related Questions

I am using python 2.7, I have some code that looks like this: task1()
I have the following python script which takes some inputs and puts them in
I have the following Python code: cursor.execute("INSERT INTO table VALUES var1, var2, var3,") where
I have the following code in python from selenium import webdriver from selenium.webdriver.common.by import
I'm new to Python and I'm starting a mini Project, but I have some
I have a following structure of python modules: /foo.py /module /module/__init__.py /module/submodule/__init__.py /module/submodule/bar.py in
I have the following Python 2.6 program and YAML definition (using PyYAML ): import
I have the following simple python test script that uses Suds to call a
I would like to have the following syntax: python utility.py file1 FILE1 file2 FILE2
I have the following array(in python): arr= ['\n', ' a#B\n', ' c#D\n'] Now I

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.