[python] ensure we lock the GUI prior to calling ClearItems. Fixes #14780
Merge pull request #4370 from jmarshallnz/clear_items_fix

[python] ensure we lock the GUI prior to calling ClearItems. Fixes #14780