Skip to content

[Draft] GIF animations in countdown #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/main.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
25 changes: 19 additions & 6 deletions src/projector.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down