def __init__(self, config, app): super(XkcdBrowser, self).__init__() self._app = app self._current_comic = None self._current_data = None self._downloader = XkcdDownloader(config['cache_dir']) self._theme = mytheme = theme.get('plugins/xkcd') self._heading = pygame.font.Font(datafiles.get(mytheme['font']), mytheme['heading_size']) self._padding = mytheme.get('padding', 5) self._frame_y = self._padding * 2 + self._heading.get_linesize() self._frame_x = self._padding screen_w, screen_h = app.screen.get_size() frame_height = screen_h - self._frame_y - self._padding * 2 - self._heading.get_linesize( ) font = pygame.font.Font(datafiles.get(mytheme['font']), mytheme['font_size']) frame_height -= 3 * font.get_linesize() + self._padding self._scrollable_frame = widgets.ScrollableImage( (screen_w - 2 * self._frame_x, frame_height)) self._caption_y = self._frame_y + frame_height + self._padding self._caption_x = self._padding self._caption_frame = widgets.TextBox( (screen_w - 2 * self._padding, screen_h - (self._frame_y + frame_height + self._padding * 2)), theme_path='/plugins/xkcd')
def __init__(self, app, config): super(Clock, self).__init__() self._app = app self._theme = theme.get('plugins/clock') self._font = pygame.font.Font(datafiles.get(self._theme['font']), self._theme['font_size']) self._format = config['format']
def __init__(self, title, top_path, app): super(FileBrowser, self).__init__() self._top_path = os.path.realpath(top_path) self._path = os.path.realpath(top_path) self._title = title self._app = app self.theme = theme.get('filebrowser') self._font = pygame.font.Font(datafiles.get(self.theme['font']), self.theme['font_size']) self._font.set_bold(True) self._listview = widgets.ListView(theme.get('filebrowser/listview'), self._getDisplayList, self._getListLength) self.go('.') self._scrollbar = widgets.ScrollBar(theme.get('filebrowser/scrollbar'), self._listview.size()[1])
def __init__(self, size, align=constants.CENTER, theme_path='/', text=None): super(TextBox, self).__init__() self._w, self._h = size self._align = align self._surface = util.alphaSurface(*size) self._theme = theme.get(theme_path) self._text = None self._font = pygame.font.Font(datafiles.get(self._theme['font']), self._theme['font_size']) if text: self.setText(text)
def __init__(self, app, choices=None): super(Menu, self).__init__() self._app = app self._theme = theme.get('menu') self._config = config.get('menu') if not choices: choices = self._config['choices'] self._choices = [] if app.current_window: self._choices.append((self.makeButton('Back'), self.goBack)) for choice in choices: type = choice['type'].lower() if choice['type'].lower() == 'menu': func = functools.partial(Menu, choices=choice['choices']) else: # Apply default config for this plugin. default_config = plugin.get_defaults(choice['type']) cfg = config.merge(default_config, choice) plug = plugin.get_plugin(choice['type']) if plug: func = functools.partial(plug, cfg) else: print >> sys.stderr, "Config contains plugin %s, but it could not be loaded." % choice[ 'type'] continue self._choices.append((self.makeButton(choice['title']), func)) self.selected = 0
def __init__(self, app, path, files): cmd = ['mplayer', '-fs'] + files super(Mplayer, self).__init__(app, cmd, path, theme.get('processrunner/mplayer'))
def makeButton(self, label): icon = datafiles.get('icon_%s.png' % label.lower()) if not os.path.isfile(icon): icon = None return widgets.Button(label, icon, theme.get('menu/button'))