View Full Version : Example (snipet) of progressbar
linuxluemmel
2009-08-27, 12:10
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
progressbar is simple, just do the same as the url, only you use final filesize as maxvalue and copied bytes is the progress
Dan Dare
2009-08-28, 11:05
@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/xbmcgui.html#DialogProgress
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?
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)
linuxluemmel
2009-08-30, 21:15
@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/xbmcgui.html#DialogProgress
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?
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
Dan Dare
2009-08-30, 22:49
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.
linuxluemmel
2009-08-31, 00:31
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
linuxluemmel
2009-08-31, 00:34
Of course I did ;-)
Version 0.5H of my ripper script is allmost finished to be published ...
regards
hans
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)
Dan Dare
2009-08-31, 00:44
Good stuff!
linuxluemmel
2009-08-31, 01:22
Good stuff!
many thanks ....
Are you using 05.G ?
Expect allmost all (progress-bar / network-ripping)
Regards
Hans
Dan Dare
2009-08-31, 01:32
No, Hans, I don't do much ripping, but I see you have a few good downloads in your Google Code page :) Good luck, man!
linuxluemmel
2009-08-31, 01:40
No, Hans, I don't do much ripping, but I see you have a few good downloads in your Google Code page :) 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
Dan Dare
2009-08-31, 02:11
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 :)