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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:36:33+00:00 2026-05-22T21:36:33+00:00

I have a text box in wxpython (see below) that stores the name of

  • 0

I have a text box in wxpython (see below) that stores the name of the value as a variable.

I am trying to do two things:

After the answer is entered, I want to display another question, and assign the new answer to another variable, using the same or an idential TextEntryDialog window.

Ideally, from a user standpoint, they just see a prompt, type an answer (or select from a list), and then after hitting OK, the prompt will change, and they will type in a new answer (which will be assigned to a new variable).

So why am I trying to do this? So that after the end of this Q & A session, I can write all of the variables to a database using pyodbc (which I dont need to know about right now).

So could you please tell me how I can automatically generate new prompts once an answer has been entered without closing the app and losing the variable data? And is there anyway to automatically backup this variable data while the user is answering in case the app crashes? My question list is about 250 questions long, and I dont want all those variables lost if my application crashes (which they tend to do)

Thanks!

import wx

class applicationName(wx.Frame):

    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent, id, 'Title', size=(300,200))

        #create panel and button
        panel = wx.Panel(self)

        test = wx.TextEntryDialog(None, "What's your name?", 'Title', 'Enter name')
        if test.ShowModal() == wx.ID_OK:
            apples = test.GetValue()

            wx.StaticText(panel, -1, apples, (10,10))


if __name__ =='__main__':
    app = wx.PySimpleApp()
    frame = applicationName(parent=None, id=-1)
    frame.Show()
    app.MainLoop()
  • 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-22T21:36:33+00:00Added an answer on May 22, 2026 at 9:36 pm

    I don’t recommend creating and destroying 250 dialogs like the other fellow did. I would probably create a list or dict at the beginning of my program that would get appended to whenever the user enters an answer. Also in that event handler, I would reset the StaticText control with a new question. You might need to refresh the screen if your questions vary a lot in length, but I think that would be a lot better than showing hundreds of dialogs in a row.

    EDIT – Added some example code below:

    import wx
    
    class MyForm(wx.Frame):
    
        #----------------------------------------------------------------------
        def __init__(self):
            wx.Frame.__init__(self, None, wx.ID_ANY, "Tutorial")
    
            # Add a panel so it looks the correct on all platforms
            panel = wx.Panel(self, wx.ID_ANY)
            self.answers = {}
            self.questions = ["What is your age?", "What is your weight?",
                              "Which of the following computer languages is the best ever: C++, PHP, Fortran, COBOL, Python?"]
            self.nextQuestion = 0
    
            self.question = wx.StaticText(panel, label="What is your name?")
            self.answer = wx.TextCtrl(panel, value="")
            submitBtn = wx.Button(panel, label="Submit")
            submitBtn.Bind(wx.EVT_BUTTON, self.onSubmit)
    
            sizer = wx.BoxSizer(wx.VERTICAL)
            self.panelSizer = wx.BoxSizer(wx.VERTICAL)
    
            sizer.Add(self.question, 0, wx.ALL, 5)
            sizer.Add(self.answer, 0, wx.ALL|wx.EXPAND, 5)
            sizer.Add(submitBtn, 0, wx.ALL|wx.CENTER, 5)
            panel.SetSizer(sizer)
    
            self.panelSizer.Add(panel, 1, wx.EXPAND)
            self.SetSizer(self.panelSizer)
    
        #----------------------------------------------------------------------
        def onSubmit(self, event):
            """"""
            self.answers[self.question.GetLabel()] = self.answer.GetValue()
            self.question.SetLabel(self.questions[self.nextQuestion])
            self.answer.SetValue("")
            self.nextQuestion += 1
            print self.answers
            self.panelSizer.Fit(self)
    
    
    
    # Run the program
    if __name__ == "__main__":
        app = wx.App(False)
        frame = MyForm()
        frame.Show()
        app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a text box that the user can type in that
I have an ASP.NET user control that contains a text box control and a
For both .NET Winforms and Windows Presentation Foundation, if I have a text box
I have some client-side validation against a text box, which only allows numbers up
I have this bit of script to widen a text box on mouseover and
i have a text box where the user will the url in it and
I have a text box. I want to take user input from there and
I have a text box in an HTML form where the user will input
I have a text box and a repeater control. I need to bind the
I have a text box and I want to display a C# object in

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.