Refresh data loaded by widget
What is the best way to update the content load by a widget?
Let me explain:
I have a script that parses a pdf file and creates a file with data that is then loaded by my widget.
Whenever a receive a newer pdf file I parse it but I need to refresh my widget with the new data.
What I am doing is:
def refresh_data(self,sender): shelve_file = shelve.open('data') dia = shelve_file['dia'] v = appex.get_widget_view() v = EmentaView(dia)
When this code is executed I get a message ‘could not load’, then I tap again the widget ant it refreshes the data.
In the end my widget appear refreshed but this is not the correct way due to the error message.
Solved my problem.
Added a new method to set the new data to existing widget.
My update view method is the one that uses the new data.
def set_data(self,new_data): self.dia= new_data self.update_view() def refresh_data(self,sender): shelve_file = shelve.open('data') dia = shelve_file['dia'] self.set_data(dia)