name 'dlg' is not defined error

Help
galaganut
2004-08-29
2004-08-30
  • galaganut

    galaganut - 2004-08-29

    Hello,
    I have worked through the entire tutorial and when I try to run the application I get this error:

    name 'dlg' is not defined
    line 101 dlg.destroy()

    I am not sure why I get this error, my code looks exactly like the tutorial.
    Thanks,
    Chuck

    Python 2.3
    windows XP

     
    • Werner F. Bruhin

      If you post your code it would be easier to help (no guarantee so!).

      The easiest is if you post as an attachment on this boa newsgroup

      gmane.comp.ide.boa-constructor.user

      See you
      Werner

       
    • galaganut

      galaganut - 2004-08-29

      Thanks Werner,

      I was not able to find any help in the forum you suggested.  Here is the block of code that is giving me the problem::

      def OnMnuFileItems0Menu(self, event):
              dlg = wxFileDialog(self, "Choose a file", ".", "", "*.*", wxOPEN)
      try:
          if dlg.ShowModal() == wxID_OK:
              filename = dlg.GetPath()
              self.txtEditor.LoadFile(filename)
              self.fileName=filename
      finally:
          dlg.Destroy()

      ::

      I am new to python so I very well could be missing something, but I followed the tutorial exactly.

      Thanks,
      Chuck

       
      • Werner F. Bruhin

        I can only guess that you have an indentation problem, I think your try/finally block is NOT on the correct level.

        Python is very sensitive, in my view actually a good thing, as it forces everyone to indent things correctly.  Makes it easier to read a program and forces some consitency.

        I will post a small file on gmane newsgroup - won't do it here because sourceforge does strange things to indentation.

        See you
        Werner

         

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks