import xbmcgui

class TaskListWindow(xbmcgui.Window):
    X_TITLE = 190
    X_STATUS = 800
    X_PERCENT = 980

    def add_headers(self):
        self.addControl(xbmcgui.ControlLabel(
            x=TaskListWindow.X_TITLE, y=25, width=600, height=50, label='Title'))
        self.addControl(xbmcgui.ControlLabel(
            x=TaskListWindow.X_STATUS, y=25, width=150, height=50, label='Status'))
        self.addControl(xbmcgui.ControlLabel(
            x=TaskListWindow.X_PERCENT, y=25, width=150, height=50, label='Percentage'))

    def add_tasks(self, taskList):
        y = 75
        for task in taskList:
            y += 30
            percent = self.__get_download_percent_label(task)
            self.addControl(xbmcgui.ControlLabel(
                x=TaskListWindow.X_TITLE, y=y, width=600, height=25, label=task['title']))
            self.addControl(xbmcgui.ControlLabel(
                x=TaskListWindow.X_STATUS, y=y, width=150, height=25, label=task['status']))
            self.addControl(xbmcgui.ControlLabel(
                x=TaskListWindow.X_PERCENT, y=y, width=150, height=25, label=percent))

    def __get_download_percent_label(self, task):
        if task['size'] == 0:
            return '0%'
        downloaded = task['additional']['transfer']['size_downloaded']
        percent = 100 * float(downloaded) / float(task['size'])
        return "%.2f" % percent + '%'

@@ -19,38 +19,13 @@
 ass 
-TaskListWindow(xbmcgui.Window)
+Sizes
 :%0A  
@@ -88,401 +88,727 @@
     
-def add_headers(self):%0A        self.addControl(xbmcgui.ControlLabel(%0A            x=TaskListWindow.X_TITLE, y=25, width=600, height=50, label='Title'))%0A        self.addControl(xbmcgui.ControlLabel(%0A            x=TaskListWindow.X_STATUS, y=25, width=150, height=50, label='Status'))%0A        self.addControl(xbmcgui.ControlLabel(%0A            x=TaskListWindow.X_PERCENT, y=25, width=150, height=50
+Y_HEADER = 25%0A    Y_HEADER_MARGIN = 75%0A    Y_TASK_MARGIN = 30%0A%0A    WIDTH_TITLE = 600%0A    WIDTH_STATUS = 150%0A    WIDTH_PERCENT = 150%0A%0A    HEIGHT_HEADER = 50%0A    HEIGHT_TASK = 25%0A%0Aclass TaskListWindow(xbmcgui.Window):%0A%0A    def add_headers(self):%0A        self.addControl(xbmcgui.ControlLabel(%0A            x=Sizes.X_TITLE, y=Sizes.Y_HEADER, width=Sizes.WIDTH_TITLE, height=Sizes.HEIGHT_HEADER, label='Title'))%0A        self.addControl(xbmcgui.ControlLabel(%0A            x=Sizes.X_STATUS, y=Sizes.Y_HEADER, width=Sizes.WIDTH_STATUS, height=Sizes.HEIGHT_HEADER, label='Status'))%0A        self.addControl(xbmcgui.ControlLabel(%0A            x=Sizes.X_PERCENT, y=Sizes.Y_HEADER, width=Sizes.WIDTH_PERCENT, height=Sizes.HEIGHT_HEADER
 , la
@@ -874,18 +874,37 @@
     y = 
-75
+Sizes.Y_HEADER_MARGIN
 %0A       
@@ -947,15 +947,101 @@
  += 
-30%0A    
+Sizes.Y_TASK_MARGIN%0A            self.__add_task(task, y)%0A%0A    def __add_task(self, task, y):%0A
     
@@ -1094,20 +1094,16 @@
 l(task)%0A
-    
         
@@ -1152,36 +1152,23 @@
         
-    x=TaskListWindow
+x=Sizes
 .X_TITLE
@@ -1184,22 +1184,51 @@
 dth=
-600, height=25
+Sizes.WIDTH_TITLE, height=Sizes.HEIGHT_TASK
 , la
@@ -1243,28 +1243,24 @@
 %5B'title'%5D))%0A
-    
         self
@@ -1305,36 +1305,23 @@
         
-    x=TaskListWindow
+x=Sizes
 .X_STATU
@@ -1330,38 +1330,68 @@
  y=y, width=
-150, height=25
+Sizes.WIDTH_STATUS, height=Sizes.HEIGHT_TASK
 , label=task
@@ -1399,28 +1399,24 @@
 'status'%5D))%0A
-    
         self
@@ -1465,28 +1465,15 @@
     
-    x=TaskListWindow
+x=Sizes
 .X_P
@@ -1495,22 +1495,53 @@
 dth=
-150, height=25
+Sizes.WIDTH_PERCENT, height=Sizes.HEIGHT_TASK
 , la

Refactor GUI