By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,035 Members | 1,995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,035 IT Pros & Developers. It's quick & easy.

How to correct attribute error?

P: 7
'myApp' object has no attribute 'closebtn'

Expand|Select|Wrap|Line Numbers
  1. import wx, os, shutil, fnmatch, sys, textwrap, re
  2. import wx.lib.intctrl
  3.  
  4. class myApp(wx.Frame):
  5.     def __init__(self,parent,id):
  6.         wx.Frame.__init__(self,parent,id,'Export Form', size=(500,500))
  7.         panel =wx.Panel(self)
  8.  
  9.         #Creating Static texts
  10.         text1 =wx.StaticText(panel, -1,"Select Data Source",(150,10),(150,-1),wx.ALIGN_CENTER)
  11.         text1.SetForegroundColour('Blue')
  12.         #text1.SetBackgroundColour('Blue')
  13.  
  14.  
  15.         text2 =wx.StaticText(panel, -1,"Use Chain Seeds",(40,60),(150,-1),wx.ALIGN_LEFT)
  16.         text3 =wx.StaticText(panel, -1,"Use Custom Seeds",(40,90),(200,-1),wx.ALIGN_LEFT)
  17.         text4 =wx.StaticText(panel, -1,"Export template",(140,130),(200,-1),wx.ALIGN_LEFT)
  18.         text5 =wx.StaticText(panel, -1,"Apply Selection",(210,310),(200,-1),wx.ALIGN_LEFT)
  19.         text6 =wx.StaticText(panel, -1,"Return to main menu",(210,360),(200,-1),wx.ALIGN_LEFT)
  20.         # Setting the fonts
  21.         font1 =wx.Font(15, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
  22.         font2 =wx.Font(10, wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD)
  23.  
  24.         #Applying Fonts
  25.         text1.SetFont(font1)
  26.         text2.SetFont(font2)
  27.         text3.SetFont(font2)
  28.         text4.SetFont(font2)
  29.         text5.SetFont(font2)
  30.         text6.SetFont(font2)
  31.  
  32.         #Creating Buttons
  33.         button1 =wx.Button(panel,label="Export",pos=(75,120),size=(50,30))
  34.         button2 =wx.Button(panel,label="Select Custom Data File",pos=(90,200),size=(150,30))
  35.         button3 =wx.Button(panel,label="",pos=(150,300),size=(50,30))
  36.         button4 =wx.Button(panel,label="",pos=(150,350),size=(50,30))
  37.  
  38.  
  39.         #Creating Radio Buttons
  40.         rb1 =wx.RadioButton(panel, -1,'',(25,60),style=wx.RB_GROUP)
  41.         rb2 =wx.RadioButton(panel, -1,'',(25,90))
  42.  
  43.         self.Bind(wx.EVT_BUTTON, self.closebtn, button1)
  44.  
  45.         def closebtn(self,event):
  46.             self.Close(True)
  47.  
  48. if __name__ == '__main__':
  49.     app=wx.PySimpleApp()
  50.     frame=myApp(parent=None,id=-1)
  51.     frame.Show()
  52.     app.MainLoop()
Feb 3 '11 #1
Share this Question
Share on Google+
1 Reply


bvdet
Expert Mod 2.5K+
P: 2,851
Your indentation is incorrect. Move method "closebtn" out to the same indentation as "__init__".
Feb 3 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.