August 30th, 2005, 11:18 AM
get unique elements
my code gets data from a richedit control in another application, in the form of a list (each element is 1 line). The trouble is, it is sometimes updated more than once per second, and when it's updated, new lines are added, the original stuff stays in there.
I need to get it line by line, but every time i get the contents obviously i get a huge list containing all the original stuff, plus the extra few lines.
Is there anyway that i can compare the original copy and a new copy, and add the new lines to the original?
August 30th, 2005, 05:43 PM
I believe the easiest way to solve this kind of problem is by using Pythons set() type. However if you did want to do it another way you could use the difflib or maybe filecmp; this last module will only be really useful with data stored in a file but I thought it worth mentioning as an option .
I hope this helps,
August 31st, 2005, 05:49 AM
It might help to tell us what widget set the richedit control is written in and how the two programs are communicating.
Originally Posted by miagigaim
Do you have access to the richedit control code to make changes?
August 31st, 2005, 08:24 AM
it's another program entirely, i am using win32 functions to get handles to it's controls like it's richedit box.
Originally Posted by Grim Archon
i wonder if there is any quick win32 way to do this??
i am using the same functions to press the write buttons depending on what's in the text box. i created something like this last night:
hwnd = '102893' # handle to window
linelist = 
while len(linelist) < 30 :
tmp = getLines(hwnd) # get lines gets ALL lines into list
for i in tmp :
if i not in linelist :
I had to do the pause at the end cus otherwise it would just hang. I then copied/pasted from the edit control and compared both. Largely they were the same but there were some variations, which is where i am concerned.