polished
This commit is contained in:
parent
80d6aea666
commit
f2963a938d
|
@ -119,15 +119,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterfa
|
||||||
self.text_storage = ExclusiveTextStorage(columns, self.default_font, self.column_width, self.line_height, self.graphics_scene)
|
self.text_storage = ExclusiveTextStorage(columns, self.default_font, self.column_width, self.line_height, self.graphics_scene)
|
||||||
self.text_storage.init_columns()
|
self.text_storage.init_columns()
|
||||||
|
|
||||||
msg = OSCMessage("/subscribe")
|
|
||||||
msg.appendTypedArg("localhost", "s")
|
|
||||||
msg.appendTypedArg(args.client_port, "i")
|
|
||||||
msg.appendTypedArg(self.args.authenticate, "s")
|
|
||||||
if self.args.subscriber_label is not None:
|
|
||||||
msg.appendTypedArg(self.args.subscriber_label, "s")
|
|
||||||
self.osc_sock.writeDatagram(QByteArray(msg.encode_osc()), QHostAddress("127.0.0.1"), 7110)
|
|
||||||
#self.add_text(0, "foo bar")
|
|
||||||
|
|
||||||
self.regex = re.compile("^/(uwe|merle|bjoern)/(.*?)$")
|
self.regex = re.compile("^/(uwe|merle|bjoern)/(.*?)$")
|
||||||
|
|
||||||
def pubdir(self):
|
def pubdir(self):
|
||||||
|
|
|
@ -75,7 +75,7 @@ class Generator(object):
|
||||||
if self.count < int(self.steps / 100. * 30):
|
if self.count < int(self.steps / 100. * 30):
|
||||||
value = random.randint(30, 35)
|
value = random.randint(30, 35)
|
||||||
elif self.count == int(self.steps / 100. * 30):
|
elif self.count == int(self.steps / 100. * 30):
|
||||||
value = random.randint(random.randint(50,60), random.randint(60, 70))
|
value = random.randint(55, 66)
|
||||||
elif self.count < int(self.steps / 100. * 45):
|
elif self.count < int(self.steps / 100. * 45):
|
||||||
value = random.randint(30, 35)
|
value = random.randint(30, 35)
|
||||||
elif self.count < int(self.steps / 2.):
|
elif self.count < int(self.steps / 2.):
|
||||||
|
@ -83,11 +83,11 @@ class Generator(object):
|
||||||
elif self.count == int(self.steps / 2.):
|
elif self.count == int(self.steps / 2.):
|
||||||
value = 255
|
value = 255
|
||||||
elif self.count < int(self.steps / 100. * 60):
|
elif self.count < int(self.steps / 100. * 60):
|
||||||
value = random.randint(random.randint(25,30), random.randint(30, 35))
|
value = random.randint(25, 35)
|
||||||
elif self.count < int(self.steps / 100. * 70):
|
elif self.count < int(self.steps / 100. * 70):
|
||||||
value = random.randint(random.randint(10,25), random.randint(25, 30))
|
value = random.randint(10, 30)
|
||||||
elif self.count < self.steps:
|
elif self.count < self.steps:
|
||||||
value = random.randint(random.randint(15,25), random.randint(25, 30))
|
value = random.randint(15, 30)
|
||||||
else:
|
else:
|
||||||
self.count = 0
|
self.count = 0
|
||||||
value = 30
|
value = 30
|
||||||
|
@ -152,11 +152,11 @@ class Actor(object):
|
||||||
self.plotPoint.setData(x=[self.pre_head], y=[self.data[self.pre_head]])
|
self.plotPoint.setData(x=[self.pre_head], y=[self.data[self.pre_head]])
|
||||||
|
|
||||||
|
|
||||||
class EkgPlotWidget(PlotWidget, MjpegStreamingConsumerInterface, PsyQtChaoscClientBase):
|
class EkgPlotWidget(PlotWidget, PsyQtChaoscClientBase, MjpegStreamingConsumerInterface):
|
||||||
def __init__(self, args, parent=None):
|
def __init__(self, args, parent=None):
|
||||||
self.args = args
|
self.args = args
|
||||||
PsyQtChaoscClientBase.__init__(self)
|
|
||||||
super(EkgPlotWidget, self).__init__()
|
super(EkgPlotWidget, self).__init__()
|
||||||
|
PsyQtChaoscClientBase.__init__(self)
|
||||||
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
|
||||||
|
|
||||||
self.fps = 12.5
|
self.fps = 12.5
|
||||||
|
@ -193,6 +193,10 @@ class EkgPlotWidget(PlotWidget, MjpegStreamingConsumerInterface, PsyQtChaoscClie
|
||||||
self.set_positions()
|
self.set_positions()
|
||||||
self.heartbeat_regex = re.compile("^/(.*?)/heartbeat$")
|
self.heartbeat_regex = re.compile("^/(.*?)/heartbeat$")
|
||||||
|
|
||||||
|
self.pull_timer = QtCore.QTimer()
|
||||||
|
self.pull_timer.timeout.connect(self.slot_pull_ekg)
|
||||||
|
self.pull_timer.start(40)
|
||||||
|
|
||||||
def pubdir(self):
|
def pubdir(self):
|
||||||
return os.path.dirname(os.path.abspath(__file__))
|
return os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
@ -228,9 +232,6 @@ class EkgPlotWidget(PlotWidget, MjpegStreamingConsumerInterface, PsyQtChaoscClie
|
||||||
|
|
||||||
def render_image(self):
|
def render_image(self):
|
||||||
for actor_obj in self.active_actors:
|
for actor_obj in self.active_actors:
|
||||||
osc = actor_obj.osci
|
|
||||||
for i in range(actor_obj.osci_obj.multiplier):
|
|
||||||
actor_obj.add_value(osc.next())
|
|
||||||
actor_obj.render()
|
actor_obj.render()
|
||||||
exporter = pg.exporters.ImageExporter.ImageExporter(self.plotItem)
|
exporter = pg.exporters.ImageExporter.ImageExporter(self.plotItem)
|
||||||
exporter.parameters()['width'] = 768
|
exporter.parameters()['width'] = 768
|
||||||
|
@ -251,6 +252,10 @@ class EkgPlotWidget(PlotWidget, MjpegStreamingConsumerInterface, PsyQtChaoscClie
|
||||||
else:
|
else:
|
||||||
self.update(osc_address, args)
|
self.update(osc_address, args)
|
||||||
|
|
||||||
|
def slot_pull_ekg(self):
|
||||||
|
for actor_obj in self.active_actors:
|
||||||
|
actor_obj.add_value(actor_obj.osci.next())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
|
@ -205,6 +205,9 @@ class MjpegStreamingServer(QTcpServer):
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.stream_clients = list()
|
self.stream_clients = list()
|
||||||
|
for sock in self.sockets:
|
||||||
|
sock.close()
|
||||||
|
sock.deleteLater()
|
||||||
self.sockets = list()
|
self.sockets = list()
|
||||||
self.html_map = dict()
|
self.html_map = dict()
|
||||||
self.close()
|
self.close()
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
from PyQt4.QtCore import QBuffer, QByteArray
|
from PyQt4.QtCore import QBuffer, QByteArray
|
||||||
|
@ -64,17 +65,19 @@ class PsyQtChaoscClientBase(PsyQtClientBase):
|
||||||
self.osc_sock.error.connect(self.handle_osc_error)
|
self.osc_sock.error.connect(self.handle_osc_error)
|
||||||
self.subscribe()
|
self.subscribe()
|
||||||
|
|
||||||
def sigint_handler(self, ex_cls, ex, traceback):
|
def sigint_handler(self, ex_cls, ex, tb):
|
||||||
"""Handler for the SIGINT signal."""
|
"""Handler for the SIGINT signal."""
|
||||||
|
logger.info("sigint_handler")
|
||||||
if ex_cls == KeyboardInterrupt:
|
if ex_cls == KeyboardInterrupt:
|
||||||
logger.info("found KeyboardInterrupt")
|
logger.info("found KeyboardInterrupt")
|
||||||
self.unsubscribe()
|
self.unsubscribe()
|
||||||
QtGui.QApplication.exit()
|
QtGui.QApplication.exit()
|
||||||
else:
|
else:
|
||||||
logger.critical(''.join(traceback.format_tb(traceback)))
|
logger.critical(''.join(traceback.format_tb(tb)))
|
||||||
logger.critical('{0}: {1}'.format(ex_cls, ex))
|
logger.critical('{0}: {1}'.format(ex_cls, ex))
|
||||||
|
|
||||||
def sigterm_handler(self, *args):
|
def sigterm_handler(self, *args):
|
||||||
|
logger.info("sigterm_handler")
|
||||||
self.unsubscribe()
|
self.unsubscribe()
|
||||||
QtGui.QApplication.exit()
|
QtGui.QApplication.exit()
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="text_list"/>
|
<widget class="QListView" name="text_list"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextEdit" name="text_preview">
|
<widget class="QTextEdit" name="text_preview">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# Form implementation generated from reading ui file 'edit_dialog.ui'
|
# Form implementation generated from reading ui file 'edit_dialog.ui'
|
||||||
#
|
#
|
||||||
# Created: Sat May 17 16:15:38 2014
|
# Created: Tue May 27 18:18:57 2014
|
||||||
# by: PyQt4 UI code generator 4.10.3
|
# by: PyQt4 UI code generator 4.10.3
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
@ -31,7 +31,7 @@ class Ui_EditDialog(object):
|
||||||
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
|
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
|
||||||
self.horizontalLayout_2 = QtGui.QHBoxLayout()
|
self.horizontalLayout_2 = QtGui.QHBoxLayout()
|
||||||
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
|
self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
|
||||||
self.text_list = QtGui.QTableView(EditDialog)
|
self.text_list = QtGui.QListView(EditDialog)
|
||||||
self.text_list.setObjectName(_fromUtf8("text_list"))
|
self.text_list.setObjectName(_fromUtf8("text_list"))
|
||||||
self.horizontalLayout_2.addWidget(self.text_list)
|
self.horizontalLayout_2.addWidget(self.text_list)
|
||||||
self.text_preview = QtGui.QTextEdit(EditDialog)
|
self.text_preview = QtGui.QTextEdit(EditDialog)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import cPickle
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import traceback
|
||||||
|
|
||||||
from PyQt4 import QtCore, QtGui
|
from PyQt4 import QtCore, QtGui
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ class EditDialog(QtGui.QWidget, Ui_EditDialog):
|
||||||
|
|
||||||
def slot_show_text(self, model_index):
|
def slot_show_text(self, model_index):
|
||||||
try:
|
try:
|
||||||
self.text_preview.setTextOrHtml(self.parent().parent().model.text_db[model_index.row()][1])
|
self.text_preview.setHtml(self.parent().parent().model.text_db[model_index.row()][1])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -232,10 +233,12 @@ class TextAnimation(QtCore.QObject):
|
||||||
self.count += 1
|
self.count += 1
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(KMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterface, PsyQtClientBase):
|
class MainWindow(KMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterface):
|
||||||
def __init__(self, args, parent=None):
|
def __init__(self, args, parent=None):
|
||||||
self.args = args
|
self.args = args
|
||||||
super(MainWindow, self).__init__()
|
#super(MainWindow, self).__init__()
|
||||||
|
#PsyQtClientBase.__init__(self)
|
||||||
|
KMainWindow.__init__(self, parent)
|
||||||
self.is_streaming = False
|
self.is_streaming = False
|
||||||
|
|
||||||
self.live_center_action = None
|
self.live_center_action = None
|
||||||
|
@ -257,12 +260,11 @@ class MainWindow(KMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterface, Ps
|
||||||
self.dialog = None
|
self.dialog = None
|
||||||
self.current_object = None
|
self.current_object = None
|
||||||
self.current_index = -1
|
self.current_index = -1
|
||||||
self.win_id = self.winId()
|
|
||||||
|
|
||||||
self.is_auto_publish = False
|
self.is_auto_publish = False
|
||||||
|
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
self.coords = self.live_text_rect()
|
self.win_id = self.live_text.winId()
|
||||||
|
|
||||||
self.fps = 12.5
|
self.fps = 12.5
|
||||||
self.http_server = MjpegStreamingServer((args.http_host, args.http_port), self, self.fps)
|
self.http_server = MjpegStreamingServer((args.http_host, args.http_port), self, self.fps)
|
||||||
|
@ -307,6 +309,9 @@ class MainWindow(KMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterface, Ps
|
||||||
self.start_streaming()
|
self.start_streaming()
|
||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
|
timer = QtCore.QTimer()
|
||||||
|
timer.start(2000)
|
||||||
|
timer.timeout.connect(lambda: None)
|
||||||
|
|
||||||
def pubdir(self):
|
def pubdir(self):
|
||||||
return os.path.dirname(os.path.abspath(__file__))
|
return os.path.dirname(os.path.abspath(__file__))
|
||||||
|
@ -317,9 +322,10 @@ class MainWindow(KMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterface, Ps
|
||||||
global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight()))
|
global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight()))
|
||||||
return global_rect.x(), global_rect.y()
|
return global_rect.x(), global_rect.y()
|
||||||
|
|
||||||
|
|
||||||
def render_image(self):
|
def render_image(self):
|
||||||
pixmap = QPixmap.grabWindow(self.win_id, self.coords.x() + 10, self.coords.y() + 10, 768, 576)
|
public_rect = self.live_text_rect()
|
||||||
|
#global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight()))
|
||||||
|
pixmap = QPixmap.grabWindow(self.win_id, public_rect.x() + 1, public_rect.y() + 1, 768, 576)
|
||||||
buf = QBuffer()
|
buf = QBuffer()
|
||||||
buf.open(QIODevice.WriteOnly)
|
buf.open(QIODevice.WriteOnly)
|
||||||
pixmap.save(buf, "JPG", 75)
|
pixmap.save(buf, "JPG", 75)
|
||||||
|
@ -505,6 +511,7 @@ class MainWindow(KMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterface, Ps
|
||||||
self.streaming_action.setChecked(True)
|
self.streaming_action.setChecked(True)
|
||||||
|
|
||||||
def closeEvent(self, event):
|
def closeEvent(self, event):
|
||||||
|
logger.info("closeEvent")
|
||||||
if self.db_dirty:
|
if self.db_dirty:
|
||||||
self.dialog = KDialog(self)
|
self.dialog = KDialog(self)
|
||||||
self.dialog.setCaption("4.48 texter - text db not saved")
|
self.dialog.setCaption("4.48 texter - text db not saved")
|
||||||
|
@ -513,7 +520,7 @@ class MainWindow(KMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterface, Ps
|
||||||
self.dialog.setButtons(KDialog.ButtonCodes(KDialog.Ok | KDialog.Cancel))
|
self.dialog.setButtons(KDialog.ButtonCodes(KDialog.Ok | KDialog.Cancel))
|
||||||
self.dialog.okClicked.connect(self.slot_save)
|
self.dialog.okClicked.connect(self.slot_save)
|
||||||
self.dialog.exec_()
|
self.dialog.exec_()
|
||||||
super(self, MainWindow).closeEvent(event)
|
event.accept()
|
||||||
|
|
||||||
def live_text_rect(self):
|
def live_text_rect(self):
|
||||||
return self.live_text.geometry()
|
return self.live_text.geometry()
|
||||||
|
@ -727,6 +734,15 @@ class MainWindow(KMainWindow, Ui_MainWindow, MjpegStreamingConsumerInterface, Ps
|
||||||
self.text_combo.setCurrentItem(0)
|
self.text_combo.setCurrentItem(0)
|
||||||
self.slot_load_preview_text(0)
|
self.slot_load_preview_text(0)
|
||||||
|
|
||||||
|
def sigint_handler(self, ex_cls, ex, tb):
|
||||||
|
"""Handler for the SIGINT signal."""
|
||||||
|
if ex_cls == KeyboardInterrupt:
|
||||||
|
logger.info("found KeyboardInterrupt")
|
||||||
|
QtGui.QApplication.exit()
|
||||||
|
else:
|
||||||
|
logger.critical(''.join(traceback.format_tb(tb)))
|
||||||
|
logger.critical('{0}: {1}'.format(ex_cls, ex))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
arg_parser = ArgParser("texter")
|
arg_parser = ArgParser("texter")
|
||||||
|
|
Loading…
Reference in New Issue