[wxPython-users] Save updated lines in List control to a file
Werner F. Bruhin
werner.bruhin at free.fr
Thu Jul 12 05:14:54 PDT 2007
Hi Johan,
Johan Geldenhuys wrote:
> Hi all,
>
> I have a list control view that gets updated when the keys of a
> dictionary change. Every time the keys change, there is a new line
> created in my list control view with each key in it's own column.
> The dictionary is cleared every time it was written to the list
> control view.
>
> What I want to do is to get all lines in my list control view with the
> associated column data, and save that to a csv file when a menu item
> is chosen. My code currently knows when the menu item is selected. All
> I need to do is to get the items from my list control and save them to
> a file.
>
> How do I do that, please ???
A very good tool/reference to see how things are done in wxPython is the
demo, if you check the one for the listctrl you will see this:
def OnItemSelected(self, event):
##print event.GetItem().GetTextColour()
self.currentItem = event.m_itemIndex
self.log.WriteText("OnItemSelected: %s, %s, %s, %s\n" %
(self.currentItem,
self.list.GetItemText(self.currentItem),
self.getColumnText(self.currentItem, 1),
self.getColumnText(self.currentItem, 2)))
So, just replace the WriteText with the routine you use to write to your
CSV file.
Werner
More information about the wxpython-users
mailing list