Try something like this:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Mon Jun 20 06:54:49 2011
import wx
# begin wxGlade: extracode
# end wxGlade
class MyFrame(wx.Frame):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init__
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.label_1 = wx.StaticText(self, -1, "label_1")
self.text_ctrl_1 = wx.TextCtrl(self, -1, "",
style=wx.TE_PROCESS_ENTER)
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_TEXT_ENTER, self.OnTextEnter,
self.text_ctrl_1)
# end wxGlade
self.questions = ['what is your name?', 'how old are you?']
self.answers =
self.qcount = 0
self.label_1.SetLabel(self.questions[0])
def __set_properties(self):
# begin wxGlade: MyFrame.__set_properties
self.SetTitle("Q & A")
self.SetSize((640, 400))
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyFrame.__do_layout
sizer_1 = wx.BoxSizer(wx.VERTICAL)
sizer_1.Add(self.label_1, 0, 0, 0)
sizer_1.Add(self.text_ctrl_1, 0, wx.EXPAND, 0)
self.SetSizer(sizer_1)
self.Layout()
# end wxGlade
def OnTextEnter(self, event): # wxGlade: MyFrame.<event_handler>
self.qcount += 1
try:
self.answers.append(self.text_ctrl_1.GetValue())
self.label_1.SetLabel(self.questions[self.qcount])
self.text_ctrl_1.SetValue('')
except:
self.doCalculations()
event.Skip()
def doCalculations(self):
print self.questions
print self.answers
for n in range(len(self.questions)):
q = self.questions[n]
try:
a = self.answers[n]
print 'q and a: %s = %s' % (q, a)
except:
print 'q and a: %s = (no answer)' % q
# end of class MyFrame
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindow(frame_1)
frame_1.Show()
app.MainLoop()
···
On Jun 19, 7:37 pm, just_vic8367 <vicp...@yahoo.com> wrote:
Concept:
I am trying to write a program in which the Program will ask the User
a series of questions.
For example:
1. What is your name?
* The User inputs their name
* The User press enter
*Question number 1 disappears
*Another question appears
2. What is your age?
*User Inputs age
*The User press enter
***The program calculates
3. Outputs - "You have given me 2 pieces of information.
Specifically I do not know how to approach on making the Questions
disappear and then replaced.