0
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.

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by plasticfood
1

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()

Edited by snippsat: n/a

Votes + Comments
excellent observation
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.