1

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.

2 Answers2

1

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.

VZ.
  • 21,740
  • 3
  • 39
  • 42
  • Tx, I looked at virtual, it can work. But I wanted something to print my data live without pushing it into data container so wx enumerates through it when ever it likes. How do you implement a clock counter or data transfer rate or progress rate .... inside list cell. I just want to print my data stream live. – user2830194 Mar 28 '14 at 12:07
0

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();
}