Reputation: 11
I want to update list's row or grid's cell in wxwidgets using a loop or with a callback function which is called 10 times in a second. But app waits until the last run of the loop and then shows the last value. I tried refresh() and ForceRefresh() but it doesn't work. how can I achieve this?
for(int i=0; i< 30000; i++) {
list->SetItem(itemIndex, 0, wxString::Format(wxT("%i"),i));
//grid->SetCellValue( 0, 0, wxString::Format(wxT("%i"),i));
}
Edit: What I mean is outputting(printing, streaming) data live like a clock counter or printing progress rate. Using virtual style also does not update it often enough.
Upvotes: 1
Views: 907
Reputation: 11
Well I got the complete answer from wxWidgets IRC. I should have refreshed before updating.
for(int i=0; i< 30000; i++) {
list->SetItem(itemIndex, 0, wxString::Format(wxT("%i"),i));
//grid->SetCellValue( 0, 0, wxString::Format(wxT("%i"),i));
MyFrame::Refresh();
MyFrame::Update();
}
Upvotes: 0
Reputation: 22753
I'm not sure what is list
and grid
in your code but in any case, this is not how you should be doing it. There is no chance that 30000 items fit on your screen at once, so why set the values of all of them? Instead, use a "virtual" wxListCtrl
, i.e. with wxLC_VIRTUAL
style, or (always "virtual") wxGrid
or wxDataViewCtrl
and just update your data and refresh the items after they change. The GUI control will take care of showing the updated values of visible items only as fast as it can.
Upvotes: 1