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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:27:52+00:00 2026-06-09T14:27:52+00:00

I am making a wxpython app that needs to have internet connection as a

  • 0

I am making a wxpython app that needs to have internet connection as a must . So , i need to check if connection is present , and if not , then do an exit . So my code looks like this .

class Example(wx.Frame):

    def __init__(self, parent, title):
        super(Example, self).__init__(parent, title=title, 
            size=(700,650))
        self.InitUI()
        self.Centre()

#*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.
#--------------------------------------------------------------------------------

        favicon = wx.Icon(ICON_PATH, wx.BITMAP_TYPE_ICO)
        wx.Frame.SetIcon(self, favicon)
        self.Show()     

    def InitUI(self):
        #checkConnection()
        checkInstances()

        panel = wx.Panel(self)

        font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
        font.SetPointSize(9)

        font1 = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
        font1.SetPointSize(10)

#Layout 

        vbox = wx.BoxSizer(wx.VERTICAL)

        hbox1 = wx.BoxSizer(wx.HORIZONTAL)
        st1 = wx.StaticText(panel, label='Select Slot :')
        st1.SetFont(font1)
        hbox1.Add(st1, flag=wx.ALL, border=8)

        try:
            handler = urllib.urlopen("http://%s/api/get-slots/?api_key=%s"%(BASE_DOMAIN, API_KEY))
        except:

            wx.MessageBox("Error communicating with the server.", 'WARNING',wx.OK |wx.ICON_INFORMATION)
            handler = None
            sys.exit(0)

So i want to check for that link above (some link) , and if it fails , i display a message box , and then I exit . When i run this (with internet off) , the app does shows the message , and after clicking OK , another traceback box opens with a print

SystemExit:0

It does not actually exit . Tried using self.Close also . That does’nt work too .
Thought of making a checkconnection function as soon as we run the app .

def checkConnection():

    try:
        test = urllib.urlopen("http://www.google.com")
    except:
        sys.exit(0)

Placed it at

 def InitUI(self):
        checkConnection()
        .........
        .........

This also did the same thing . So is there some way to avoid the printing
and ACTUALLY EXIT?

os._exit worked but I just thought that sys.exit should have worked too .
So any hints guys?

  • 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-09T14:27:53+00:00Added an answer on June 9, 2026 at 2:27 pm

    Instead of sys.exit (or os._exit) use

    self.Destroy()
    

    os._exit halts the process abruptly without calling any cleanup handlers and should generally not be used (except to halt child processes after a fork).

    sys.exit raises a SystemExit exception. wxpython must be catching this exception and choosing to print the error message without quitting the app.

    self.Destroy() should quit the app.


    try:
        test = urllib.urlopen("http://www.google.com")
    except IOError:
        wx.MessageBox("Error communicating with the server.")
        self.Destroy()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Making game of life I need to a have a grid that is 30x20
I'm making a wxpython app that I will compile with the various freezing utility
Making an adobe flex ui in which data that is calculated must use proprietary
I have a GUI application that needs to do something simple in the background
Making an Flex App. Just wondering if anyone has created something that fits automatically
I´m making an Android App with a Google Map. This app must alert you
I am making a wxPython app which supplies a shell for the user to
Im making a flash app that will capture video from the users web-cam, show
Making a link with javascript:void(0) violate the W3C standard. I need to have a
I am making a music player in python/wxpython. I have a listbox with all

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.