I'm using an OLV with a checked column (I do an initial import, show the user the list, let her select which items to continue with - you know the drill.) I wanted to add the option to quickly check or uncheck everything; this is what I came up with:
if (btn == "Check All"):
self.oLV.SelectAll()
for item in self.oLV.GetSelectedObjects():
self.oLV.Check(item)
self.oLV.RefreshObject(item)
if (btn == "Uncheck All"): #
for item in self.oLV.GetCheckedObjects():
self.oLV.Uncheck(item)
self.oLV.RefreshObject(item)
Basically I was wondering whether there was a more efficient way to go about it - do I really have to SelectAll? Is it necessary to do the "for item in...", or can I check/uncheck multiple objects in one call?
For that matter, is there a GetObjects() or some such?
Hope I'm not asking hopelessly dumb questions here... Again, thanks for a great control!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In SourceForge forums, you can't preserve the indentation :( It is preserved in the email notifications that are sent, so I saw the indentation that you intended.
Regards,
Phillip
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You don't need the SelectAll(), but there isn't really a more efficient way of doing this.
The only slight improvements look like this:
if (btn == "Check All"):
unchecked = [x for x in self.oLV.modelObjects if not self.oLV.IsChecked(x) ]
for item in unchecked :
self.oLV.Check(item)
self.oLV.RefreshObject(unchecked)
if (btn == "Check All"):
checked = self.GetCheckedObjects()
for item in checked:
self.oLV.Uncheck(item)
self.oLV.RefreshObject(checked)
I'll have to think about CheckObjects()/UncheckObjects() methods for the next version.
Regards,
Phillip
BTW: This is the forum for the .NET version of the control. The Python forum is for the python version of ObjectListView.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
was what I was looking for and not finding... I didn't think it should be necessary to "select all" to get a list of objects, but I couldn't see any other way. This is much nicer!
By the way - my original concept was to put a small checkbox in the header of the check column - Yahoo Mail uses this look - but that doesn't allow me to sort by checked/unchecked status. Thoughts?
Also by the way - point taken about this being the wrong forum - just thought I'd finish the thought where it started. Again, thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using an OLV with a checked column (I do an initial import, show the user the list, let her select which items to continue with - you know the drill.) I wanted to add the option to quickly check or uncheck everything; this is what I came up with:
if (btn == "Check All"):
self.oLV.SelectAll()
for item in self.oLV.GetSelectedObjects():
self.oLV.Check(item)
self.oLV.RefreshObject(item)
if (btn == "Uncheck All"): #
for item in self.oLV.GetCheckedObjects():
self.oLV.Uncheck(item)
self.oLV.RefreshObject(item)
Basically I was wondering whether there was a more efficient way to go about it - do I really have to SelectAll? Is it necessary to do the "for item in...", or can I check/uncheck multiple objects in one call?
For that matter, is there a GetObjects() or some such?
Hope I'm not asking hopelessly dumb questions here... Again, thanks for a great control!
Hmmm... my indentation got eaten...
How can I preserve indentation in code that I post in this forum?
In SourceForge forums, you can't preserve the indentation :( It is preserved in the email notifications that are sent, so I saw the indentation that you intended.
Regards,
Phillip
Hi Marc,
You don't need the SelectAll(), but there isn't really a more efficient way of doing this.
The only slight improvements look like this:
if (btn == "Check All"):
unchecked = [x for x in self.oLV.modelObjects if not self.oLV.IsChecked(x) ]
for item in unchecked :
self.oLV.Check(item)
self.oLV.RefreshObject(unchecked)
if (btn == "Check All"):
checked = self.GetCheckedObjects()
for item in checked:
self.oLV.Uncheck(item)
self.oLV.RefreshObject(checked)
I'll have to think about CheckObjects()/UncheckObjects() methods for the next version.
Regards,
Phillip
BTW: This is the forum for the .NET version of the control. The Python forum is for the python version of ObjectListView.
Thanks, Phillip!
This:
self.oLV.modelObjects
was what I was looking for and not finding... I didn't think it should be necessary to "select all" to get a list of objects, but I couldn't see any other way. This is much nicer!
By the way - my original concept was to put a small checkbox in the header of the check column - Yahoo Mail uses this look - but that doesn't allow me to sort by checked/unchecked status. Thoughts?
Also by the way - point taken about this being the wrong forum - just thought I'd finish the thought where it started. Again, thanks!
There are always mistakes :(
The RefreshObject() calls in my code should be RefreshObjects()!
Phillip