Working version of gui
This commit is contained in:
parent
2e09a50fa2
commit
6bf32fd92a
14
ini/base.ini
14
ini/base.ini
|
@ -1,7 +1,7 @@
|
||||||
# Basic Feeds Settings
|
# Basic Feeds Settings
|
||||||
# Copyright by Peter Maersk-Moller 2012 - All rights reserved
|
# Copyright by Peter Maersk-Moller 2012 - All rights reserved
|
||||||
#verbose
|
#verbose
|
||||||
require version 0.4.0
|
require version 0.4.2
|
||||||
|
|
||||||
# Define allowed remote host IP addresses. If omitted then only 127.0.0.1 will be accepted.
|
# Define allowed remote host IP addresses. If omitted then only 127.0.0.1 will be accepted.
|
||||||
system host allow 127.0.0.1
|
system host allow 127.0.0.1
|
||||||
|
@ -211,13 +211,23 @@ image load 1 images/logo.png
|
||||||
image place 1 1 24 24
|
image place 1 1 24 24
|
||||||
|
|
||||||
|
|
||||||
|
#Text
|
||||||
|
text font 1 Source Code Pro Bold 32
|
||||||
|
|
||||||
|
text string 1 [Test text 1]
|
||||||
|
text place 1 1 1 32 650 1.0 1.0 1.0
|
||||||
|
|
||||||
|
text string 2 [Test text 2]
|
||||||
|
text place 2 2 1 32 700 1.0 1.0 1.0
|
||||||
|
|
||||||
|
|
||||||
command create Show
|
command create Show
|
||||||
overlay image 0
|
overlay image 0
|
||||||
|
|
||||||
overlay virtual feed 1..3
|
overlay virtual feed 1..3
|
||||||
|
|
||||||
overlay image 1
|
overlay image 1
|
||||||
#overlay text all
|
overlay text all
|
||||||
loop
|
loop
|
||||||
command end
|
command end
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
#!/bin/env python2
|
#!/bin/env python2
|
||||||
import socket
|
|
||||||
|
|
||||||
class SceneChange(object):
|
class SceneChanger(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, socket):
|
||||||
self.cur_scene = 1
|
self.cur_scene = 1
|
||||||
self.snowmix_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.snowmix_socket = socket
|
||||||
self.snowmix_socket.connect(("localhost", 9999))
|
|
||||||
|
|
||||||
|
|
||||||
def switch_to(self, next_scene):
|
def switch_to(self, next_scene):
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/env python2
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
class TextChanger(object):
|
||||||
|
|
||||||
|
TEXT_ID = 1
|
||||||
|
UMLAUTS = {
|
||||||
|
'ä' : 'ae',
|
||||||
|
'ü' : 'ue',
|
||||||
|
'ö' : 'oe',
|
||||||
|
'ß' : 'ss'
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, socket):
|
||||||
|
self.snowmix_socket = socket
|
||||||
|
|
||||||
|
|
||||||
|
def set_text(self, text):
|
||||||
|
for umlaut, replacement in self.UMLAUTS.items():
|
||||||
|
text = text.replace(umlaut, replacement)
|
||||||
|
|
||||||
|
cmd = "text string %d %s\n" % (self.TEXT_ID,text)
|
||||||
|
self.snowmix_socket.send(cmd)
|
||||||
|
|
||||||
|
def hide_text(self):
|
||||||
|
cmd = "text string %d\n" % self.TEXT_ID
|
||||||
|
self.snowmix_socket.send(cmd)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
class TimerController(object):
|
||||||
|
|
||||||
|
TEXT_ID = 2
|
||||||
|
UMLAUTS = {
|
||||||
|
'ä' : 'ae',
|
||||||
|
'ü' : 'ue',
|
||||||
|
'ö' : 'oe',
|
||||||
|
'ß' : 'ss'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, socket):
|
||||||
|
self.snowmix_socket = socket
|
||||||
|
|
||||||
|
self.active_timer = None
|
||||||
|
self.timers = {}
|
||||||
|
|
||||||
|
self.update_thread = threading.Thread(target=self.update_timer)
|
||||||
|
self.stopped = False
|
||||||
|
self.update_thread.start()
|
||||||
|
|
||||||
|
def start_timer(self, name):
|
||||||
|
if not name in self.timers.keys():
|
||||||
|
self.timers[name] = datetime.now()
|
||||||
|
|
||||||
|
def get_timers(self):
|
||||||
|
return self.timers.keys()
|
||||||
|
|
||||||
|
|
||||||
|
def hide_timer(self):
|
||||||
|
self.active_timer = None
|
||||||
|
self.hide_text()
|
||||||
|
|
||||||
|
|
||||||
|
def set_active_timer(self, name):
|
||||||
|
if name in self.timers.keys():
|
||||||
|
self.active_timer = name
|
||||||
|
|
||||||
|
|
||||||
|
def update_timer(self):
|
||||||
|
print "Starting update thread !"
|
||||||
|
while not self.stopped:
|
||||||
|
if self.active_timer != None:
|
||||||
|
delta = datetime.now() - self.timers[self.active_timer]
|
||||||
|
hours, remainder = divmod(delta.total_seconds(), 3600)
|
||||||
|
minutes, seconds = divmod(remainder, 60)
|
||||||
|
self.update_text('%s: %d:%d:%d' % (self.active_timer, hours, minutes, seconds))
|
||||||
|
pass
|
||||||
|
time.sleep(1.0)
|
||||||
|
|
||||||
|
print "Stopping update thread !"
|
||||||
|
|
||||||
|
|
||||||
|
def update_text(self, text):
|
||||||
|
for umlaut, replacement in self.UMLAUTS.items():
|
||||||
|
text = text.replace(umlaut, replacement)
|
||||||
|
|
||||||
|
cmd = "text string %d %s\n" % (self.TEXT_ID,text)
|
||||||
|
self.snowmix_socket.send(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
def hide_text(self):
|
||||||
|
cmd = "text string %d\n" % self.TEXT_ID
|
||||||
|
self.snowmix_socket.send(cmd)
|
||||||
|
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.stopped = True
|
||||||
|
self.update_thread.join(5.0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,25 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python2
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import socket
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
from scenechange import SceneChange
|
from scenechanger import SceneChanger
|
||||||
|
from textchanger import TextChanger
|
||||||
|
from timercontroller import TimerController
|
||||||
|
|
||||||
class VideoController:
|
class VideoController:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.scenechange = SceneChange()
|
self.snowmix_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
self.snowmix_socket.connect(("localhost", 9999))
|
||||||
|
|
||||||
self.gladefile = "videocontroler.ui"
|
self.scenechanger = SceneChanger(self.snowmix_socket)
|
||||||
|
self.textchanger = TextChanger(self.snowmix_socket)
|
||||||
|
self.timercontroller = TimerController(self.snowmix_socket)
|
||||||
|
|
||||||
|
self.gladefile = "videocontroller.ui"
|
||||||
self.builder = Gtk.Builder()
|
self.builder = Gtk.Builder()
|
||||||
self.builder.add_from_file(self.gladefile)
|
self.builder.add_from_file(self.gladefile)
|
||||||
|
|
||||||
|
@ -18,6 +27,9 @@ class VideoController:
|
||||||
self.max_cam1_button = self.builder.get_object("MaxCam1Button")
|
self.max_cam1_button = self.builder.get_object("MaxCam1Button")
|
||||||
self.max_cam2_button = self.builder.get_object("MaxCam2Button")
|
self.max_cam2_button = self.builder.get_object("MaxCam2Button")
|
||||||
self.max_cam3_button = self.builder.get_object("MaxCam3Button")
|
self.max_cam3_button = self.builder.get_object("MaxCam3Button")
|
||||||
|
self.set_text_entry = self.builder.get_object("SetTextEntry")
|
||||||
|
self.start_timer_entry = self.builder.get_object("StartTimerEntry")
|
||||||
|
self.change_timer_combobox = self.builder.get_object("ChangeTimerComboBox")
|
||||||
|
|
||||||
self.messagebox = Gtk.MessageDialog(self.main_window, 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, "I'm afaraid I can't let you do that dave.")
|
self.messagebox = Gtk.MessageDialog(self.main_window, 0, Gtk.MessageType.WARNING, Gtk.ButtonsType.OK_CANCEL, "I'm afaraid I can't let you do that dave.")
|
||||||
|
|
||||||
|
@ -30,7 +42,7 @@ class VideoController:
|
||||||
if self.max_cam1_button.get_active():
|
if self.max_cam1_button.get_active():
|
||||||
self.max_cam2_button.set_active(False)
|
self.max_cam2_button.set_active(False)
|
||||||
self.max_cam3_button.set_active(False)
|
self.max_cam3_button.set_active(False)
|
||||||
self.scenechange.switch_to(1)
|
self.scenechanger.switch_to(1)
|
||||||
else:
|
else:
|
||||||
if not self.max_cam2_button.get_active() and not self.max_cam3_button.get_active():
|
if not self.max_cam2_button.get_active() and not self.max_cam3_button.get_active():
|
||||||
self.max_cam1_button.set_active(True)
|
self.max_cam1_button.set_active(True)
|
||||||
|
@ -40,7 +52,7 @@ class VideoController:
|
||||||
if self.max_cam2_button.get_active():
|
if self.max_cam2_button.get_active():
|
||||||
self.max_cam1_button.set_active(False)
|
self.max_cam1_button.set_active(False)
|
||||||
self.max_cam3_button.set_active(False)
|
self.max_cam3_button.set_active(False)
|
||||||
self.scenechange.switch_to(2)
|
self.scenechanger.switch_to(2)
|
||||||
else:
|
else:
|
||||||
if not self.max_cam1_button.get_active() and not self.max_cam3_button.get_active():
|
if not self.max_cam1_button.get_active() and not self.max_cam3_button.get_active():
|
||||||
self.max_cam2_button.set_active(True)
|
self.max_cam2_button.set_active(True)
|
||||||
|
@ -50,16 +62,38 @@ class VideoController:
|
||||||
if self.max_cam3_button.get_active():
|
if self.max_cam3_button.get_active():
|
||||||
self.max_cam1_button.set_active(False)
|
self.max_cam1_button.set_active(False)
|
||||||
self.max_cam2_button.set_active(False)
|
self.max_cam2_button.set_active(False)
|
||||||
self.scenechange.switch_to(3)
|
self.scenechanger.switch_to(3)
|
||||||
else:
|
else:
|
||||||
if not self.max_cam1_button.get_active() and not self.max_cam2_button.get_active():
|
if not self.max_cam1_button.get_active() and not self.max_cam2_button.get_active():
|
||||||
self.max_cam3_button.set_active(True)
|
self.max_cam3_button.set_active(True)
|
||||||
|
|
||||||
|
|
||||||
|
def SetTextButtonClicked(self, widget):
|
||||||
|
self.textchanger.set_text(self.set_text_entry.get_text())
|
||||||
|
|
||||||
|
|
||||||
|
def HideTextButtonClicked(self, widget):
|
||||||
|
self.textchanger.hide_text()
|
||||||
|
|
||||||
|
|
||||||
|
def StartTimerButtonClicked(self, widget):
|
||||||
|
self.timercontroller.start_timer(self.start_timer_entry.get_text())
|
||||||
|
self.change_timer_combobox.remove_all()
|
||||||
|
for timer in self.timercontroller.get_timers():
|
||||||
|
self.change_timer_combobox.append_text(timer)
|
||||||
|
|
||||||
|
def ChangeTimerComboBoxChanged(self, widget):
|
||||||
|
self.timercontroller.set_active_timer(self.change_timer_combobox.get_active_text())
|
||||||
|
|
||||||
|
|
||||||
|
def HideTimerButtonClicked(self, widget):
|
||||||
|
self.timercontroller.hide_timer()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def MainWindowDelete(self, widget, event):
|
def MainWindowDelete(self, widget, event):
|
||||||
if self.messagebox.run() == Gtk.ResponseType.OK:
|
if self.messagebox.run() == Gtk.ResponseType.OK:
|
||||||
|
self.timercontroller.stop()
|
||||||
Gtk.main_quit()
|
Gtk.main_quit()
|
||||||
|
|
||||||
self.messagebox.hide()
|
self.messagebox.hide()
|
||||||
|
|
|
@ -110,7 +110,7 @@ Cam 2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkEntry" id="StartTimerEnty">
|
<object class="GtkEntry" id="StartTimerEntry">
|
||||||
<property name="width_request">180</property>
|
<property name="width_request">180</property>
|
||||||
<property name="height_request">30</property>
|
<property name="height_request">30</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -161,19 +161,6 @@ Cam 2</property>
|
||||||
<property name="y">270</property>
|
<property name="y">270</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkComboBoxText" id="ChangeTimerComboBox">
|
|
||||||
<property name="width_request">290</property>
|
|
||||||
<property name="height_request">30</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<signal name="changed" handler="ChangeTimerComboBoxChanged" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">170</property>
|
|
||||||
<property name="y">270</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="HideTextButton">
|
<object class="GtkButton" id="HideTextButton">
|
||||||
<property name="label" translatable="yes">Hide text</property>
|
<property name="label" translatable="yes">Hide text</property>
|
||||||
|
@ -182,6 +169,7 @@ Cam 2</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="HideTextButtonClicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x">10</property>
|
<property name="x">10</property>
|
||||||
|
@ -196,12 +184,26 @@ Cam 2</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
<property name="receives_default">True</property>
|
||||||
|
<signal name="clicked" handler="HideTimerButtonClicked" swapped="no"/>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x">230</property>
|
<property name="x">230</property>
|
||||||
<property name="y">320</property>
|
<property name="y">320</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBoxText" id="ChangeTimerComboBox">
|
||||||
|
<property name="width_request">285</property>
|
||||||
|
<property name="height_request">30</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<signal name="changed" handler="ChangeTimerComboBoxChanged" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="x">174</property>
|
||||||
|
<property name="y">270</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
Loading…
Reference in New Issue