If your derive the app class from wxPySimpleApp instead of deriving from wxApp, you will get more useful debug error from python interpreter.
As per wxWindows document,
-
There is no style called wxLC_VIRTUAL.
-
SetItemCount is not a member funtion of wxListCtrl.
If you rectify above 2 errors, ur app works fine and have empty listctrl. use **InsertStringItem(index, label) **
to add items in listctrl.
Maharajan
···
-----Original Message-----
From: Eric Mangold [mailto:ericmangold@yahoo.com]
Sent: Wednesday, February 20, 2002 1:44 PM
To: wxPython Mailing List
Subject: [wxPython] Assert failing, reason unkown.
This is kind of odd. My program is tripping one of the assert’s (apparently inside of the wxWindows library), that generates a little msgbox with the title “Debug” and the contents:
C:\Projects\wx\src\msw\listctrl.cpp(2095): assert failed: not supposed to be called
Do you want to stop the program?
You may also press cancle to supress further warnings.
Pressing yes, obviously closes the program, pressing NO causes the python interpreter to crash, pressing CANCLE causes the application to run flawlessly from that point on. Not pressing anything after several seconds or moving the msgbox causes the python interpreter to crash immediately.
Since I have no idea why this assert is being tripped, I though I might ask If anyone knows, or if anyone knows whats steps I should take to gather more info about it.
I have included my programs source below:
from wxPython.wx import *
from random import *
class MyListCtrl(wxListCtrl):
def init(self, parent, id):
wxListCtrl.init(self, parent, id, size=wxSize(400,650), style=wxLC_REPORT | wxLC_VIRTUAL | wxLC_EDIT_LABELS) #Call the base classes constructor to get the object initialized.
self.sort_order = (0,1) #holds the last two column numbers whos headers were clicked, index 0 is the most recent.
#setup event handlers for various things like clicks on the column headers. EVT_LIST_COL_CLICK(self, self.GetId(), self.ColHeadClick) #setup the listctrl columns self.SetItemCount(500)
col_info = wxListItem() col_info.m_mask = wxLIST_MASK_TEXT
col_info.m_text = "Alias" self.InsertColumnInfo(0, col_info)
col_info.m_text = "Host" self.InsertColumnInfo(1, col_info)
col_info.m_text = "Port" self.InsertColumnInfo(2, col_info)
col_info.m_text = "Passwd" self.InsertColumnInfo(3, col_info)
col_info.m_text = "State" self.InsertColumnInfo(4, col_info)
col_info.m_text = "Last Response" self.InsertColumnInfo(5, col_info)
#build up some random data for testing purposes, from which OnGetItemText will draw its data self.pot = ("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z") self.rowdata = [] for i in range(500): coldata = [] for j in range(6): colitem = "" for k in range(5): colitem += choice(self.pot) coldata.append(colitem) self.rowdata.append(coldata) del coldata
self.sort_order = (0,1) #set the starting sort order, and sort it to begin with. self.rowdata.sort(self.SortItUp) def OnGetItemText(self, row, col): #this method must be able to return the contents of any row/column that it is asked for. return self.rowdata[row][col] def ColHeadClick(self, obj): #this method takes appropriate action when a columns header is clicked self.sort_order = (obj.GetColumn(), self.sort_order[0]) #move item 0 to item 1 and bring in item 0 from the passed in ListEven object.
if self.sort_order[0] == self.sort_order[1]: self.rowdata.reverse() return self.rowdata.sort(self.SortItUp)
def SortItUp(self, arg1, arg2): if arg1[self.sort_order[0]] < arg2[self.sort_order[0]]: return -1 elif arg1[self.sort_order[0]] > arg2[self.sort_order[0]]: return 1 else: return 0
class MySplitter(wxSplitterWindow):
def init(self, parent, id, pos, size):
wxSplitterWindow.init(self, parent, id, pos, size)
self.LeftPane = MyListCtrl(self, -1)
self.RightPane = wxWindow(self, -1)
self.RightPane.SetBackgroundColour(wxBLUE)
wxStaticText(self.RightPane, -1, “Panel Two”, wxPoint(5,5)).SetBackgroundColour(wxBLUE)
self.SetMinimumPaneSize(20)
self.SplitVertically(self.LeftPane, self.RightPane)
self.SetSashPosition(400)
class MyFrame(wxFrame):
def init(self, parent, id, title, pos, size):
wxFrame.init(self, parent, id, title, pos, size)
self.Splitter = MySplitter(self, -1, wxDefaultPosition, wxDefaultSize)
class MyApp(wxApp):
def OnInit(self):
self.Frame = MyFrame(NULL, -1, “DED - Distributed Electronic Dictator - v0.2”, wxDefaultPosition, wxDefaultSize)
self.Frame.Show(true)
self.SetTopWindow(self.Frame)
return true
App = MyApp()
App.MainLoop() #lets rock