Port pyQode/pyqode.widgets#7 to pyqode.core

(because of #42)