Python shell sad it has no reference for "frame" but gets it right in another script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • roryclancy
    New Member
    • Jan 2014
    • 8

    Python shell sad it has no reference for "frame" but gets it right in another script

    I am on a window xp and I've down loaded python 2.7.6 and wxpython 3.3, and i've run the following code
    Code:
    #import wx
    
    class bucky(wx, frame):
        
        def __init__(self, parent,id):
            wx.Frame.__init__(self, prent, id, 'Frame aka window', size = (300,200))
    
    if __name__== "__main__":
        app = wx.PySimpleApp()
        frame = bucky(parent = None, id = -1)
        frame.Show()
        app.MainLoop()#
    from the new boston and the error message i get back is:

    Traceback (most recent call last):
    File "C:\Python27\bu cky test", line 3, in <module>
    class bucky(wx, frame):
    NameError: name 'frame' is not defined
    what do i do
    thank you
    Last edited by Rabbit; Jan 2 '14, 04:44 AM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    You misspelled "parent" in wx.Frame.__init __. The following code works for me, your original code does not.
    Code:
    import wx
    
    class bucky(wx.Frame):
        def __init__(self, parent,id):
            wx.Frame.__init__(self, parent, id, 'Frame aka window', size = (300,200))
    
    if __name__== "__main__":
        app = wx.PySimpleApp()
        frame = bucky(parent = None, id = -1)
        frame.Show()
        app.MainLoop()

    Comment

    • roryclancy
      New Member
      • Jan 2014
      • 8

      #3
      Thank you
      dwbles
      liked your answer a lot really helped, while I have you any idea how to get the editor to color code the text Thanks again
      Clancypmr

      Comment

      Working...