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 10 months ago
  • Hamza Anwar

    Hello brother. I am having the same issue if you can help me..

    class Question:
    def init(self, prompt, answer):
    self.prompt = prompt
    self.answer = answer

    -----------------------------------------------------------

    from Question import Question

    Questionsarray = [
    "Who is Newton?\n(a) Scientist\n(b) Mathematician\n(c) Jack the rebel\n\n",
    "What color is black?\n(a) Black\n(b) White\n(c) No color\n\n",
    "What color is sky?\n(a) Magenta\n(b) Transparent\n(c) Green\n\n"
    ]

    askQuestion = [
    Question(Questionsarray[0], "c"),
    Question(Questionsarray[1], "a"),
    Question(Questionsarray[2], "b")
    ]
    print(Question.prompt)
    def runTest(askQuestion):
    marks = 0
    for questions in askQuestion:
    userAnswer = input(Question.prompt)
    if userAnswer == Question.answer:
    marks += 1
    else:
    marks == marks

    runTest(askQuestion)


  • Whitelisted Links