Note that there are some explanatory texts on larger screens.

plurals
  1. POimport variable
    primarykey
    data
    text
    <p>attrubuI'm new to python but don't know how to solve this:</p> <pre><code>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() </code></pre> <p>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?</p> <p>Edit: OK, this one was solved. After that I wanted to modify it a little:</p> <pre><code> 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") </code></pre> <p>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?</p> <p>Edit 2: Thanks again! And I have a last question (sorry for asking step by step):</p> <pre><code>dir(wx.Choice) </code></pre> <p>works, but I have a given code with an obejct called "VarDecl". For this I get an error if I ask</p> <pre><code>dir(wx.VarDecl) </code></pre> <p>I'm lookin for an attribute like "HasChanged" for this VarDecl-object. </p> <pre><code>Traceback (most recent call last): File [...] if self.theVariable.HasChanged(): AttributeError: 'VarDecl' object has no attribute 'HasChanged' </code></pre> <p>Edit3: OK, I think it has nothing to do with "wx", I think it comes from "re". (or still "wx"? I'm confused) </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload