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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:20:26+00:00 2026-06-04T15:20:26+00:00

im writing a web crawler, using wxpython to display the real-time result. Assuming that

  • 0

im writing a web crawler, using wxpython to display the real-time result. Assuming that there is only one button named crawl on the window. when i clicked the button, a new dialog will come out, and the TextCtrl on the new dialog will display the current url that is crawling.

The codes can be simplified as follows(just UI with WebCrawler thread on OnDisplayClick function):

# -*- coding: utf-8 -*- 

import wx
class Main ( wx.Frame ):

    def __init__( self, parent ):
        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )

        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )

        bSizer3 = wx.BoxSizer( wx.VERTICAL )

        self.Crawl = wx.Button( self, wx.ID_ANY, u"Crawl", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.Crawl.SetDefault() 
        bSizer3.Add( self.Crawl, 0, wx.ALL, 5 )

        self.SetSizer( bSizer3 )
        self.Layout()

        self.Centre( wx.BOTH )

        # Connect Events
        self.Crawl.Bind( wx.EVT_BUTTON, self.OnDisplayClick )

    def __del__( self ):
        pass


    # Virtual event handlers, overide them in your derived class
    def OnDisplayClick( self, event ):

            #Show the display window
        newDisplay = Display(self)
            newDisplay.show()

            ############################################################
            ##          start a multi-threading webcrawler            ##
            ############################################################

            web_crawler = WebCrawler(newDisplay.current_url)
            web_crawler.startCrawl()



class Display ( wx.Frame ):

    def __init__( self, parent ):
        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 500,300 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )

        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )

        bSizer4 = wx.BoxSizer( wx.VERTICAL )

        self.cur_url = wx.StaticText( self, wx.ID_ANY, u"Current_URL: ", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.cur_url.Wrap( -1 )
        bSizer4.Add( self.cur_url, 0, wx.ALL, 5 )

        self.current_url = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer4.Add( self.current_url, 0, wx.ALL, 5 )

        self.SetSizer( bSizer4 )
        self.Layout()

        self.Centre( wx.BOTH )

    def __del__( self ):
        pass

UI:

Crawl
Display

WebCrawler is a multi-thread crawler, i pass the TextCtrl(current_url) to the WebCrawler to let it display the current crawling url on the display window, but when i click on the crawl button, the interface seems dead, i guess it is because the multi-threading WebCrawler is running and the UI thread cannot get the opportunity to display the new window. i tried to write another two threads using threading.Thread, one is used to display the new window, one to WebCrawler, but i failed, the app often exited immediately, though it can display the window and do with the crawl threadings for some seconds, and sometimes it told me something like:

(python2.7:5231): Pango-CRITICAL **: pango_layout_get_iter: assertion `PANGO_IS_LAYOUT (layout)' failed

(python2.7:5404): GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count > 0' failed

the two theads are as follows:

class UpdateThread(threading.Thread):

    """ WebCrawler thread """

    def __init__(self, webCrawl):
        threading.Thread.__init__(self)
        self.webCrawl = webCrawl

    def run(self):
        self.webCrawl.start()

class CrawlShowThread(threading.Thread):

    """ Display thread """
    def __init__(self, crawl_display):
        threading.Thread.__init__(self)
        self.crawl_display = crawl_display

    def run(self):
        self.crawl_display.Show()

then both start() at the OnCrawlClick() function. but just like what i have said above, the method doesnt work.

can anyone tell me what is the right way to do with such things? any help appreciated!

  • 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-04T15:20:28+00:00Added an answer on June 4, 2026 at 3:20 pm

    You aren’t allowed to access the GUI from a non-main thread. See the documentation wiki on this.

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

Sidebar

Related Questions

I am writing a web crawler that processes multiple URLs at the same time
I'm currently writing a web crawler (using the python framework scrapy ). Recently I
I'm writing a web-crawler that should be able to parse multiple pages at the
I am writing a web crawler for reddit which only allows 1 request every
I'm writing a simple web crawler in Ruby and I need to fetch all
I'm writing a multi-threaded Java web crawler. From what I understand of the web,
I am writing a crawler in Perl, which has to extract contents of web
I find that writing web apps and WinForm apps generally come out a lot
When writing a web application which allows the upload of files, one must be
I'm just getting started writing a simple web crawler to get info on links

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.