Hello Ramit yes solution worked... thanks and regards marco
On Mon, Oct 22, 2012 at 5:58 PM, Prasad, Ramit <ramit.pra...@jpmorgan.com>wrote: > Marco Mistroni wrote: > > > Hello > > i found the problem. It's calling self.list.ClearAll that causes the > segmentation fault. > > removing the call to ClearAll fixed my problem , but i still want to > clear the list before i load new > > data...... > > could anyone assist? > > I think the problem is the way you populate the data. The issue > with ClearAll is a side effect of that. See below for more information. > > > > > wkr > > marco > > On Fri, Oct 19, 2012 at 11:05 PM, Marco Mistroni <mmistr...@gmail.com> > wrote: > > Hi all > > i have written a wx GUI which downloads json data from a server, and > populate a listbox. > > Every time i populate a listbox, i am receiving Segmentation Faults. > > I have tried to retrieve data from the URL via separate thread, and to > use events, but i am still getting a > > segmentation fault > > > > could anyone assist pls? > > > > here's relevant code. I m running python on Ubuntu 10.04 > > > [snip] > > > > self.list = AutoWidthListCtrl(panel)' > > This mailing list is for learning Python. Support and familiarity > with 3rd party packages is limited. You will probably be better off > asking the wxpython mailing list. Especially as the AutoWidthListCtrl > is not a widget that comes with wxpython. > > [snip] > > > > def OnResult(self, event): > > print 'onResult' > > ptf_data = event.data > > for item in ptf_data['portfolio']['items']: > > index = self.list.InsertStringItem(sys.maxint, item['ticker']) > > I believe this is the source of your problem. You are using the > incorrect value as the index. If you look at documentation for > the base class ListCtrl [0][1] you will notice that the first > argument to InsertStringItem is the insertion index. Instead you are > using the same value (sys.maxint) for all items you are inserting. > sys.maxint represents the maximum integer supported by the system > and is not relevant for what you are trying to do. Instead use an > incrementing count. > > rows = self.list.GetItemCount() > for index, item in enumerate( ptf_data['portfolio']['items'], rows ): > self.list.InsertStringItem(index, item['ticker']) > > [0]: http://wiki.wxpython.org/ListControls > [1]: http://www.wxpython.org/docs/api/wx.ListCtrl-class.html > > > self.list.SetStringItem(index, 1, item['name']) > > self.list.SetStringItem(index, 2, str(item['movingAvg200'])) > > self.list.SetStringItem(index, 3, str(item['movingAvg50'])) > > self.list.SetStringItem(index, 4, str(item['price'])) > > self.list.SetStringItem(index, 5, str(item['previous'])) > > self.list.SetStringItem(index, 6, str(item['price'] - > item['previous']) ) > > self.list.SetStringItem(index, 7, str(item['totalValue'])) > > self.list.SetStringItem(index, 8, str(item['position'])) > > > > Do let us know if the suggestion works or not. > > Ramit Prasad > > > This email is confidential and subject to important disclaimers and > conditions including on offers for the purchase or sale of > securities, accuracy and completeness of information, viruses, > confidentiality, legal privilege, and legal entity disclaimers, > available at http://www.jpmorgan.com/pages/disclosures/email. > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor