-
Notifications
You must be signed in to change notification settings - Fork 22
/
viewer.py
55 lines (44 loc) · 1.93 KB
/
viewer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
# -*- coding: utf-8 -*-
import xbmc
import xbmcgui
from xbmcaddon import Addon
import utils
# Addon info
__addonID__ = "script.filecleaner"
__addon__ = Addon(__addonID__)
__title__ = __addon__.getAddonInfo("name")
__profile__ = xbmc.translatePath(__addon__.getAddonInfo("profile")).decode("utf-8")
class LogViewerDialog(xbmcgui.WindowXMLDialog):
"""
The LogViewerDialog class is an extension of the default windows supplied with Kodi.
It is used to display the contents of a log file, and as such uses a fullscreen window to show as much text as
possible. It also contains two buttons for trimming and clearing the contents of the log file.
"""
CAPTIONID = 201
TEXTBOXID = 202
TRIMBUTTONID = 301
CLEARBUTTONID = 302
CLOSEBUTTONID = 303
def __init__(self, xml_filename, script_path, default_skin="Default", default_res="720p", *args, **kwargs):
self.log = utils.Log()
self.caption = utils.translate(32603)
xbmcgui.WindowXMLDialog.__init__(self)
def onInit(self):
self.getControl(self.CAPTIONID).setLabel(self.caption)
self.getControl(self.TEXTBOXID).setText(self.log.get())
def onClick(self, control_id, *args):
if control_id == self.TRIMBUTTONID:
if xbmcgui.Dialog().yesno(utils.translate(32604), utils.translate(32605), utils.translate(32607)):
self.getControl(self.TEXTBOXID).setText(self.log.trim())
elif control_id == self.CLEARBUTTONID:
if xbmcgui.Dialog().yesno(utils.translate(32604), utils.translate(32606), utils.translate(32607)):
self.getControl(self.TEXTBOXID).setText(self.log.clear())
elif control_id == self.CLOSEBUTTONID:
self.close()
else:
utils.debug("Unknown button pressed", xbmc.LOGERROR)
if __name__ == "__main__":
win = LogViewerDialog("DialogLogViewer.xml", __addon__.getAddonInfo("path"))
win.doModal()
del win