diff --git a/src/main.pyw b/src/main.pyw index a7f3964..0d6f022 100644 --- a/src/main.pyw +++ b/src/main.pyw @@ -17,6 +17,7 @@ import copy import vlc import wx import wx.grid +from wx.adv import Animation from background_music_player import BackgroundMusicPlayer from constants import Config, Colors, Columns, FileTypes, Strings @@ -205,6 +206,11 @@ class MainWindow(wx.Frame): self.Bind(wx.EVT_MENU, self.destroy_proj_win, self.destroy_proj_win_item) menu_bar.Append(proj_win_menu, _("&Projector Window")) + self.countdown_gif = Animation(r'C:\Users\glago\Desktop\giphy2.gif') # TODO: config + if self.countdown_gif.GetFrameCount() < 1: + self.logger.log(_("[ERROR] Countdown GIF is broken!")) + self.countdown_gif = None + # --- Text Window --- text_win_menu = wx.Menu() self.text_win_show_item = text_win_menu.Append(wx.ID_ANY, _("&Show"), kind=wx.ITEM_CHECK) @@ -555,8 +561,7 @@ class MainWindow(wx.Frame): def ensure_proj_win(self, e=None): no_window = not self.proj_win if no_window: - self.proj_win = ProjectorWindow(self, self.config[Config.PROJECTOR_SCREEN]) - + self.proj_win = ProjectorWindow(self, self.config[Config.PROJECTOR_SCREEN], self.countdown_gif) self.vid_btn.Bind(wx.EVT_TOGGLEBUTTON, self.switch_to_vid) self.zad_btn.Bind(wx.EVT_TOGGLEBUTTON, self.switch_to_zad) self.switch_to_zad() diff --git a/src/projector.py b/src/projector.py index 6068a67..8ad5fdb 100644 --- a/src/projector.py +++ b/src/projector.py @@ -1,10 +1,11 @@ import wx from datetime import * from constants import Config, Colors +from wx.adv import AnimationCtrl class ProjectorWindow(wx.Frame): - def __init__(self, parent, screen=None): + def __init__(self, parent, screen=None, countdown_gif=None): self.main_window = parent run_windowed = wx.Display.GetCount() <= screen or wx.Display.GetCount() < 2 @@ -71,12 +72,19 @@ def __init__(self, parent): self.countdown_text = wx.StaticText(self, style=wx.ALIGN_CENTER_HORIZONTAL) self.time_text = wx.StaticText(self, style=wx.ALIGN_CENTER_HORIZONTAL) + self.countdown_gif_ctrl = None + if countdown_gif: + self.countdown_gif_ctrl = AnimationCtrl(self, anim=countdown_gif) + self.countdown_text.SetForegroundColour(Colors.COUNTDOWN_TEXT_COLOR) self.info_text.SetForegroundColour(Colors.COUNTDOWN_TEXT_COLOR) self.time_text.SetForegroundColour(Colors.COUNTDOWN_TEXT_COLOR) sizer = wx.BoxSizer(wx.VERTICAL) + if self.countdown_gif_ctrl: + sizer.Add(self.countdown_gif_ctrl, 0, wx.CENTER) # TODO: Layout + sizer.AddStretchSpacer() sizer.Add(self.info_text, 0, wx.CENTER) sizer.Add(self.countdown_text, 0, wx.CENTER) @@ -162,23 +170,28 @@ def load_zad(self, file_path, fit=True): self.images_panel.Refresh() def switch_to_video(self, e=None): - if self.countdown_panel.IsShown(): - self.countdown_panel.timer.Stop() - self.countdown_panel.Hide() + self.stop_timer() self.video_panel.Show() self.images_panel.Hide() def switch_to_images(self, e=None): + self.stop_timer() + self.video_panel.Hide() + self.images_panel.Show() + + def stop_timer(self): if self.countdown_panel.IsShown(): self.countdown_panel.timer.Stop() self.countdown_panel.Hide() - self.video_panel.Hide() - self.images_panel.Show() + if self.countdown_panel.countdown_gif_ctrl: + self.countdown_panel.countdown_gif_ctrl.Stop() def launch_timer(self, time, text): self.video_panel.Hide() self.images_panel.Hide() self.countdown_panel.Show() + if self.countdown_panel.countdown_gif_ctrl: + self.countdown_panel.countdown_gif_ctrl.Play() self.Layout() if time[-1] == 'm': # Assuming duration