Example (snipet) of progressbar
#1
Hello Scripters ....

If found this ...

http://www.xbmc.org/wiki/?title=HOW-...th_Progressbar


I would like to implement a progress bar for a ripping process ....
Has anyone a code-snippet to display the progress of a long duration copy ?
(Not from a url .... it is a local copy from dvd to rip-directory )

I have the filename to monitor including the full path
I have the finalsize in bytes it should have on the disk

The above sample shows only a url donwload ...

Has anoyone used a script with this kind of progressbar ?

Thanks
Hans
Reply
#2
progressbar is simple, just do the same as the url, only you use final filesize as maxvalue and copied bytes is the progress
Reply
#3
@linuxluemmel
The link in your post is not valid for me, but maybe have a look at this as well:

http://xbmc.sourceforge.net/python-docs/...ogProgress
http://xbmc.sourceforge.net/python-docs/

I would say loop around in your code doing what you need to do and update the progress dialog after each file? urllib.urlretrieve() allows for a reporthook function where you can update the progress in finer steps, maybe you can find one that copies data locally that has similar?

Code:
import time
import xbmcgui

dp = xbmcgui.DialogProgress()
dp.create("Copying files...")

for i in range(1, 100) :
    dp.update(i, "source\\file #%u" % i, "destination\\file #%u" % i)
    if dp.iscanceled() : break
    time.sleep(1)
Reply
#4
Dan Dare Wrote:@linuxluemmel
The link in your post is not valid for me, but maybe have a look at this as well:

http://xbmc.sourceforge.net/python-docs/...ogProgress
http://xbmc.sourceforge.net/python-docs/

I would say loop around in your code doing what you need to do and update the progress dialog after each file? urllib.urlretrieve() allows for a reporthook function where you can update the progress in finer steps, maybe you can find one that copies data locally that has similar?

Code:
import time
import xbmcgui

dp = xbmcgui.DialogProgress()
dp.create("Copying files...")

for i in range(1, 100) :
    dp.update(i, "source\\file #%u" % i, "destination\\file #%u" % i)
    if dp.iscanceled() : break
    time.sleep(1)

Thanks ...

It works perfect ..

Regards Hans
Reply
#5
I'm sure you changed the code so first it calculate the percentage increment for dp.update() based on the total number of files and then loop through the actual files... That was just a proof of concept code.

Glad it helped.
Reply
#6
Dan Dare Wrote:I'm sure you changed the code so first it calculate the percentage increment for dp.update() based on the total number of files and then loop through the actual files... That was just a proof of concept code.

Glad it helped.

Of course I did ;-)

Version 0.5H of my ripper script is allmost finished to be published ...

regards
hans
Reply
#7
linuxluemmel Wrote:Of course I did ;-)

Version 0.5H of my ripper script is allmost finished to be published ...

regards
hans

Code:
if (choice == 1):

               dp = xbmcgui.DialogProgress()
               dp.create(__language__(32042),__language__(32043))

               i1 =  size_rip /100

              
               exit = True
               while (exit):

                      iso_file = os.stat(iso)        
                      iso_size = iso_file[stat.ST_SIZE]                          
                      i2 =  iso_size  

                      progress = i2 / i1
                    
                      if (progress == 100):
                          dp.close()  
                          exit = False                      
                  dp.update(progress,__language__(32042),__language__(32043))

                  if dp.iscanceled():
                         dp.close()
                         exit = False
                         break
                  time.sleep(1)
Reply
#8
Good stuff!
Reply
#9
Dan Dare Wrote:Good stuff!

many thanks ....

Are you using 05.G ?

Expect allmost all (progress-bar / network-ripping)

Regards
Hans
Reply
#10
No, Hans, I don't do much ripping, but I see you have a few good downloads in your Google Code page Smile Good luck, man!
Reply
#11
Dan Dare Wrote:No, Hans, I don't do much ripping, but I see you have a few good downloads in your Google Code page Smile Good luck, man!

Thanks to you :-)

The download counter on my red-pill and blue pill is still ticking .... (over 500)
But sadly I have allmost no feedback from users ...
So it seems that my script is useless or at least a lot of users of my script
comes from a country in witch the use is illegal.

Best regards from switzerland
Hans
Reply
#12
Hans, I wouldn't worry much about that - these days most users don't even bother sending feedback, unless something's broken or they want more from it. Maybe add an entry in the menu with a link to where you want users to send their feedback and maybe then you get some comments... Until then, just be happy you started something that works Smile
Reply

Logout Mark Read Team Forum Stats Members Help
Example (snipet) of progressbar0