def onClick(self):
     proxy = self.proxy()
     if proxy:
         self.dialog = SelectDialog(self.attribs['widget_label'],
                                    self.attribs['widget_mapping'].itervalues(),
                                    get_item_index(self.attribs['widget_mapping'].keys(),
                                                   self.attribs['item_state']))
         pos = self.dialog.show()
         self.dialog = None
         if pos is not None:
             (state, value) = self.attribs['widget_mapping'].items()[pos]
             proxy.cmd_set(state)
 def onClick(self):
     proxy = self.proxy()
     if proxy:
         selections = list(reversed(list(drange(self.attribs['widget_min_value'],
                                                self.attribs['widget_max_value'],
                                                self.attribs['widget_step']))))
         self.dialog = SelectDialog(self.attribs['widget_label'],
                                    [str(x) for x in selections],
                                    get_item_index(selections, self.attribs['item_state']))
         pos = self.dialog.show()
         self.dialog = None
         if pos is not None:
             proxy.cmd_set(selections[pos])
Esempio n. 3
0
class TestSelectDialog(object):
    """
    Test runner for SelectDialog.
    """

    def __init__(self):
        self.items = (
            {'enabled': True,  'name': 'item1', 'desc': 'desc1'},
            {'enabled': False, 'name': 'item2'                 },
            {'enabled': True,                   'desc': 'desc3'},
            {                  'name': 'item4', 'desc': 'desc4'},
            {'enabled': True,  'name': 'item5', 'desc': ''     },
            {'enabled': False, 'name': '',      'desc': 'desc6'},
        )
        self.dialog = SelectDialog(self.items, title='Test runner', message='Select the items you want:')
        self.dialog.connect('item-enabled',   self._on_dialog_action, 'Enabled')
        self.dialog.connect('item-disabled',  self._on_dialog_action, 'Disabled')
        self.dialog.connect('item-selected',  self._on_dialog_action, 'Selected')
        self.dialog.connect('selection-done', self._on_dialog_action, 'Selection done')

    def run(self):
        self.dialog.run()

    def _on_dialog_action(self, dialog, item, action):
        print '%s: %s' % (action, item)
Esempio n. 4
0
class TestSelectDialog(object):
    """
    Test runner for SelectDialog.
    """
    def __init__(self):
        self.items = (
            {
                'enabled': True,
                'name': 'item1',
                'desc': 'desc1'
            },
            {
                'enabled': False,
                'name': 'item2'
            },
            {
                'enabled': True,
                'desc': 'desc3'
            },
            {
                'name': 'item4',
                'desc': 'desc4'
            },
            {
                'enabled': True,
                'name': 'item5',
                'desc': ''
            },
            {
                'enabled': False,
                'name': '',
                'desc': 'desc6'
            },
        )
        self.dialog = SelectDialog(self.items,
                                   title='Test runner',
                                   message='Select the items you want:')
        self.dialog.connect('item-enabled', self._on_dialog_action, 'Enabled')
        self.dialog.connect('item-disabled', self._on_dialog_action,
                            'Disabled')
        self.dialog.connect('item-selected', self._on_dialog_action,
                            'Selected')
        self.dialog.connect('selection-done', self._on_dialog_action,
                            'Selection done')

    def run(self):
        self.dialog.run()

    def _on_dialog_action(self, dialog, item, action):
        print '%s: %s' % (action, item)
 def onClick(self):
     proxy = self.proxy()
     if proxy:
         selection = [ADDON.getLocalizedString(30202),
                      ADDON.getLocalizedString(30203),
                      ADDON.getLocalizedString(30204)]
         self.dialog = SelectDialog(self.attribs['widget_label'], selection, 1)
         pos = self.dialog.show()
         self.dialog = None
         if pos is not None:
             if pos == 0:
                 proxy.cmd_up()
             elif pos == 1:
                 proxy.cmd_stop()
             elif pos == 2:
                 proxy.cmd_down()
class ListItemRollerShutter(ListItemWithValue):
    def __init__(self, proxy):
        super(ListItemRollerShutter, self).__init__("text", proxy)
        self.set_show_next_icon(True)
        self.dialog = None

    def onAction(self, action):
        proxy = self.proxy()
        if proxy:
            if action.getId() == xbmcgui.ACTION_CHANNEL_DOWN:
                proxy.cmd_down()
            elif action.getId() == xbmcgui.ACTION_CHANNEL_UP:
                proxy.cmd_up()
            elif action.getId() == xbmcgui.ACTION_STOP:
                proxy.cmd_stop()
            elif action.getId() == xbmcgui.ACTION_PLAY:
                proxy.cmd_move()

    def onClick(self):
        proxy = self.proxy()
        if proxy:
            selection = [ADDON.getLocalizedString(30202),
                         ADDON.getLocalizedString(30203),
                         ADDON.getLocalizedString(30204)]
            self.dialog = SelectDialog(self.attribs['widget_label'], selection, 1)
            pos = self.dialog.show()
            self.dialog = None
            if pos is not None:
                if pos == 0:
                    proxy.cmd_up()
                elif pos == 1:
                    proxy.cmd_stop()
                elif pos == 2:
                    proxy.cmd_down()
class ListItemSelection(ListItemWithValue):
    def __init__(self, proxy):
        super(ListItemSelection, self).__init__("text", proxy)
        self.set_show_next_icon(True)
        self.dialog = None

    def update(self, changed, deleted):
        super(ListItemSelection, self).update(changed, deleted)
        if self.dialog:
            if 'widget_label' in changed:
                self.dialog.set_title(changed['widget_label'])
            if 'widget_mapping' in changed:
                self.dialog.set_items(changed['widget_mapping'].itervalues())
            if 'item_state' in changed:
                self.dialog.set_index(get_item_index(self.attribs['widget_mapping'].keys(),
                                                     self.attribs['item_state']))

    def onClick(self):
        proxy = self.proxy()
        if proxy:
            self.dialog = SelectDialog(self.attribs['widget_label'],
                                       self.attribs['widget_mapping'].itervalues(),
                                       get_item_index(self.attribs['widget_mapping'].keys(),
                                                      self.attribs['item_state']))
            pos = self.dialog.show()
            self.dialog = None
            if pos is not None:
                (state, value) = self.attribs['widget_mapping'].items()[pos]
                proxy.cmd_set(state)
Esempio n. 8
0
 def __init__(self):
     self.items = (
         {
             'enabled': True,
             'name': 'item1',
             'desc': 'desc1'
         },
         {
             'enabled': False,
             'name': 'item2'
         },
         {
             'enabled': True,
             'desc': 'desc3'
         },
         {
             'name': 'item4',
             'desc': 'desc4'
         },
         {
             'enabled': True,
             'name': 'item5',
             'desc': ''
         },
         {
             'enabled': False,
             'name': '',
             'desc': 'desc6'
         },
     )
     self.dialog = SelectDialog(self.items,
                                title='Test runner',
                                message='Select the items you want:')
     self.dialog.connect('item-enabled', self._on_dialog_action, 'Enabled')
     self.dialog.connect('item-disabled', self._on_dialog_action,
                         'Disabled')
     self.dialog.connect('item-selected', self._on_dialog_action,
                         'Selected')
     self.dialog.connect('selection-done', self._on_dialog_action,
                         'Selection done')
Esempio n. 9
0
 def __init__(self):
     self.items = (
         {'enabled': True,  'name': 'item1', 'desc': 'desc1'},
         {'enabled': False, 'name': 'item2'                 },
         {'enabled': True,                   'desc': 'desc3'},
         {                  'name': 'item4', 'desc': 'desc4'},
         {'enabled': True,  'name': 'item5', 'desc': ''     },
         {'enabled': False, 'name': '',      'desc': 'desc6'},
     )
     self.dialog = SelectDialog(self.items, title='Test runner', message='Select the items you want:')
     self.dialog.connect('item-enabled',   self._on_dialog_action, 'Enabled')
     self.dialog.connect('item-disabled',  self._on_dialog_action, 'Disabled')
     self.dialog.connect('item-selected',  self._on_dialog_action, 'Selected')
     self.dialog.connect('selection-done', self._on_dialog_action, 'Selection done')
Esempio n. 10
0
class ListItemSetPoint(ListItemWithValue):
    def __init__(self, proxy):
        super(ListItemSetPoint, self).__init__("text", proxy)
        self.set_show_next_icon(True)
        self.dialog = None

    def update(self, changed, deleted):
        super(ListItemSetPoint, self).update(changed, deleted)
        if self.dialog:
            if 'widget_label' in changed:
                self.dialog.set_title(changed['widget_label'])
            if 'widget_min_value' in changed or 'widget_max_value' in changed or 'widget_step' in changed:
                selections = list(reversed(list(drange(self.attribs['widget_min_value'],
                                                       self.attribs['widget_max_value'],
                                                       self.attribs['widget_step']))))
                self.dialog.set_items([str(x) for x in selections])
            if 'item_state' in changed:
                selections = list(reversed(list(drange(self.attribs['widget_min_value'],
                                                       self.attribs['widget_max_value'],
                                                       self.attribs['widget_step']))))
                self.dialog.set_index(get_item_index(selections, self.attribs['item_state']))

    def onAction(self, action):
        proxy = self.proxy()
        if proxy:
            state = None
            if action.getId() == xbmcgui.ACTION_CHANNEL_DOWN:
                state = self.attribs['item_state'] - self.attribs['widget_step']
            elif action.getId() == xbmcgui.ACTION_CHANNEL_UP:
                state = self.attribs['item_state'] + self.attribs['widget_step']

            if state is not None:
                if self.attribs['widget_min_value'] <= state <= self.attribs['widget_max_value']:
                    proxy.cmd_set(state)

    def onClick(self):
        proxy = self.proxy()
        if proxy:
            selections = list(reversed(list(drange(self.attribs['widget_min_value'],
                                                   self.attribs['widget_max_value'],
                                                   self.attribs['widget_step']))))
            self.dialog = SelectDialog(self.attribs['widget_label'],
                                       [str(x) for x in selections],
                                       get_item_index(selections, self.attribs['item_state']))
            pos = self.dialog.show()
            self.dialog = None
            if pos is not None:
                proxy.cmd_set(selections[pos])
Esempio n. 11
0
class ListItemSlider(ListItemWithValue):
    def __init__(self, proxy):
        super(ListItemSlider, self).__init__("text", proxy)
        self.set_show_next_icon(True)
        self.dialog = None

    def update(self, changed, deleted):
        super(ListItemSlider, self).update(changed, deleted)
        if self.dialog:
            if 'widget_label' in changed:
                self.dialog.set_title(changed['widget_label'])
            if 'widget_mapping' in changed:
                self.dialog.set_items(changed['widget_mapping'].itervalues())
            if 'item_state' in changed:
                self.dialog.set_index(get_item_index(self.attribs['widget_mapping'].keys(), self.attribs['item_state']))

    def onAction(self, action):
        proxy = self.proxy()
        if proxy:
            state = None
            if action.getId() == xbmcgui.ACTION_TELETEXT_RED:
                proxy.cmd_off()
            elif action.getId() == xbmcgui.ACTION_TELETEXT_GREEN:
                proxy.cmd_on()
            elif action.getId() == xbmcgui.ACTION_CHANNEL_DOWN:
                proxy.cmd_decrement()
            elif action.getId() == xbmcgui.ACTION_CHANNEL_UP:
                proxy.cmd_increment()

    def onClick(self):
        proxy = self.proxy()
        if proxy:
            selections = list(reversed(list(drange(self.attribs['widget_min_value'],
                                                   self.attribs['widget_max_value'],
                                                   self.attribs['widget_step']))))
            self.dialog = SelectDialog(self.attribs['widget_label'],
                                       [str(x) for x in selections],
                                       get_item_index(selections, self.attribs['item_state']))
            pos = self.dialog.show()
            self.dialog = None
            if pos is not None:
                proxy.cmd_set(selections[pos])
Esempio n. 12
0
 def on__import_glade__activate(self, action):
     filters = [("Glade files (*.glade)", "*.glade"),
                ("All files", "*")]
     dialog = OpenDialog(self['main_window'], filters)
     res = dialog.run()
     
     if res == gtk.RESPONSE_OK:
         filename = dialog.get_filename()
         print filename
         
         seldialog = SelectDialog(self)
         widgets = loader.get_glade_widgets(filename)
         seldialog.set_options(widgets)
         seldialog.set_transient_for(self['main_window'])
         seldialog.connect("destroy", self.import_glade, seldialog, filename)
         seldialog.set_position(gtk.WIN_POS_CENTER)
         seldialog.show()
         
     dialog.destroy()
Esempio n. 13
0
# -*- coding: utf-8 -*-
import sys
from PyQt5 import QtWidgets
from selectdialog import SelectDialog
from mainwindow import MainWindow

if __name__ == "__main__":
    application = QtWidgets.QApplication(sys.argv)
    mainwindow = MainWindow()
    selectdialog = SelectDialog(mainwindow)

    selectdialog.show()
    sys.exit(application.exec_())
Esempio n. 14
0
    def on_import_glade__activate(self, action):
        filters = [("Glade files (*.glade)", "*.glade"), ("All files", "*")]
        dialog = OpenDialog(self['main_window'], filters)
        res = dialog.run()

        if res == gtk.RESPONSE_OK:
            filename = dialog.get_filename()
            print filename

            seldialog = SelectDialog()
            widgets = loader.get_glade_widgets(filename)
            seldialog.set_options(widgets)
            seldialog.set_transient_for(self['main_window'])
            seldialog.connect("destroy", self.import_glade, seldialog,
                              filename)
            seldialog.set_position(gtk.WIN_POS_CENTER)
            seldialog.show()

        dialog.destroy()