2011-08-05, 09:17
Hello,
I've created my own progress control because I need two progress bars. For this I use the windowXMLDialog and run into courios behaviours. If I use windowXMLDialog.doModal() all events would be triggered (onAction, onClick etc.) but would lost when I use window.XMLDialog.show() instead.
and here we go:
I need .show() instead of .doModal() otherwise the progress bars aren't updated. But I lost any interaction with the window and I can't close it. Why?
_BJ1
I've created my own progress control because I need two progress bars. For this I use the windowXMLDialog and run into courios behaviours. If I use windowXMLDialog.doModal() all events would be triggered (onAction, onClick etc.) but would lost when I use window.XMLDialog.show() instead.
Code:
CAPTION = 30401
PROCESS_LABEL = 30402
PROGRESS_1 = 30404
PROGRESS_TOTAL = 30405
CLOSE_BUTTON = 30406
CANCEL_DIALOG = ( 7, 9, 10, 11, 92, 216, 247, 257, 275, 61467, 61448, )
class ProgressInfo(xbmcgui.WindowXMLDialog):
def __init__( self, *args, **kwargs ):
xbmcgui.WindowXML.__init__(self)
def onInit( self ):
print 'onInit triggered'
self.initialize()
def initialize(self):
self.closeButton = self.getControl(CLOSE_BUTTON)
self.getControl(CAPTION).setLabel(__getLS__(30005))
self.getControl(PROCESS_LABEL).setLabel(__getLS__(30011))
self.getControl(CLOSE_BUTTON).setLabel(__getLS__(30012))
self.setProperty('isCanceled', 'False')
def update(self, progress_1, progress_2, info):
self.getControl(PROCESS_LABEL).setLabel(info)
self.getControl(PROGRESS_1).setPercent(progress_1)
self.getControl(PROGRESS_TOTAL).setPercent(progress_2)
def onClick(self, controlId):
print 'Control-ID: ' + str(controlId)
self.setProperty('isCanceled', 'True')
def onFocus(self, controlId):
self.controlId = controlId
def onAction(self, action):
self.setProperty('isCanceled', 'True')
print 'Action-ID: ' + str(action)
if (action in CANCEL_DIALOG):
self.close()
def onControl(self, control):
print "onControl triggered"
and here we go:
Code:
progress = ProgressInfo( "script-Backup_Progress.xml" , __cwd__, "Default")
progress.show()
progress.initialize()
#progress.doModal()
while not progress.getProperty('isCanceled') == 'True':
# do some operations and update progressbars
# setProperty('isCanceled', 'True') if all operations are done
time.sleep(1)
progress.close()
del progress
I need .show() instead of .doModal() otherwise the progress bars aren't updated. But I lost any interaction with the window and I can't close it. Why?
_BJ1