[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] wxPython Message Window returns in Pygame



Hi,
  I've got a Pygame window from which a wxPython window pops up.  One enters 5 values into 5 boxes, and then clicks OK.  I want those return strings!  Instead, when I print the returned value, I get '5100'.  After the window exits, clicking on the print window causes a crash.  Here's the code:

class EquationDialog(wx.Dialog):
    def __init__(
            self, parent, ID, title, size=wx.DefaultSize, pos=wx.DefaultPosition,
            style=wx.DEFAULT_DIALOG_STYLE
            ):

        pre = wx.PreDialog()
        pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
        pre.Create(parent, ID, title, pos, size, style)

        self.PostCreate(pre)

        sizer = wx.BoxSizer(wx.VERTICAL)

        label = wx.StaticText(self, -1, "Enter the equation(s) to graph below.")
        sizer.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

        for equation in range(5):
            box = wx.BoxSizer(wx.HORIZONTAL)
            label = wx.StaticText(self, -1, str(equation+1)+":   y = ")
            box.Add(label, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            text = wx.TextCtrl(self, -1, "", size=(80,-1))
            box.Add(text, 1, wx.ALIGN_CENTRE|wx.ALL, 5)
            sizer.Add(box, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)
        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)

        btnsizer = wx.StdDialogButtonSizer()
       
        if wx.Platform != "__WXMSW__":
            btn = wx.ContextHelpButton(self)
            btnsizer.AddButton(btn)
       
        btn = wx.Button(self, wx.ID_OK)
##        btn.SetHelpText("The OK button completes the dialog")
        btn.SetDefault()
        btnsizer.AddButton(btn)

        btn = wx.Button(self, wx.ID_CANCEL)
##        btn.SetHelpText("The Cancel button cancels the dialog. (Cool, huh?)")
        btnsizer.AddButton(btn)
        btnsizer.Realize()

        sizer.Add(btnsizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)app = wx.PySimpleApp()

dlg = EquationDialog(None, -1, "Set the Equation(s)", size=(350, 200),
                             #style = wxCAPTION | wxSYSTEM_MENU | wxTHICK_FRAME
                             style = wx.DEFAULT_DIALOG_STYLE
                             )
dlg.CenterOnScreen()
val = dlg.ShowModal()
dlg.Destroy()

This last paragraph is actually in a function which is called by the main program.  Again, the return, val, is something like 5100, no matter what I put in.  Clicking on the console window causes a crash?!
Thanks,
Ian