How to set up the calculate progress - Printable Version +- Kodi Community Forum (https://forum.kodi.tv) +-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32) +--- Forum: Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=26) +--- Thread: How to set up the calculate progress (/showthread.php?tid=198123) |
How to set up the calculate progress - coolguy145 - 2014-06-17 Hello, I need some help with my code, I want to to set up the calculate progress from 0% to 100% for the label control to see how far I'm going when I send the request to url to get the response and then to store the data in a database. Here is the label control that i want to use: Code: main_loading_time_left = 4202 Here is the code: Code: #DOWNLOAD THE XML SOURCE HERE Does anyone know how I can use the label control `main_loading_time_left` to set up the calculate progress that start from 0% to 100% when I send the request to the url to get the response and then store the data into the database? Thanks in advance RE: How to set up the calculate progress - coolguy145 - 2014-06-19 24 hours and no one is reply, does anyone know how I can use the label to display the progress? RE: How to set up the calculate progress - el_Paraguayo - 2014-06-19 Firstly, there's no rule that people need to reply to your post within a certain time, so please don't get impatient.. Secondly, I've read your post three times now and I still haven't got a clue what you're trying to do. RE: How to set up the calculate progress - coolguy145 - 2014-06-19 I understand what you are saying but I would like to get this done asap. I would like to apology for being impatient. Ok, what I'm trying to do is I want to set up the progress dialog like start from 0%, 2%, 4%, 6%, 8% and so on until when it finish it will be 100%. Hope you get what I mean? The label control I want to use to set up the progress dialog using the variable id is main_loading_time_left. RE: How to set up the calculate progress - Martijn - 2014-06-19 first create the dialog http://mirrors.xbmc.org/docs/python-docs/13.0-gotham/xbmcgui.html#DialogProgressBG-create then start updating it http://mirrors.xbmc.org/docs/python-docs/13.0-gotham/xbmcgui.html#DialogProgressBG-update after done, close it http://mirrors.xbmc.org/docs/python-docs/13.0-gotham/xbmcgui.html#DialogProgressBG-close This uses the background dialog so you can continue using XBMC. For the blocking dialog, use http://mirrors.xbmc.org/docs/python-docs/13.0-gotham/xbmcgui.html#DialogProgress RE: How to set up the calculate progress - coolguy145 - 2014-06-19 Thank you Martijn. How I can use the variable of main_loading_time_left to work with the progress dialog and the urllib2? Here is the one I want to use: Code: main_loading_time_left = 4202 RE: How to set up the calculate progress - el_Paraguayo - 2014-06-20 Maybe I'm being stupid but I don't see anything in your code that links that variable to the progress of your download. You need to work that out first (which isn't an xbmc issue) and then use the progress dialog to display the progress. RE: How to set up the calculate progress - coolguy145 - 2014-06-20 Well I am sure you know what I want to achieve. Sorry for confused you, but I'm set up the label text and I want to call the setLabel with the percent string. When I try this: Code: percent = 1 I'm getting an error: TypeError: unsupported operand type(s) for +: 'float' and 'str' The error are jumping on this line: Code: self.getControl(4202).setLabel(secondsLeft + "%") I don't understand why I'm getting an error. Do you know why I'm getting the error and do you know how to fix it? RE: How to set up the calculate progress - pkscout - 2014-06-21 secondsLeft is a float, and "%" is a string. You can't concatenate a float and a string. If you don't need any of the decimal points, I think you can just do str(secondsLef) + "%". If you want to get that into something like 98.22%, I think you may have to do a little googling. RE: How to set up the calculate progress - coolguy145 - 2014-06-21 Thank you for your help pkscuot. I have a little trouble with updating the percent in a setLabel function. It can only be updating once the value is set in the label. This is where I'm stuck at right now: Code: #DOWNLOAD THE XML SOURCE HERE If there is possible to updating the setLabel function more than once, I would love to know how RE: How to set up the calculate progress - el_Paraguayo - 2014-06-21 Sorry, I think it was me who may have been unclear. My confusion was that I didn't see anything in your code that calculated how much of the download was remaining. That code you referred to is a loop that just counts to 10 and has nothing to do with the state of your download. Once you've worked out how you're calculating the progress, we can then tell you how to implement it into your code. E.g. if the relevant progress based on the number of programmes you've processed? RE: How to set up the calculate progress - coolguy145 - 2014-06-21 That's okay. Yes, I want to counts to 10 in the loop, but the trouble is it will only allow me to update the value in the setLabel function only once at a time. If you know a way how to update the values in the setLabel function with counting the number to 10, I will be very grateful RE: How to set up the calculate progress - el_Paraguayo - 2014-06-22 ok - but counting to 10 against what? Sorry, if I'm being dumb - but I just don't see the point of sticking in an arbitrary counting to 10. The progress bar should be meaningful, i.e. if your xml file has 100 programmes, then I'd base the status text on how many of those 100 programmes had been processed. |