import wx 

class bucky(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Frame aka window', size=(400,300))
        panel=wx.Panel(self)

    status=self.CreateStatusBar()   
    menubar=wx.MenuBar()
    first=wx.Menu()
    second=wx.Menu()
    first.Append(wx.NewId(),"new window")
    first.Append(wx.NewId(),"Open...")
    menubar.Append(first,"File")
    menubar.Append(second,"edit")
    self.SetMenuBar(menubar)


if __name__=='__main__':
    app=wx.PySimpleApp()
    Frame=bucky(parent=None, id=-1)
    Frame.Show()
    app.MainLoop()

when i run this program, i get a "self is not defined in status=self.CreateStatusBar()".

so i erased that part, and it gives me another error: "PyNoAppError: The wx.App object must be created first!"

this is just some code i copied from a tutorial.
i am using python 2.6.1.

Recommended Answers

All 2 Replies

indentations 4 space,is important in python.
If you have a good python editor it will auto indent.

import wx

class bucky(wx.Frame):

    def __init__(self,parent,id):
        wx.Frame.__init__(self,parent,id,'Frame aka window', size=(400,300))
        panel=wx.Panel(self)

        status=self.CreateStatusBar()
        menubar=wx.MenuBar()
        first=wx.Menu()
        second=wx.Menu()
        first.Append(wx.NewId(),"new window")
        first.Append(wx.NewId(),"Open...")
        menubar.Append(first,"File")
        menubar.Append(second,"edit")
        self.SetMenuBar(menubar)

if __name__=='__main__':
    app=wx.PySimpleApp()
    Frame=bucky(parent=None, id=-1)
    Frame.Show()
    app.MainLoop()
commented: excellent observation +12

thanks!!! almost drove me mad!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.