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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:52:19+00:00 2026-06-10T01:52:19+00:00

I’m writing a program so I can send SMS via email and using wxpython.

  • 0

I’m writing a program so I can send SMS via email and using wxpython. Using Combobox to select which carrier the phone number is attached to. However, the program continues with everything else before I have a chance to select a carrier. Is there a way to make this halt until I make a choice? Still learning how to copy/paste in here so forgive any indentation errors, it’s all correct in my code. Thanks everyone! 🙂

  if password.ShowModal() == wx.ID_OK:
      pwd =password.GetValue()
      phone_number = wx.TextEntryDialog(self,"Phone Number", "Phone Number", "")
      if phone_number.ShowModal() == wx.ID_OK:
        number = phone_number.GetValue()
        self.carrier = wx.ComboBox(self, -1, pos=(10, 50), choices=carriers, style=wx.CB_READONLY)
        self.carrier.Bind(wx.EVT_COMBOBOX, self.onCombo)
        if self.carrier.ShowModal() == wx.EVT_COMBOBOX:
           message = wx.TextEntryDialog(self,"Your Message", "Your Message", "")
           if message.ShowModal() == wx.ID_OK:

              msg = message.GetValue()
              smtpserver = smtplib.SMTP("smtp.gmail.com", 587)
              smtpserver.ehlo()
              smtpserver.starttls()
              smtpserver.ehlo
              smtpserver.login(username, pwd)
              header = 'To:' + email + '\n' + 'From: ' + username + '\n' + 'Subject:testing \n'
              print header
              msg1 = header + msg
              smtpserver.sendmail(username, email, msg1)
              smtpserver.close()

 def onCombo(self, event):


    self.selection = self.carrier.GetValue()
    print self.selection
    print self.number
    self.email = number + selection
    print email
    return self.email
  • 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-10T01:52:21+00:00Added an answer on June 10, 2026 at 1:52 am

    Right away I can tell you that self.carrier is of type wx.ComboBox and does not have a ShowModal() method. And if it did it wouldn’t return wx.EVT_COMBOBOX. The ShowModal() method returns the ID of the button that was clicked. wx.EVT_COMBOBOX is an event, not an ID and thus would not be returned.

    Only wx.Dialogs use ShowModal(). It looks like the dialog you want is a wx.SingleChoiceDialog (You can find a tutorial here but you’ll need to scroll about 7/8 of the way down. Or just hit ctrl+f and search for “singlechoice”). This will show a list and prompt users to make a single selection.

    Alternatively, you could create your own custom dialog (tutorials here and here) that contain all the information you need in a single convenient dialog (instead of three separate ones).

    I wrote rough draft that you can find below. Just remember that I haven’t tested it so there may be errors, but it should give you an idea of what you need to do. Also, you should probably place the objects in a sizer and organize the layout the way you want it.

    class MyTxtMsgDialog (wx.Dialog):
        def __init__(self, parent):
            wx.Dialog.__init__(self, parent=parent, title="My Txt Message Dialog")
    
            self.number = wx.TextCtrl(self)
            self.carrier = wx.ComboBox(self, -1, pos=(10, 50), choices=carriers, style=wx.CB_READONLY)
            self.message = wx.TextCtrl(self, style=wx.TC_MULTILINE) #means this TextCtrl will be multiple lines, not just one
            self.okButton = wx.Button(self, wx.ID_OK, "OK")
            #Setting the ID to wx.ID_OK is important. Any of the wx.ID_* variables work natively with ShowModal()
            #but if you created your own ID using the wx.NewId() method then you will need to manually call
            #"self.EndModal(<your ID>)" when your button is clicked.
    

    You’d then call it using:

    txtMsgDialog = MyTxtMsgDialog(self)
    if txtMsgDialog.ShowModal() == wx.ID_OK: #check to see if OK was pressed
        #save the values
        self.number = txtMsgDialog.number.GetValue()
        self.carrier = txtMsgDialog.carrier.GetGetValue()
        self.message = txtMsgDialog.message.GetValue()
    
        txtMsgDialog.Destroy() #close the dialog
    

    One final note: as you can see in my example, it’s a good idea to call the Destroy() method on all of your dialogs when you’re done with them. This will close them and free the resources. Be careful though because after you call this method any variables you didn’t already save will be gone.
    I see the reason you aren’t calling Destroy() is because of an answer to a question you asked previously. It’s mostly a style issue but I think that other commenter was wrong and you should destory your dialogs when you are done with them. It closes the dialog, frees up your resources, and it’s the way all the tutorials are written.

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

Sidebar

Related Questions

I'm trying to select an H1 element which is the second-child in its group
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words

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.