Possible bug in WxPython
vtail
vtail at yandex.ru
Mon Sep 9 09:57:29 EDT 2002
Greetings.
When trying to run an example program from wxWiKi
http://wiki.wxpython.org/index.cgi/Getting_20Started, section 7.1.2, I
encounter following error. Could someone please explain it to me?
My python version is
Python 2.2.1c2 (#33, Mar 26 2002, 13:04:18) [MSC 32 bit (Intel)] on
win32,
my wxpython version is 2.3.2.1 (from
c:/Python22/Lib/site-packages/wxPython/__version__.py)
I've attached the error message and the program that causes it.
Thanks for your help, Vtail.
====>
O:\_PUBLIC\Newdbase\Python\wxPython>python test4.pyw > aaa.txt
17:52:59: Debug: c:\Projects\wx\src\msw\app.cpp(542):
'UnregisterClass(no redraw
canvas)' failed with error 0x00000584 (class still has open
windows.).
17:52:59: There were memory leaks.
17:52:59: ----- Memory dump -----
17:52:59: wxFrame at $FF8890, size 332
17:52:59: wxTextCtrl at $115EAA8, size 316
17:52:59: wxStatusBar at $778C38, size 260
17:52:59: wxMenu at $10D3AB0, size 112
17:52:59: wxMenuItem at $F9CE50, size 124
17:52:59: wxMenuItem at $F9CF08, size 124
17:52:59: wxMenuItem at $F9CFC0, size 124
17:52:59: wxMenuItem at $F9D078, size 124
17:52:59: wxMenuItem at $F9D130, size 124
17:52:59: wxMenuBar at $F8FD88, size 312
17:52:59: wxPyCallback at $F81C40, size 12
17:52:59: wxObject at $85DC50, size 28
17:52:59: wxPyCallback at $F81830, size 12
17:52:59: wxPyCallback at $F82638, size 12
17:52:59: wxBoxSizer at $F8FF98, size 96
17:52:59: wxButton at $F85128, size 264
17:52:59: wxSizerItem at $F7F998, size 60
17:52:59: wxButton at $10601A0, size 264
17:52:59: wxSizerItem at $F903A0, size 60
17:52:59: wxButton at $F90418, size 264
17:52:59: wxSizerItem at $F906D8, size 60
17:52:59: wxButton at $F90750, size 264
17:52:59: wxSizerItem at $F90A10, size 60
17:52:59: wxButton at $F82B08, size 264
17:52:59: wxSizerItem at $F82CE8, size 60
17:52:59: wxButton at $F82D60, size 264
17:52:59: wxSizerItem at $F82FF8, size 60
17:52:59: wxBoxSizer at $F83070, size 96
17:52:59: wxSizerItem at $F831A0, size 60
17:52:59: wxSizerItem at $F83218, size 60
17:52:59:
17:52:59:
17:52:59: ----- Memory statistics -----
17:52:59: 8 objects of class wxSizerItem, total size 480
17:52:59: 6 objects of class wxButton, total size 1584
17:52:59: 2 objects of class wxBoxSizer, total size 192
17:52:59: 1 objects of class wxObject, total size 28
17:52:59: 3 objects of class wxPyCallback, total size 36
17:52:59: 1 objects of class wxMenuBar, total size 312
17:52:59: 5 objects of class wxMenuItem, total size 620
17:52:59: 1 objects of class wxMenu, total size 112
17:52:59: 1 objects of class wxStatusBar, total size 260
17:52:59: 1 objects of class wxTextCtrl, total size 316
17:52:59: 1 objects of class wxFrame, total size 332
17:52:59:
17:52:59: Number of object items: 30
17:52:59: Number of non-object items: 0
17:52:59: Total allocated size: 4272
17:52:59:
17:52:59:
<====
====> test4.pyw
from wxPython.wx import *
import os
ID_ABOUT=101
ID_OPEN=102
ID_BUTTON1=110
ID_EXIT=200
class MainWindow(wxFrame):
def __init__(self,parent,id,title):
self.dirname=''
wxFrame.__init__(self,parent,-4, title,
style=wxDEFAULT_FRAME_STYLE|
wxNO_FULL_REPAINT_ON_RESIZE)
self.control = wxTextCtrl(self, 1, style=wxTE_MULTILINE)
self.CreateStatusBar() # A Statusbar in the bottom of the
window
# Setting up the menu.
filemenu= wxMenu()
filemenu.Append(ID_OPEN, "&Open"," Open a file to edit")
filemenu.AppendSeparator()
filemenu.Append(ID_ABOUT, "&About"," Information about this
program")
filemenu.AppendSeparator()
filemenu.Append(ID_EXIT,"E&xit"," Terminate the program")
# Creating the menubar.
menuBar = wxMenuBar()
menuBar.Append(filemenu,"&File") # Adding the "filemenu" to
the MenuBar
self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame
content.
EVT_MENU(self, ID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_EXIT, self.OnExit)
EVT_MENU(self, ID_OPEN, self.OnOpen)
self.sizer2 = wxBoxSizer(wxHORIZONTAL)
self.buttons=[]
for i in range(0,6):
self.buttons.append(wxButton(self, ID_BUTTON1+i, "Button
&"+`i`))
self.sizer2.Add(self.buttons[i],1,wxEXPAND)
# Use some sizers to see layout options
self.sizer=wxBoxSizer(wxVERTICAL)
self.sizer.Add(self.control,1,wxEXPAND)
self.sizer.Add(self.sizer2,0,wxEXPAND)
#Layout sizers
self.SetSizer(self.sizer)
self.SetAutoLayout(1)
self.sizer.Fit(self)
self.Show(1)
def OnAbout(self,e):
d= wxMessageDialog( self, " A sample editor \n"
" in wxPython","About Sample Editor",
wxOK)
# Create a message dialog box
d.ShowModal() # Shows it
d.Destroy() # finally destroy it when finished.
def OnExit(self,e):
self.Close(true) # Close the frame.
def OnOpen(self,e):
""" Open a file"""
dlg = wxFileDialog(self, "Choose a file", self.dirname, "",
"*.*", wxOPEN)
if dlg.ShowModal() == wxID_OK:
self.filename=dlg.GetFilename()
self.dirname=dlg.GetDirectory()
f=open(os.path.join(self.dirname, self.filename),'r')
self.control.SetValue(f.read())
f.close()
dlg.Destroy()
app = wxPySimpleApp()
frame = MainWindow(None, -1, "Sample editor")
frame.Show(1)
<====
More information about the Python-list
mailing list