import variable
Question: 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)


Answer: 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](http://docs.python.org/library/functions.html#dir)

**EDIT 2:** [The wxPython documentation may also be of use to
you](http://wxpython.org/docs/api/)

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

