def cache_alarmscreen(self): self.alarmscreen_cache = {} icon_size = (self.ui.display_size[0] * .3, self.ui.display_size[1] * .3) epoch = int(time.time()) if (epoch % 2) == 0: fgcolor = self.ui.bg_color bgcolor = self.ui.fg_color shadow = False else: fgcolor = self.ui.fg_color bgcolor = pygame.Color(0, 0, 0, 0) shadow = True self.alarmscreen_cache["background"] = gui.GuiObject() self.alarmscreen_cache["background"].Surface = pygame.Surface( self.ui.display_size, flags=pygame.SRCALPHA) self.alarmscreen_cache["background"].Position = (0, 0) self.alarmscreen_cache["background"].Surface.fill(bgcolor) current_time_text = str(datetime.now().strftime( self.config.setting["timeformat"])) self.alarmscreen_cache["alarm_button"] = gui.Button( self.ui.image_cache["alarm-symbolic.png"], icon_size, self.stop_alarm) self.alarmscreen_cache[ "alarm_button"].Position = self.ui.calculate_position( (0, -55), self.alarmscreen_cache["alarm_button"].Surface, "center", "center") timefont_size = self.ui.calculate_font_size(25) time_text = gui.Text(current_time_text, timefont_size, font=self.ui.boldfont_file, color=fgcolor, shadow=shadow) self.alarmscreen_cache["time_text_button"] = gui.Button( time_text.Surface, time_text.Surface.get_size(), self.stop_alarm) self.alarmscreen_cache[ "time_text_button"].Position = self.ui.calculate_position( (0, -30), self.alarmscreen_cache["alarm_button"].Surface, "center", "center") self.alarmscreen_cache["time_text_button"].Position = ( self.alarmscreen_cache["alarm_button"].Position[0] + icon_size[1] * 1.2, self.alarmscreen_cache["alarm_button"].Position[1])
def cache_player_widget(self): self.player_widget_cache = {} icon_size = (self.ui.display_size[0] * .15, self.ui.display_size[1] * .15) panel_size = (self.ui.display_size[0], self.ui.display_size[1] * .15) self.player_widget_cache["panel"] = gui.GuiObject() self.player_widget_cache["panel"].Surface = pygame.Surface( panel_size, flags=pygame.SRCALPHA) self.player_widget_cache[ "panel"].Position = self.ui.calculate_position( (0, 0), self.player_widget_cache["panel"].Surface, "bottom", "left") gui.fill_gradient(self.player_widget_cache["panel"].Surface, pygame.Color(0, 0, 0, 0), pygame.Color(0, 0, 0, 255), vertical=True) self.player_widget_cache["play_button"] = gui.Button( self.ui.image_cache["play.png"], icon_size, self.musicplayer.toggle_play) self.player_widget_cache["pause_button"] = gui.Button( self.ui.image_cache["pause.png"], icon_size, self.musicplayer.toggle_play) self.player_widget_cache[ "play_button"].Position = self.player_widget_cache[ "pause_button"].Position = self.ui.calculate_position( (0, -18), self.player_widget_cache["play_button"].Surface, "bottom", "right") self.player_widget_cache["sf_button"] = gui.Button( self.ui.image_cache["sf.png"], icon_size, self.musicplayer.skip) self.player_widget_cache["sf_button"].Position = ( self.player_widget_cache["play_button"].Position[0] + icon_size[1], self.player_widget_cache["play_button"].Position[1]) self.player_widget_cache["sb_button"] = gui.Button( self.ui.image_cache["sb.png"], icon_size, self.musicplayer.back) self.player_widget_cache["sb_button"].Position = ( self.player_widget_cache["play_button"].Position[0] - icon_size[1], self.player_widget_cache["play_button"].Position[1]) self.player_widget_cache["volup_button"] = gui.Button( self.ui.image_cache["volup.png"], icon_size, self.musicplayer.volup) self.player_widget_cache[ "volup_button"].Position = self.ui.calculate_position( (0, 32), self.player_widget_cache["play_button"].Surface, "bottom", "left") self.player_widget_cache["volmute"] = gui.Button( self.ui.image_cache["volmute.png"], icon_size, self.musicplayer.toggle_mute) self.player_widget_cache["vollow"] = gui.Button( self.ui.image_cache["vollow.png"], icon_size, self.musicplayer.toggle_mute) self.player_widget_cache["volmed"] = gui.Button( self.ui.image_cache["volmed.png"], icon_size, self.musicplayer.toggle_mute) self.player_widget_cache["volhigh"] = gui.Button( self.ui.image_cache["volhigh.png"], icon_size, self.musicplayer.toggle_mute) self.player_widget_cache["volmute"].Position = self.player_widget_cache["volhigh"].Position = self.player_widget_cache["volmed"].Position = \ self.player_widget_cache["vollow"].Position = ( self.player_widget_cache["volup_button"].Position[0] - icon_size[1], self.player_widget_cache["volup_button"].Position[1]) self.player_widget_cache["voldown_button"] = gui.Button( self.ui.image_cache["voldown.png"], icon_size, self.musicplayer.voldown) self.player_widget_cache["voldown_button"].Position = ( self.player_widget_cache["volmute"].Position[0] - icon_size[1], self.player_widget_cache["volmute"].Position[1])