dialog = xbmcgui.Dialog() path = dialog.browse(1, 'Select file', 'video', '.avi|.mkv|.mp4')  <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <addon id="script.test.buttons" name="Buttons test script" version="0.0.1" provider-name="Roman_V_M"> <requires> <import addon="xbmc.python" version="2.0"/> </requires> <extension point="xbmc.python.script" library="default.py"> <provides>executable</provides> </extension> <extension point="xbmc.addon.metadata"> <platform>all</platform> <summary lang="en">Buttons test script</summary> <description lang="en">My buttons test script.</description> </extension> </addon>  # -*- coding: utf-8 -*- # Licence: GPL v.3 http://www.gnu.org/licenses/gpl.html #    . import os, sys #   XBMC. import xbmcgui, xbmcaddon #    Addon     . #     xbmcaddon.Addon()   , #     . _addon = xbmcaddon.Addon() #    . _addon_path = _addon.getAddonInfo('path').decode(sys.getfilesystemencoding()) #   . ACTION_PREVIOUS_MENU = 10 # Esc ACTION_NAV_BACK = 92 # Backspace #   . ALIGN_CENTER = 6 #      : # ; background_img = os.path.join(_addon_path, 'images', 'SKINDEFAULT.jpg') #    ; button_nf_img = os.path.join(_addon_path, 'images', 'KeyboardKeyNF.png') #    ; button_fo_img = os.path.join(_addon_path, 'images', 'KeyboardKey.png') #      :-). banana_img = os.path.join(_addon_path, 'images', 'banana.gif') class MyAddon(xbmcgui.Window): def __init__(self): #   . background = xbmcgui.ControlImage(1, 1, 1280, 720, background_img) self.addControl(background) #    . banana_picture = xbmcgui.ControlImage(500, 200, 256, 256, banana_img) self.addControl(banana_picture) #    (). self.set_controls() #    . self.set_navigation() def set_controls(self): #  "". self.privet_btn = xbmcgui.ControlButton(500, 500, 110, 40, u'…', focusTexture=button_fo_img, noFocusTexture=button_nf_img, alignment=ALIGN_CENTER) self.addControl(self.privet_btn) #  "". self.exit_btn = xbmcgui.ControlButton(650, 500, 110, 40, u'', focusTexture=button_fo_img, noFocusTexture=button_nf_img, alignment=ALIGN_CENTER) self.addControl(self.exit_btn) def set_navigation(self): #      "". self.privet_btn.controlRight(self.exit_btn) self.privet_btn.controlLeft(self.exit_btn) #      "". self.exit_btn.controlRight(self.privet_btn) self.exit_btn.controlLeft(self.privet_btn) #      "". self.setFocus(self.privet_btn) def onAction(self, action): #       . if action == ACTION_NAV_BACK or action == ACTION_PREVIOUS_MENU: self.close() def onControl(self, control): #   . #    ""... if control == self.privet_btn: # ...            .Dialog().ok(). xbmcgui.Dialog().ok(u', !', u'    :-)') #    "",   . elif control == self.exit_btn: self.close() if __name__ == '__main__': addon = MyAddon() addon.doModal() del addon 

 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <addon id="script.test.buttons.alt" name="Buttons test script - Dialog" version="0.0.1" provider-name="Roman_V_M"> <requires> <import addon="xbmc.python" version="2.0"/> </requires> <extension point="xbmc.python.script" library="default.py"> <provides>executable</provides> </extension> <extension point="xbmc.addon.metadata"> <platform>all</platform> <summary lang="en">Buttons test script</summary> <description lang="en">My buttons test script.</description> </extension> </addon>  # -*- coding: utf-8 -*- # Licence: GPL v.3 http://www.gnu.org/licenses/gpl.html #    . import os, sys #   XBMC. import xbmcgui, xbmcaddon #    Addon     . #     xbmcaddon.Addon()   , #     . _addon = xbmcaddon.Addon() #    . _addon_path = _addon.getAddonInfo('path').decode(sys.getfilesystemencoding()) #   . ACTION_PREVIOUS_MENU = 10 # Esc ACTION_NAV_BACK = 92 # Backspace #   . ALIGN_CENTER = 6 #      : # ; background_img = os.path.join(_addon_path, 'images', 'ContentPanel.png') #    ; button_nf_img = os.path.join(_addon_path, 'images', 'KeyboardKeyNF.png') #    ; button_fo_img = os.path.join(_addon_path, 'images', 'KeyboardKey.png') #      :-). banana_img = os.path.join(_addon_path, 'images', 'banana.gif') class MyAddon(xbmcgui.WindowDialog): def __init__(self): #   . background = xbmcgui.ControlImage(370, 100, 500, 500, background_img) self.addControl(background) #    . banana_picture = xbmcgui.ControlImage(500, 200, 256, 256, banana_img) self.addControl(banana_picture) #    (). self.set_controls() #    . self.set_navigation() def set_controls(self): #  "". self.privet_btn = xbmcgui.ControlButton(500, 500, 110, 40, u'…', focusTexture=button_fo_img, noFocusTexture=button_nf_img, alignment=ALIGN_CENTER) self.addControl(self.privet_btn) #  "". self.exit_btn = xbmcgui.ControlButton(650, 500, 110, 40, u'', focusTexture=button_fo_img, noFocusTexture=button_nf_img, alignment=ALIGN_CENTER) self.addControl(self.exit_btn) def set_navigation(self): #      "". self.privet_btn.controlRight(self.exit_btn) self.privet_btn.controlLeft(self.exit_btn) #      "". self.exit_btn.controlRight(self.privet_btn) self.exit_btn.controlLeft(self.privet_btn) #      "". self.setFocus(self.privet_btn) def onAction(self, action): #       . if action == ACTION_NAV_BACK or action == ACTION_PREVIOUS_MENU: self.close() def onControl(self, control): #   . #    ""... if control == self.privet_btn: # ...            xbmcgui.Dialog().ok(). xbmcgui.Dialog().ok(u', !', u'    :-)') #    "",   . elif control == self.exit_btn: self.close() if __name__ == '__main__': addon = MyAddon() addon.doModal() del addon 
Source: https://habr.com/ru/post/194124/
All Articles