Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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.</p> <p><strong>EDIT</strong> - Added some example code below:</p> <pre><code>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() </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload