Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:32:27+00:00 2026-06-11T13:32:27+00:00

attrubuI’m new to python but don’t know how to solve this: import wx class

  • 0

attrubuI’m new to python but don’t know how to solve this:

import wx

class myclass(wx.Frame):

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

        button=wx.Button(panel,label="click me",size=(120,60))
        self.Bind(wx.EVT_BUTTON, self.clickbutton, button)

        value=1

    def clickbutton(self, event):
        if self.value == 1:
            print("success")

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

When I click the button I receive this error: “AttributeError: ‘myclass’ object has no attribute ‘value'”. What am I doing wrong? / How do I import “value” into my “clickbutton”-function?

Edit:
OK, this one was solved. After that I wanted to modify it a little:

    self.dropdown=wx.Choice(panel,pos=(130,60))
    list = ['banana', 'apple', 'strawberry']
    self.dropdown.AppendItems(strings=list)

def clickbutton(self, event):
    if self.dropdown.GetStringSelection() == 'apple':
        print("success")

Actually this works…. but it took me a long time to figure out that I have to use “GetStringSelection()” in the last but one line. How can i display a list with possible attributes (like “GetStringSelection()”) for “wx.Choice” (and other wx-classes) ? Or does a good website for this exists?

Edit 2:
Thanks again!
And I have a last question (sorry for asking step by step):

dir(wx.Choice)

works, but I have a given code with an obejct called “VarDecl”. For this I get an error if I ask

dir(wx.VarDecl)

I’m lookin for an attribute like “HasChanged” for this VarDecl-object.

Traceback (most recent call last):
File [...]    
if self.theVariable.HasChanged():
AttributeError: 'VarDecl' object has no attribute 'HasChanged'

Edit3:
OK, I think it has nothing to do with “wx”, I think it comes from “re”. (or still “wx”? I’m confused)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:32:28+00:00Added an answer on June 11, 2026 at 1:32 pm

    Change value=1 to self.value = 1. The value you have now is a local variable, which is discarded upon exiting the constructor.

    EDIT: As for your second question, the built-in function dir(object) will give you a list of names (including methods) in the scope of the given object.
    More information available here

    EDIT 2: The wxPython documentation may also be of use to you

    EDIT 3: About the theVariable thing: Have you tried dir(self.theVariable)?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.