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

  • Home
  • SEARCH
  • 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 5840423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:44:35+00:00 2026-05-22T11:44:35+00:00

Platforms: Windows, OS X Python Version: Active State Python 2.7 wxPython Version: Version 2.9

  • 0

Platforms: Windows, OS X

Python Version: Active State Python 2.7

wxPython Version: Version 2.9

Here is a sample code in which I use a wxMessageBox:

import wx,os

class Frame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(100, 100),style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN)

        host=os.system('hostname')
        if host!='superman':            
            self.dialogBox=wx.MessageBox('The host name should be superman. Closing this dialog box in 2s...','Info')            
            self.Destroy()
        else:
            self.Center()
            self.Show()

if __name__ == '__main__':
    app = wx.App(redirect=False)
    frame = Frame(None, -1, 'Sample')
    app.MainLoop()

According to the above piece of code, If the host name is not ‘superman’ , then the user is displayed a message box and prompted to press ‘OK’. If the user presses ‘OK’ button on the message box, then the control moves to the next line in the code (i.e., line number 10) where the frame is destroyed. I want to be to able to automatically close the dialog box and go to the next line in the code i.e., self.Destroy() if the user does not press the ‘OK’ button in the next 2 seconds. Any thoughts on how do I do that in wxpython ?

  • 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-22T11:44:35+00:00Added an answer on May 22, 2026 at 11:44 am

    I think you might have to use a custom wx.Dialog for this. You can use wx.FutureCall to call trigger an event in the future. Something like:

    class MessageDialog(wx.Dialog):
        def __init__(self, message, title):
            wx.Dialog.__init__(self, None, -1, title,size=(300, 120))
            self.CenterOnScreen(wx.BOTH)
    
            ok = wx.Button(self, wx.ID_OK, "OK")
            ok.SetDefault()
            text = wx.StaticText(self, -1, message)
    
            vbox = wx.BoxSizer(wx.VERTICAL)
            vbox.Add(text, 1, wx.ALIGN_CENTER|wx.TOP, 10)
            vbox.Add(ok, 1, wx.ALIGN_CENTER|wx.BOTTOM, 10)
            self.SetSizer(vbox)
    
    class Frame(wx.Frame):
        def __init__(self, parent, id, title):
            wx.Frame.__init__(self, parent, id, title, size=(100, 100),style=wx.MINIMIZE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX | wx.CLIP_CHILDREN)
    
            host=os.system('hostname')
            if host!='superman':
                dlg = MessageDialog('The host name should be superman. Closing this dialog box in 2s...', 'Info')        
                wx.FutureCall(2000, dlg.Destroy)
                dlg.ShowModal()
            else:
                self.Center()
                self.Show()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using: Windows XP Python 2.6.2 (standard install from python.org) git version 1.6.5.1-preview20091022
i have installed lxml2.2.2 on windows platform(i m using python version 2.6.5).i tried this
What's the best way to maintain a multiple databases across several platforms (Windows, Linux,
Would this work on all platforms? i know windows does \r\n, and remember hearing
I'm using Windows CE Platform Builder and my code is written in C++ .
I'm writing cross platform C++ code (Windows, Mac). Is there a way to check
I'm writing some cross-platform code between Windows and Mac. If list::end() "returns an iterator
I'm running Windows Server 2003 on a 64-bit Itanium server which is also running
Platform: Windows 7, 64 bit (x64), Visual Studio 2008 I chose Python & Swig
Python 2.7 (32-bit) Windows: We're experimenting with Python 2.7's support for themed Tkinter (

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.