Further to my earlier post, a script to illustrate the problem
is given below. This returns the error message:
TRAP FRAME
Traceback (most recent call last):
File "G:\My Files\Python\Testing\TextGrief.py", line 82, in OnInit
runTest(self, frame, self.log)
File "G:\My Files\Python\Testing\TextGrief.py", line 24, in runTest
f= Field(frame, -1, 'UGH', size= (60, 22))
File "G:\My Files\Python\Testing\TextGrief.py", line 8, in __init__
wxTextCtrl(self, parent, Id= Id, pos= pos, value= value, size=size)
File "g:\python20\wxPython\controls.py", line 561, in __init__
self.this = apply(controlsc.new_wxTextCtrl,_args,_kwargs)
AttributeError: 'MainFrame' instance has no attribute '__int__'
Colin W.
''' textGrief.py To subclass a TextCtrl '''
from wxPython.wx import *
class Field(wxTextCtrl):
def __init__(self, parent, Id= -1, value= ' ',
pos= (-1, -1),
size= wxDefaultSize):
wxTextCtrl(self, parent, Id= Id, pos= pos, value= value, size=size)
## EVT_KILL_FOCUS(self, self.OnKillFocus)
## EVT_SET_FOCUS(self, self.OnFocus)
EVT_TEXT_ENTER(self.GetId(), func)
def OnCommand(self, event):
self.log.WriteText("TextPanel OnCommand: " + `self.wList` + "\n")
def OnEnter(self, event):
self.log.WriteText("TextPanel OnEnter: " + `self.wList` + "\n")
def OnFocus(self, event):
self.log.WriteText("TextPanel OnFocus: " + `self.wList` + "\n")
def OnKillFocus(self, event):
self.log.WriteText("TextPanel KillFocus: " + `self.wList` + "\n")
def runTest(app, frame, log):
## b = wxBoxSizer(wxHORIZONTAL)
f= Field(frame, -1, 'UGH', size= (60, 22))
return
ID_ABOUT = 101
ID_EXIT = 102
class MainFrame(wxFrame):
def __init__(self):
try:
wxFrame.__init__(self, NULL, -1, pos= (20, 20), size= (200, 200),
title= "Testing...", name= 'Main Frame')
self.SetBackgroundColour(wxWHITE)
self.CreateStatusBar()
mainmenu = wxMenuBar()
menu = wxMenu()
menu.Append(ID_ABOUT, "&About",
"TestCtrl problem")
menu.Append(ID_EXIT, 'E&xit', 'We are finished!')
mainmenu.Append(menu, "&File")
self.SetMenuBar(mainmenu)
EVT_MENU(self, 200, self.OnExit)
EVT_CLOSE(self, self.OnCloseWindow)
rect= self.GetSize()
rect.x+=1
self.SetSize(rect)
print 'Main: End of __init__'
except:
import traceback
print 'TRAP FRAME'
traceback.print_exc() # and you still get your trace
self.Destroy() # causes main loop to exit
return 0
def OnSetFocus(self):
print 'OnFocus:'
def OnSize(self):
print 'MainFrame: OnSize'
def OnCloseWindow(self, event):
print 'MainFrame: OnClose Veto=', event.GetVeto(), event.CanVeto()
self.Destroy()
def OnExit(self, event):
print 'Main: OnExit'
self.Close()
class Logger:
def __init__(self):
z= 1 # Do nothing
def WriteText(self, txt= 'anything'):
print txt
class TestApp(wxApp):
def OnInit(self):
try:
frame = MainFrame()
self.log = Logger()
self.log.WriteText('TestApp')
runTest(self, frame, self.log)
frame.Show(true)
self.SetTopWindow(frame)
print 'End of TestApp.__init__'
return true
except:
import traceback
print 'TRAP FRAME'
traceback.print_exc() # and you still get your trace
self.ExitMainLoop() # causes main loop to exit
return false
if __name__ == '__main__':
app = TestApp(0)
app.MainLoop()
···
_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/wxpython-users