Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    update GeDialog while download [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 463 Views
    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.
    • H Offline
      Helper
      last edited by

      On 24/11/2014 at 13:14, xxxxxxxx wrote:

      hey I try to set a progress while downloading a file

        
      u = urlopen('http:/url/'+filename)
      ...
        
      while True:
      	...
      	self.SetString(1014,message)
      	self.LayoutChanged(1009)
      

      It update the dialog after the full download of the file .

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 25/11/2014 at 02:34, xxxxxxxx wrote:

        Hello,

        without knowing in which context you are using the above code it is hard to say anything. There are differences in PC and Mac when it comes to redrawing dialogs, please see this thread.

        So the most sophisticated solution would be to handle the download in a separate C4DThread[URL-REMOVED]. There you could use SpecialEventAdd()[URL-REMOVED] to trigger the redraw of the dialog.

        best wishes,
        Sebastian


        [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 26/11/2014 at 04:53, xxxxxxxx wrote:

          Hello Sebastian,

          thanks for you reply - I try that :

          class RB_Client(c4d.threading.C4DThread) :
                      
                      def Main(self) :
                          
                          u = urlopen('url')
                          ...
            
                              while True:
                                  buffer = u.read(block_size)
                                  if not buffer:
                                      break
                                  message2 = str(round(float(downloaded_bytes)/file_size*100-0.5))+" %"
                                  UpdaterDialog.progressmessage = message2
                                  c4d.SpecialEventAdd(betaupdatefunction_ID)
                              f.close()
                          
                          pass
                          
                  Cthread = RB_Client()
                  Cthread.Start(mode=c4d.THREADMODE_ASYNC, priority=c4d.THREADPRIORITY_NORMAL)
                  
                  Cthread.Wait(False)
            
           def CoreMessage(self, id, msg) :
                    if id==betaupdatefunction_ID:
                        self.SetString(1005,self.progressmessage)
                        self.LayoutChanged(1006)
                        return True
                    return gui.GeDialog.CoreMessage(self, id, msg)
            
          
          

          the dialog refresh after the end of the function not during the while

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 27/11/2014 at 02:23, xxxxxxxx wrote:

            Hello,

            maybe your thread works too fast for Cinema to send the messages. You could add a sleep() call from the time lib in your while loop to give Cinema a chance to send the message.

            Alternatively you can use SetTimer()[URL-REMOVED] and Timer()[URL-REMOVED] in your GeDialog so the dialog will update continuously independent from any thread message.

            Best wishes,
            Sebastian


            [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 05/12/2014 at 08:24, xxxxxxxx wrote:

              Hello conner,
              was your question answered?
              best wishes,
              Sebastian

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 06/12/2014 at 07:55, xxxxxxxx wrote:

                yes thanks

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post