omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Refresh data loaded by widget

    Pythonista
    1
    2
    1752
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • djorge
      djorge last edited by

      Hi,

      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.

      1 Reply Last reply Reply Quote 0
      • djorge
        djorge last edited by

        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)
        

        David

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors