Python Discussion Forums

There's no such thing as a stupid question. Ask. Discuss. Learn.

Attribute error: ….. object has no attribute ……….

Hi guys! I am new to python, I am using the wx python tutorials from http://zetcode.com/wxpython/menustoolbars/.

Can someone please explain to me how to fix this problem. I do not want to use a class. I tired moving def OnQuit(), I tried adding OnQuit( frame), OnQuit (frame, e) and I tried everything I though of.


#!/usr/bin/env python3

-- coding: utf-8 --

simple.py

import wx
#Menu block functionality
def OnQuit():
frame.Close()

app = wx.App()

frame = wx.Frame(None, title='Simple application', size=(1000, 1000))
#Menu block
menubar = wx.MenuBar()
fileMenu = wx.Menu()
fileItem = fileMenu.Append(wx.ID_EXIT, 'Quit', 'Quit application')
menubar.Append(fileMenu, '&File')
frame.SetMenuBar(menubar)
frame.Bind(wx.EVT_MENU, frame.OnQuit, fileItem)
#Position block
#frame.Move((800, 250))
frame.Centre(event)

frame.Show()
app.MainLoop()


Arakelthedragon 5 months ago
  • Whitelisted Links