I have a python practise project. I’m going to write a GUI program which can tell you the TCP download and upload speed per process. Just like nethogs does but in Python with wxPython as GUI frontend.
The program should something look like this:
----- ---------------- ------ ------- --------
PID program name user send received
----- ---------------- ------ ------- --------
1937 firefox root 10 KB/s 50 KB/s
-------------------------------------------------
3720 wget root 0 KB/s 120 KB/s
The data shows here are just dummy ones(sorry, I can’t post images. I hard coded some data using wx.ListCtrl).
I don’t have much experience in GUI programming, so how can I add/delete one row when needed ? Say, I just close the firefox, so that row shoun’t be there anymore, or I just lanched a wget process and that should be added to the list. The send/received speed may not constant, so I also need to update the change in real time.
Do I need some event notify mechanism ? Does wx.ListCtrl can handle the real time change ?
Hope I’ve annouced my question clearly.
You’ll need to redo the ListItems. Basically that means that whenever something changes, you empty the ListCtrl and then reinsert everything minus whatever was moved. I’ve found that to be the easiest way. I use ObjectListView instead of ListCtrl whenever possible as I think it’s easier to use and update. You might find one of these articles helpful in that respect: