def __init__(self, parent='osd', text=None, search=None, handler=None, left=None, top=None, width=600, height=200, bg_color=None, fg_color=None, icon=None, border=None, bd_color=None, bd_width=None, vertical_expansion=1): if not text: text = _('Program Search') PopupBox.__init__(self, text, handler, left, top, width, height, icon, vertical_expansion, parent=parent) (self.server_available, msg) = record_client.connectionTest() if not self.server_available: errormsg = Label(_('Recording server is unavailable.') + \ ( ': %s\n\n' % msg ) + \ _('Feel free to implement this function inside the main guide.'), self, Align.CENTER) return self.internal_h_align = Align.CENTER self.lbg = LetterBoxGroup(text=search) self.add_child(self.lbg) items_height = Button('foo').height self.num_shown_items = 8 self.results = ListBox(width=(self.width - 2 * self.h_margin), height=self.num_shown_items * items_height, show_v_scrollbar=0) self.results.y_scroll_interval = self.results.items_height = items_height max_results = 10 self.results.set_h_align(Align.CENTER) self.add_child(self.results) if search: self.searchProg(search) self.center_on_screen = TRUE
def __init__(self, parent=None, subject=None, left=None, top=None, width=500, height=350, context=None): self.oldname = None if context: self.context = context else: context = 'guide' if isinstance(subject, TvProgram): (result, favs) = record_client.getFavorites() if result: num_favorites = len(favs) self.priority = num_favorites + 1 else: self.priority = 1 self.fav = Favorite(subject.title, subject, TRUE, TRUE, TRUE, self.priority, TRUE, FALSE) else: self.fav = subject self.oldname = self.fav.name PopupBox.__init__(self, text=_('Edit Favorite'), x=left, y=top, width=width, height=height) self.v_spacing = 15 self.h_margin = 20 self.v_margin = 20 self.internal_h_align = Align.LEFT if not self.left: self.left = self.osd.width / 2 - self.width / 2 if not self.top: self.top = self.osd.height / 2 - self.height / 2 guide = epg_xmltv.get_guide() name = Label(_('Name') + ':', self, Align.LEFT) self.name_input = LetterBoxGroup(text=self.fav.name) self.name_input.h_align = Align.NONE self.add_child(self.name_input) title = Label(_('Title') + ': %s' % self.fav.title, self, Align.LEFT) chan = Label(_('Channel') + ':', self, Align.LEFT) self.chan_box = OptionBox('ANY') self.chan_box.h_align = Align.NONE self.chan_box.add_item(text=_('ANY'), value='ANY') i = 1 chan_index = 0 for ch in guide.chan_list: #if ch.id == self.fav.channel_id: if ch.displayname == self.fav.channel: chan_index = i i += 1 self.chan_box.add_item(text=ch.displayname, value=ch.displayname) self.chan_box.toggle_selected_index(chan_index) # This is a hack for setting the OptionBox's label to the current # value. It should be done by OptionBox when drawing, but it doesn't # work :( self.chan_box.change_item(None) self.add_child(self.chan_box) dow = Label(_('Day of Week') + ':', self, Align.LEFT) self.dow_box = OptionBox('ANY DAY') self.dow_box.h_align = Align.NONE self.dow_box.add_item(text=_('ANY DAY'), value='ANY') i = 1 dow_index = 0 for dow in (_('Mon'), _('Tue'), _('Wed'), _('Thu'), _('Fri'), _('Sat'), _('Sun')): val = "%d" % (i - 1) self.dow_box.add_item(text=_(dow), value=val) if val == self.fav.dow: dow_index = i i += 1 self.dow_box.toggle_selected_index(dow_index) # This is a hack for setting the OptionBox's label to the current # value. It should be done by OptionBox when drawing, but it doesn't # work :( self.dow_box.change_item(None) self.add_child(self.dow_box) tod = Label(_('Time of Day') + ':', self, Align.LEFT) self.tod_box = OptionBox('ANY') self.tod_box.h_align = Align.NONE self.tod_box.add_item(text=_('ANY TIME'), value='ANY') i = 0 tod_index = 0 for h in range(0, 24): for m in (00, 30): val = i * 30 # Little hack: we calculate the hours from Jan 1st, 1970 GMT, # and then use strftime to get the string representation text = strftime(config.TV_TIMEFORMAT, gmtime(h * 3600 + 60 * m)) self.tod_box.add_item(text=text, value=val) if val == self.fav.mod: tod_index = i + 1 i += 1 self.tod_box.toggle_selected_index(tod_index) # This is a hack for setting the OptionBox's label to the current # value. It should be done by OptionBox when drawing, but it doesn't # work :( self.tod_box.change_item(None) self.add_child(self.tod_box) self.save = Button(_('Save')) self.add_child(self.save) if self.oldname: self.remove = Button(_('Remove')) self.add_child(self.remove) else: self.remove = None self.cancel = Button(_('CANCEL')) self.add_child(self.cancel)