<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def OnPreferences(self, event):
 """Preferences event handler that launches preferences dialog"""


        preferences = self.interfaces.get_preferences_from_user()

        if preferences:
            for key in preferences:
                if type(config[key]) in (type(u""), type("")):
                    config[key] = preferences[key]
                else:
                    config[key] = ast.literal_eval(preferences[key])

        self.main_window.grid.grid_renderer.cell_cache.clear()
        self.main_window.grid.ForceRefresh()