Re: sorry, pyLbc again

  • From: Alex Hall <mehgcap@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 11 Jul 2010 19:16:22 -0400

That is just it: I have nothing recursing, and the bug is in
FindWindowByName. That is why I find it so strange to have a recursion
error: I am not sure where I am using recursive logic. At least it is
no where that I can find in my code. The code is pretty simple:

"""
Modified by Alex Hall from the Fruit basket program in Python with lbc
Public domain by Jamal Mazrui
I mostly modded the Fruit Basket file because of its fancy event
handler function.
"""

import wx, lbc


# Custom event handler
def myHandler(dlg, event):
 wgt=event.GetEventObject()
 if event.GetEventType() in wx.EVT_CLOSE.evtType or
wgt.GetName()=='Button_Close':
  dlg.Close()
 else: pass

 i1=dlg.FindWindowByName('TextCtrl_i1')
 i2=dlg.FindWindowByName('TextCtrl_i2')
 i3=dlg.FindWindowByName('TextCtrl_i3')
 cost1=dlg.FindWindowByName('TextCtrl_cost')
 ans=dlg.FindWindowByName('TextCtrl_Result')
 if wgt.GetName() == 'Button_Calculate': #perform the calculation
  try:
   n1=int(i1.GetValue())
   n2=int(i2.GetValue())
   n3=int(i3.GetValue())
   cost=int(cost1.GetValue())
   ans.SetValue(str(n1+n2+n3*cost))
   ans.SetFocus()
  except:
   lbc.DialogShow(title="Error!", message="Either an invalid character
was entered in one of the fields, or you left one or more fields
blank. Please check your inputs. Exact error checking has never been
one of my strong points...")
   i1.SetFocus()
  #end except
#end def

# set up the dialog to be shown
app = lbc.App()
dlg = lbc.Dialog(title='Electricity Cost Thingy')
dlg.AddTextCtrl(label='i1')
dlg.AddTextCtrl(label='i2')
dlg.AddTextCtrl(label='i3')
dlg.AddBand()
dlg.AddTextCtrl(label='Cost (no dollar sign):')
dlg.AddButton(label="Calculate")
dlg.AddTextCtrl(label='Result:')
dlg.ShowModal(buttons=['Close'], handler=myHandler)
app.Exit()


On 7/11/10, qubit <lauraeaves@xxxxxxxxx> wrote:
> This means you have an infinite recursion in your code. Perhaps that is not
> the event your handler was defined to handle.
> Your runtime stack is overflowing because you don't have a condition in some
> function that will halt the recursion. Check all the functions that are
> recursive and see if you may have omitted something.
> This is a common type of bug. Everyone codes an infinite recursion sometime
> when learning to program.
> --le.
>
> ----- Original Message -----
> From: "Alex Hall" <mehgcap@xxxxxxxxx>
> To: "programmingblind" <programmingblind@xxxxxxxxxxxxx>
> Sent: Sunday, July 11, 2010 5:47 PM
> Subject: sorry, pyLbc again
>
>
> Hi all,
> Sorry for all the pyLbc posts, but this one is quite confusing. I have
> a custom event handler defined for a dialog. However, the error keeps
> coming up as lbc.py, line 478, in DefaultHandler. I am not sure why
> that would be called if I have my own event handler?
> Anyway, the error is also confusing: maximum recursion depth exceeded.
> The line is
> window = self.FindWindowByName(control)
> I had not seen this error before today (until now, everything was
> working fine), and I cannot see what I changed. I tried to up things
> back just as they were yesterday, when everything was working, but I
> still have no luck. Thoughts? TIA.
>
>
> --
> Have a great day,
> Alex (msg sent from GMail website)
> mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
>


-- 
Have a great day,
Alex (msg sent from GMail website)
mehgcap@xxxxxxxxx; http://www.facebook.com/mehgcap
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: