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)
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()
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()
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])
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])
# -*- 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_())