From 54d3526d2a8eef184a79692ed487c2500253d14d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Sun, 20 Apr 2014 11:37:22 +0200 Subject: [PATCH 01/14] sync commit for laptop --- texter/texter/build.sh | 4 +- texter/texter/main.py | 180 ++++++++++--- texter/texter/text_sorter_ui.py | 166 +++++++++++- texter/texter/texter3.ui | 2 +- texter/texter/texter4.ui | 460 +++++++++++++++++++++++++++++++- texter/texter/texter_ui.py | 10 +- 6 files changed, 770 insertions(+), 52 deletions(-) diff --git a/texter/texter/build.sh b/texter/texter/build.sh index 2239a83..5a54324 100644 --- a/texter/texter/build.sh +++ b/texter/texter/build.sh @@ -1,2 +1,2 @@ -# pykdeuic4-python2.7 -o texter_ui.py texter3.ui -pykdeuic4-python2.7 -o text_sorter_ui.py texter4.ui +pyuic4 -o texter_ui.py texter3.ui +# pykdeuic4-python2.7 -o text_sorter_ui.py texter4.ui diff --git a/texter/texter/main.py b/texter/texter/main.py index 8c827a7..85c44c5 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -12,6 +12,7 @@ from operator import itemgetter from PyQt4 import QtCore, QtGui + from PyKDE4.kdecore import ki18n, KCmdLineArgs, KAboutData from PyKDE4.kdeui import KDialog, KActionCollection, KRichTextWidget, KComboBox, KPushButton, KRichTextWidget, KMainWindow, KToolBar, KApplication, KAction, KToolBarSpacerAction, KSelectAction, KToggleAction, KShortcut @@ -106,6 +107,104 @@ class TextSorterDialog(QtGui.QWidget, Ui_TextSorterDialog): self.text_list.clicked.emit(index) +class TextAnimation(QtCore.QObject): + animation_started = QtCore.pyqtSignal() + animation_finished = QtCore.pyqtSignal() + animation_stopped = QtCore.pyqtSignal() + + def __init__(self, parent=None): + super(TextAnimation, self).__init__(parent) + self.animated_document = None + self.cursor_position = 0 + self.src_cursor = None + self.area = None + self.dst_cursor = None + self.text = None + self.it = None + self.timer = None + self.dst_current_block = None + + def start_animation(self, animated_document, area, cursor_position): + print "start_animation", animated_document, area, cursor_position + if self.timer is not None: + print "timer is not None" + return False + self.animated_document = animated_document + self.area = area + self.cursor_position = cursor_position + + self.src_cursor = QtGui.QTextCursor(self.animated_document) + self.src_cursor.setPosition(0) + + self.dst_cursor = self.area.textCursor() + self.dst_cursor.setPosition(self.cursor_position) + self.timer = QtCore.QTimer(self) + self.timer.timeout.connect(self.slot_animate) + parent = self.parent() + parent.slot_clear_live() + #self.dst_cursor.setPosition(self.cursor_position) + self.timer.start(70) + print "timer started" + return True + + def slot_animate(self): + print "slot_animate" + self.animation_started.emit() + parent = self.parent() + + if self.it is None: + self.it = self.animated_document.rootFrame().begin() + #self.src_block = self.it.currentBlock() + #area_rootFrame = self.area.document().rootFrame() + #area_rootFrame.setFrameFormat(rootFrame.frameFormat()) + #print "it is none", repr(self.src_block.text()) + + if not self.it.atEnd(): + if self.text is None: + self.src_block = self.it.currentBlock() + text = unicode(self.src_block.text()) + print "text", repr(text) + self.text = iter(text) + src_block_format = self.src_block.blockFormat() + if self.dst_current_block is not None: + print "insert new block" + self.dst_cursor.insertBlock(src_block_format) + self.dst_current_block = self.dst_current_block.next() + else: + self.dst_current_block = self.dst_cursor.block() + dst_char_format = self.dst_current_block.charFormat() + src_char_format = self.src_block.charFormat() + src_font_point_size = src_char_format.fontPointSize() + dst_char_format.setFontPointSize(src_font_point_size) + print "src font size", src_font_point_size + parent.default_size = src_font_point_size + parent.font.setPointSize(parent.default_size) + parent.live_text.setFontSize(parent.default_size) + parent.live_text.setFont(parent.font) + parent.live_size_action.setFontSize(parent.default_size) + #parent.live_text.document().setDefaultFont(parent.font) + + try: + char = self.text.next() + print "char", char + self.dst_cursor.insertText(char) + except StopIteration: + print "end of block" + self.it += 1 + self.text = None + else: + self.timer.stop() + self.timer.timeout.disconnect(self.slot_animate) + self.timer.deleteLater() + self.dst_current_block = None + self.it = None + self.text = None + self.animation_finished.emit() + self.timer = None + print "animation end" + print + + class MainWindow(KMainWindow, Ui_MainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) @@ -125,6 +224,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.live_actions = list() self.current = 0 self.model = TextModel(self) + self.animation = TextAnimation(self) + self.db_dirty = False self.is_auto_publish = False @@ -142,22 +243,22 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.createLiveActions() self.createPreviewActions() - self.slot_load() - self.preview_text.document().setDefaultFont(self.font) + #self.preview_text.document().setDefaultFont(self.font) self.preview_text.setFont(self.font) self.preview_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) self.preview_editor_collection = KActionCollection(self) self.preview_text.createActions(self.preview_editor_collection) self.live_text.setRichTextSupport(KRichTextWidget.RichTextSupport(0xffffffff)) - self.live_text.document().setDefaultFont(self.font) + #self.live_text.document().setDefaultFont(self.font) self.live_text.setFont(self.font) self.live_editor_collection = KActionCollection(self) self.live_text.createActions(self.live_editor_collection) self.filter_editor_actions() self.toolbar.insertSeparator(self.publish_action) self.toolbar.addSeparator() + self.slot_load() self.show() @@ -181,7 +282,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.next_action.triggered.connect(self.slot_next_item) self.previous_action.triggered.connect(self.slot_previous_item) - app.aboutToQuit.connect(self.kill_streaming) self.getLiveCoords() print "desktop", app.desktop().availableGeometry() @@ -309,12 +409,10 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.next_action.setIconText("next") self.next_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Right)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - self.text_editor_action = KToggleAction(self.preview_text_collection) + self.text_editor_action = self.preview_text_collection.addAction("text_editor_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("document-open")) self.text_editor_action.setIcon(icon) - self.text_editor_action.setIconText("sort") - self.preview_text_collection.addAction("text editor", self.text_editor_action) - self.text_editor_action.setObjectName("text_editor_action") + self.text_editor_action.setIconText("edit") self.text_editor_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_O)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) self.auto_publish_action = KToggleAction(self.preview_text_collection) @@ -323,6 +421,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.auto_publish_action.setIcon(icon) self.auto_publish_action.setObjectName("auto_publish_action") self.auto_publish_action.setIconText("auto publish") + self.auto_publish_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_P)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) self.save_action = self.preview_text_collection.addAction("save_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("document-save")) @@ -338,11 +437,11 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.streaming_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_1)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) self.preview_text_collection.addAction("stream", self.streaming_action) - #self.valign_action = self.preview_text_collection.addAction("valign_action") - #icon = QtGui.QIcon.fromTheme(_fromUtf8("media-stop")) - #self.valign_action.setIcon(icon) - #self.valign_action.setIconText("valign") - #self.valign_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Plus)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + self.valign_action = self.preview_text_collection.addAction("valign_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-stop")) + self.valign_action.setIcon(icon) + self.valign_action.setIconText("valign") + self.valign_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Plus)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) self.spacer = KToolBarSpacerAction(self.preview_text_collection) self.preview_text_collection.addAction("spacer", self.spacer) @@ -355,18 +454,18 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.text_combo.setObjectName("text_combo") self.preview_text_collection.addAction("saved texts", self.text_combo) - def slot_auto_publish(self, state): - self.is_auto_publish = bool(state) + def closeEvent(self, event): + self.stop_streaming() + if self.db_dirty: + self.dialog = KDialog(self) + self.dialog.setCaption("4.48 texter - text db not saved") + label = QtGui.QLabel("The Text database is not saved. Do you want to save before exit?", self.dialog) + self.dialog.setMainWidget(label) + self.dialog.setButtons(KDialog.ButtonCodes(KDialog.Ok | KDialog.Cancel)) + self.dialog.okClicked.connect(self.slot_save) + self.dialog.exec_() - - def slot_toggle_streaming(self): - if self.ffserver is None: - self.start_streaming() - else: - self.kill_streaming() - - - def kill_streaming(self): + def stop_streaming(self): self.is_streaming = False if self.ffmpeg is not None: self.ffmpeg.kill() @@ -402,6 +501,17 @@ class MainWindow(KMainWindow, Ui_MainWindow): return re.sub(" +", " ", text.replace("\n", " ")).strip()[:20] + def slot_auto_publish(self, state): + self.is_auto_publish = bool(state) + + + def slot_toggle_streaming(self): + if self.ffserver is None: + self.start_streaming() + else: + self.stop_streaming() + + def slot_next_item(self): self.current = (self.text_combo.currentItem() + 1) % len(self.model.text_db) self.text_combo.setCurrentItem(self.current) @@ -422,7 +532,10 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_publish(self): - self.live_text.setTextOrHtml(self.preview_text.textOrHtml()) + print "publish" + #self.live_text.setTextOrHtml(self.preview_text.textOrHtml()) + self.animation.start_animation(self.preview_text.document(), self.live_text, 0) + self.slot_clear_live() def slot_live_font_size(self, action): print "font_size" @@ -453,7 +566,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.preview_text.setFontSize(self.default_size) self.preview_text.setFont(self.font) self.preview_size_action.setFontSize(self.default_size) - self.preview_text.document().setDefaultFont(self.font) + #self.preview_text.document().setDefaultFont(self.font) def slot_set_live_defaults(self): @@ -463,7 +576,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.live_text.setFontSize(self.default_size) self.live_text.setFont(self.font) self.live_size_action.setFontSize(self.default_size) - self.live_text.document().setDefaultFont(self.font) + #self.live_text.document().setDefaultFont(self.font) def slot_clear_live(self): @@ -506,7 +619,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): return self.preview_text.setTextOrHtml(text) if self.is_auto_publish: - self.live_text.setTextOrHtml(text) + self.slot_publish() def slot_save_live_text(self): @@ -530,6 +643,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.model.modelReset.emit() action = self.text_combo.addAction(preview) self.text_combo.setCurrentAction(action) + self.db_dirty = True def slot_save_preview_text(self): text = self.preview_text.toHtml() @@ -553,6 +667,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.model.modelReset.emit() action = self.text_combo.addAction(preview) self.text_combo.setCurrentAction(action) + self.db_dirty = True def slot_save(self): path = os.path.expanduser("~/.texter") @@ -617,6 +732,9 @@ class MainWindow(KMainWindow, Ui_MainWindow): #painter.drawEllipse(QtCore.QRectF(-radius, margin, 2*radius, 2*radius)) #painter.end() + def slot_valign(self): + self.animation = TextAnimation(self.preview_text.document(), ) + def slot_open_dialog(self): self.dialog = KDialog(self) self.dialog_widget = TextSorterDialog(self.dialog) @@ -628,8 +746,10 @@ class MainWindow(KMainWindow, Ui_MainWindow): global_height = rect.height() x = global_width - pos_x - 10 self.dialog.setFixedSize(x, global_height-40); + self.dialog.okClicked.connect(self.fill_combo_box) self.dialog.exec_() - self.fill_combo_box() + self.dialog.deleteLater() + self.dialog = None def slot_load(self): path = os.path.expanduser("~/.texter") @@ -648,7 +768,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.fill_combo_box() self.text_combo.setCurrentItem(0) self.slot_load_preview_text(0) - self.slot_load_preview_text(0) + def main(): diff --git a/texter/texter/text_sorter_ui.py b/texter/texter/text_sorter_ui.py index 5e34386..da3d9e0 100644 --- a/texter/texter/text_sorter_ui.py +++ b/texter/texter/text_sorter_ui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding=UTF-8 # -# Generated by pykdeuic4 from texter4.ui on Wed Apr 16 00:27:54 2014 +# Generated by pykdeuic4 from texter4.ui on Sat Apr 19 19:39:29 2014 # # WARNING! All changes to this file will be lost. from PyKDE4 import kdecore @@ -25,49 +25,203 @@ except AttributeError: class Ui_TextSorterDialog(object): def setupUi(self, TextSorterDialog): TextSorterDialog.setObjectName(_fromUtf8("TextSorterDialog")) - TextSorterDialog.resize(662, 716) + TextSorterDialog.resize(1073, 938) self.verticalLayout = QtGui.QVBoxLayout(TextSorterDialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.text_list = QtGui.QListView(TextSorterDialog) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(2) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.text_list.sizePolicy().hasHeightForWidth()) + self.text_list.setSizePolicy(sizePolicy) self.text_list.setMinimumSize(QtCore.QSize(0, 576)) self.text_list.setMaximumSize(QtCore.QSize(16777215, 576)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(128, 125, 123)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(128, 125, 123)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) - brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) self.text_list.setPalette(palette) self.text_list.setObjectName(_fromUtf8("text_list")) self.horizontalLayout_2.addWidget(self.text_list) self.text_preview = KRichTextWidget(TextSorterDialog) - self.text_preview.setMinimumSize(QtCore.QSize(0, 576)) - self.text_preview.setMaximumSize(QtCore.QSize(16777215, 576)) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) + sizePolicy.setHorizontalStretch(8) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.text_preview.sizePolicy().hasHeightForWidth()) + self.text_preview.setSizePolicy(sizePolicy) + self.text_preview.setMinimumSize(QtCore.QSize(200, 576)) + self.text_preview.setMaximumSize(QtCore.QSize(768, 576)) palette = QtGui.QPalette() + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) - palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) + brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) + brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) + brush.setStyle(QtCore.Qt.SolidPattern) + palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) self.text_preview.setPalette(palette) self.text_preview.setReadOnly(True) self.text_preview.setObjectName(_fromUtf8("text_preview")) diff --git a/texter/texter/texter3.ui b/texter/texter/texter3.ui index bb7834f..34ecd42 100644 --- a/texter/texter/texter3.ui +++ b/texter/texter/texter3.ui @@ -218,7 +218,7 @@ - BlankCursor + ArrowCursor true diff --git a/texter/texter/texter4.ui b/texter/texter/texter4.ui index bf97ac0..2ff8e33 100644 --- a/texter/texter/texter4.ui +++ b/texter/texter/texter4.ui @@ -6,8 +6,8 @@ 0 0 - 662 - 716 + 1073 + 938 @@ -18,6 +18,12 @@ + + + 2 + 0 + + 0 @@ -33,6 +39,15 @@ + + + + 255 + 255 + 255 + + + @@ -51,8 +66,26 @@ + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + @@ -71,8 +104,26 @@ + + + + 0 + 0 + 0 + + + + + + + 128 + 125 + 123 + + + @@ -85,9 +136,18 @@ - 255 - 255 - 255 + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 @@ -98,21 +158,108 @@ + + + 8 + 0 + + - 0 + 200 576 - 16777215 + 768 576 + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + @@ -122,8 +269,134 @@ + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + @@ -133,9 +406,117 @@ + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + - + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + 255 @@ -144,6 +525,69 @@ + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + diff --git a/texter/texter/texter_ui.py b/texter/texter/texter_ui.py index 730e3c3..c6f94c7 100644 --- a/texter/texter/texter_ui.py +++ b/texter/texter/texter_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'texter3.ui' # -# Created: Wed Apr 16 20:48:51 2014 +# Created: Sat Apr 19 21:56:41 2014 # by: PyQt4 UI code generator 4.10.3 # # WARNING! All changes made in this file will be lost! @@ -57,8 +57,8 @@ class Ui_MainWindow(object): self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.live_text = KRichTextWidget(self.centralwidget) - self.live_text.setMinimumSize(QtCore.QSize(772,580)) - self.live_text.setMaximumSize(QtCore.QSize(772,580)) + self.live_text.setMinimumSize(QtCore.QSize(775, 578)) + self.live_text.setMaximumSize(QtCore.QSize(775, 578)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) @@ -97,7 +97,7 @@ class Ui_MainWindow(object): brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Link, brush) self.live_text.setPalette(palette) - self.live_text.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.BlankCursor)) + self.live_text.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.live_text.setAutoFillBackground(True) self.live_text.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.live_text.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) @@ -113,7 +113,7 @@ class Ui_MainWindow(object): sizePolicy.setHeightForWidth(self.preview_text.sizePolicy().hasHeightForWidth()) self.preview_text.setSizePolicy(sizePolicy) self.preview_text.setMinimumSize(QtCore.QSize(300, 577)) - self.preview_text.setMaximumSize(QtCore.QSize(772,580)) + self.preview_text.setMaximumSize(QtCore.QSize(769, 577)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) From 007ec565e18370c56eb9e69fff94eeb2dab8b8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Tue, 22 Apr 2014 11:10:08 +0200 Subject: [PATCH 02/14] finished animation feature, rearranged buttons and cleaned up the code --- texter/texter/main.py | 345 ++++----- texter/texter/text_model.py | 9 +- texter/texter/text_sorter_ui.py | 25 +- texter/texter/texter3.ui | 10 +- texter/texter/texter4.ui | 1167 +++++++++++++++---------------- texter/texter/texter_ui.py | 8 +- 6 files changed, 748 insertions(+), 816 deletions(-) diff --git a/texter/texter/main.py b/texter/texter/main.py index 85c44c5..01762ee 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -35,7 +35,8 @@ for path in QtGui.QIcon.themeSearchPaths(): print "%s/%s" % (path, QtGui.QIcon.themeName()) -# NOTE: if the QIcon.fromTheme method does not find any icons, you can set a theme +# NOTE: if the QIcon.fromTheme method does not find any icons, you can use +# qtconfig and set a default theme or copy|symlink an existing theme dir to hicolor # in your local icon directory: # ln -s /your/icon/theme/directory $HOME/.icons/hicolor @@ -95,12 +96,14 @@ class TextSorterDialog(QtGui.QWidget, Ui_TextSorterDialog): return True def slot_show_text(self, model_index): - self.text_preview.setTextOrHtml(self.parent().parent().model.text_db[model_index.row()][1]) + try: + self.text_preview.setTextOrHtml(self.parent().parent().model.text_db[model_index.row()][1]) + except IndexError: + pass def slot_removeItem(self): index = self.text_list.currentIndex().row() - print "remote index", index self.model.removeRows(index, 1) index = self.model.index(0, 0) self.text_list.setCurrentIndex(index) @@ -114,84 +117,83 @@ class TextAnimation(QtCore.QObject): def __init__(self, parent=None): super(TextAnimation, self).__init__(parent) - self.animated_document = None + self.src_text_edit = None self.cursor_position = 0 self.src_cursor = None - self.area = None + self.dst_text_edit = None self.dst_cursor = None + self.src_block = None + self.fragment_iter = None self.text = None self.it = None self.timer = None self.dst_current_block = None + self.fonts = dict() + self.count = 0 - def start_animation(self, animated_document, area, cursor_position): - print "start_animation", animated_document, area, cursor_position + def start_animation(self, src_text_edit, dst_text_edit, cursor_position): if self.timer is not None: - print "timer is not None" return False - self.animated_document = animated_document - self.area = area + self.parent().slot_clear_live() + self.src_document = QtGui.QTextDocument(self) + self.src_document.setHtml(src_text_edit.document().toHtml()) + self.src_text_edit = src_text_edit + self.dst_text_edit = dst_text_edit self.cursor_position = cursor_position - self.src_cursor = QtGui.QTextCursor(self.animated_document) - self.src_cursor.setPosition(0) - - self.dst_cursor = self.area.textCursor() + self.dst_cursor = self.dst_text_edit.textCursor() self.dst_cursor.setPosition(self.cursor_position) self.timer = QtCore.QTimer(self) self.timer.timeout.connect(self.slot_animate) - parent = self.parent() - parent.slot_clear_live() - #self.dst_cursor.setPosition(self.cursor_position) - self.timer.start(70) - print "timer started" + self.parent().slot_clear_live() + self.timer.start(55) return True def slot_animate(self): - print "slot_animate" self.animation_started.emit() parent = self.parent() if self.it is None: - self.it = self.animated_document.rootFrame().begin() - #self.src_block = self.it.currentBlock() - #area_rootFrame = self.area.document().rootFrame() - #area_rootFrame.setFrameFormat(rootFrame.frameFormat()) - #print "it is none", repr(self.src_block.text()) + src_root_frame = self.src_document.rootFrame() + self.it = src_root_frame.begin() + self.dst_text_edit.document().rootFrame().setFrameFormat(src_root_frame.frameFormat()) if not self.it.atEnd(): - if self.text is None: + if self.src_block is None: self.src_block = self.it.currentBlock() - text = unicode(self.src_block.text()) - print "text", repr(text) - self.text = iter(text) + self.fragment_iter = self.src_block.begin() + src_block_format = self.src_block.blockFormat() + src_char_format = self.src_block.charFormat() if self.dst_current_block is not None: - print "insert new block" self.dst_cursor.insertBlock(src_block_format) self.dst_current_block = self.dst_current_block.next() else: self.dst_current_block = self.dst_cursor.block() - dst_char_format = self.dst_current_block.charFormat() - src_char_format = self.src_block.charFormat() - src_font_point_size = src_char_format.fontPointSize() - dst_char_format.setFontPointSize(src_font_point_size) - print "src font size", src_font_point_size - parent.default_size = src_font_point_size - parent.font.setPointSize(parent.default_size) - parent.live_text.setFontSize(parent.default_size) - parent.live_text.setFont(parent.font) - parent.live_size_action.setFontSize(parent.default_size) - #parent.live_text.document().setDefaultFont(parent.font) + self.dst_cursor.setBlockFormat(src_block_format) + self.dst_cursor.setBlockCharFormat(src_char_format) + self.dst_cursor.setCharFormat(src_char_format) - try: - char = self.text.next() - print "char", char - self.dst_cursor.insertText(char) - except StopIteration: - print "end of block" + self.dst_cursor.mergeBlockCharFormat(src_char_format) + self.dst_cursor.mergeCharFormat(src_char_format) + self.dst_cursor.mergeBlockFormat(src_block_format) + + if not self.fragment_iter.atEnd(): + if self.text is None: + fragment = self.fragment_iter.fragment() + self.text = iter(unicode(fragment.text())) + self.fragment_char_format = fragment.charFormat() + self.dst_cursor.setCharFormat(self.fragment_char_format) + + try: + char = self.text.next() + self.dst_cursor.insertText(char) + except StopIteration: + self.fragment_iter += 1 + self.text = None + else: self.it += 1 - self.text = None + self.src_block = None else: self.timer.stop() self.timer.timeout.disconnect(self.slot_animate) @@ -201,8 +203,8 @@ class TextAnimation(QtCore.QObject): self.text = None self.animation_finished.emit() self.timer = None - print "animation end" - print + + self.count += 1 class MainWindow(KMainWindow, Ui_MainWindow): @@ -226,6 +228,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.model = TextModel(self) self.animation = TextAnimation(self) self.db_dirty = False + self.is_animate = False self.is_auto_publish = False @@ -234,15 +237,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.font = QtGui.QFont("monospace", self.default_size) self.font.setStyleHint(QtGui.QFont.TypeWriter) - self.toolbar = KToolBar(self, True, True) - self.toolbar.setAllowedAreas(QtCore.Qt.BottomToolBarArea) - self.toolbar.setMovable(False) - self.toolbar.setFloatable(False) - self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) - self.addToolBar(QtCore.Qt.BottomToolBarArea, self.toolbar) - self.createLiveActions() - self.createPreviewActions() + self.create_toolbar() #self.preview_text.document().setDefaultFont(self.font) self.preview_text.setFont(self.font) @@ -256,14 +252,12 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.live_editor_collection = KActionCollection(self) self.live_text.createActions(self.live_editor_collection) self.filter_editor_actions() - self.toolbar.insertSeparator(self.publish_action) - self.toolbar.addSeparator() self.slot_load() self.show() self.save_action.triggered.connect(self.slot_save) - #self.valign_action.triggered.connect(self.slot_valign) + self.publish_action.triggered.connect(self.slot_publish) self.clear_live_action.triggered.connect(self.slot_clear_live) self.clear_preview_action.triggered.connect(self.slot_clear_preview) @@ -276,6 +270,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.save_preview_action.triggered.connect(self.slot_save_preview_text) self.streaming_action.triggered.connect(self.slot_toggle_streaming) self.auto_publish_action.toggled.connect(self.slot_auto_publish) + self.typer_animation_action.toggled.connect(self.slot_toggle_animation) self.preview_size_action.triggered[QtGui.QAction].connect(self.slot_preview_font_size) self.live_size_action.triggered[QtGui.QAction].connect(self.slot_live_font_size) @@ -351,108 +346,116 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.slot_set_live_defaults() - def createLiveActions(self): - self.toolbar.show() - self.live_text_collection = KActionCollection(self) - self.live_text_collection.addAssociatedWidget(self.toolbar) + def create_toolbar(self): - self.clear_live_action = self.live_text_collection.addAction("clear_live_action") + self.toolbar = KToolBar(self, True, True) + self.toolbar.setAllowedAreas(QtCore.Qt.BottomToolBarArea) + self.toolbar.setMovable(False) + self.toolbar.setFloatable(False) + self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) + self.addToolBar(QtCore.Qt.BottomToolBarArea, self.toolbar) + + self.toolbar.show() + self.action_collection = KActionCollection(self) + self.action_collection.addAssociatedWidget(self.toolbar) + + self.clear_live_action = self.action_collection.addAction("clear_live_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-clear")) self.clear_live_action.setIcon(icon) self.clear_live_action.setIconText("clear live") self.clear_live_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Q)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - - self.save_live_action = self.live_text_collection.addAction("save_live_action") + self.save_live_action = self.action_collection.addAction("save_live_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("document-new")) self.save_live_action.setIcon(icon) self.save_live_action.setIconText("save live") self.save_live_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_W)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - def createPreviewActions(self): - self.toolbar.show() - self.preview_text_collection = KActionCollection(self) - self.preview_text_collection.addAssociatedWidget(self.toolbar) - - self.clear_preview_action = self.preview_text_collection.addAction("clear_preview_action") + self.clear_preview_action = self.action_collection.addAction("clear_preview_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-clear")) self.clear_preview_action.setIcon(icon) self.clear_preview_action.setIconText("clear preview") #self.clear_preview_action.setObjectName("clear_preview") self.clear_preview_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_A)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - - self.save_preview_action = self.preview_text_collection.addAction("save_preview_action") + self.save_preview_action = self.action_collection.addAction("save_preview_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("document-new")) self.save_preview_action.setIcon(icon) self.save_preview_action.setIconText("save preview") self.save_preview_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_S)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - - self.publish_action = self.preview_text_collection.addAction("publish_action") - icon = QtGui.QIcon.fromTheme(_fromUtf8("media-playback-start")) + self.publish_action = self.action_collection.addAction("publish_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("edit-copy")) self.publish_action.setIcon(icon) self.publish_action.setIconText("publish") self.publish_action.setShortcutConfigurable(True) self.publish_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Return)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + self.toolbar.insertSeparator(self.publish_action) - self.previous_action = self.preview_text_collection.addAction("previous_action") - icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-backward")) - self.previous_action.setIcon(icon) - self.previous_action.setIconText("previous") - self.previous_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Left)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - - self.next_action = self.preview_text_collection.addAction("next_action") - icon = QtGui.QIcon.fromTheme(_fromUtf8("media-skip-forward")) - self.next_action.setIcon(icon) - self.next_action.setIconText("next") - self.next_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Right)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - - self.text_editor_action = self.preview_text_collection.addAction("text_editor_action") - icon = QtGui.QIcon.fromTheme(_fromUtf8("document-open")) - self.text_editor_action.setIcon(icon) - self.text_editor_action.setIconText("edit") - self.text_editor_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_O)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - - self.auto_publish_action = KToggleAction(self.preview_text_collection) - self.preview_text_collection.addAction("auto publish", self.auto_publish_action) + self.auto_publish_action = KToggleAction(self.action_collection) + self.action_collection.addAction("auto publish", self.auto_publish_action) icon = QtGui.QIcon.fromTheme(_fromUtf8("view-refresh")) self.auto_publish_action.setIcon(icon) self.auto_publish_action.setObjectName("auto_publish_action") self.auto_publish_action.setIconText("auto publish") - self.auto_publish_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_P)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + self.auto_publish_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_P)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - self.save_action = self.preview_text_collection.addAction("save_action") + self.typer_animation_action = KToggleAction(self.action_collection) + icon = QtGui.QIcon.fromTheme(_fromUtf8("media-playback-stop")) + self.typer_animation_action.setIcon(icon) + self.typer_animation_action.setIconText("animate") + self.typer_animation_action.setObjectName("typer_animation_action") + self.typer_animation_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_M)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + self.action_collection.addAction("typer_animation_action", self.typer_animation_action) + + self.text_editor_action = self.action_collection.addAction("text_editor_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("document-open-data")) + self.text_editor_action.setIcon(icon) + self.text_editor_action.setIconText("edit") + self.text_editor_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_O)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + self.toolbar.insertSeparator(self.text_editor_action) + + self.save_action = self.action_collection.addAction("save_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("document-save")) self.save_action.setIcon(icon) self.save_action.setIconText("save") self.save_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_S)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - self.streaming_action = KToggleAction(self.preview_text_collection) + self.streaming_action = KToggleAction(self.action_collection) icon = QtGui.QIcon.fromTheme(_fromUtf8("media-record")) self.streaming_action.setIcon(icon) self.streaming_action.setIconText("stream") self.streaming_action.setObjectName("stream") self.streaming_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_1)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - self.preview_text_collection.addAction("stream", self.streaming_action) + self.action_collection.addAction("stream", self.streaming_action) - self.valign_action = self.preview_text_collection.addAction("valign_action") - icon = QtGui.QIcon.fromTheme(_fromUtf8("media-stop")) - self.valign_action.setIcon(icon) - self.valign_action.setIconText("valign") - self.valign_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_Plus)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + spacer = KToolBarSpacerAction(self.action_collection) + self.action_collection.addAction("1_spacer", spacer) - self.spacer = KToolBarSpacerAction(self.preview_text_collection) - self.preview_text_collection.addAction("spacer", self.spacer) + self.previous_action = self.action_collection.addAction("previous_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("go-previous-view-page")) + self.previous_action.setIcon(icon) + self.previous_action.setIconText("previous") + self.previous_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Left)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) - self.text_combo = KSelectAction(self.preview_text_collection) + self.text_combo = KSelectAction(self.action_collection) self.text_combo.setEditable(False) icon = QtGui.QIcon.fromTheme(_fromUtf8("document-open-recent")) self.text_combo.setIcon(icon) self.text_combo.setIconText("saved texts") self.text_combo.setObjectName("text_combo") - self.preview_text_collection.addAction("saved texts", self.text_combo) + self.action_collection.addAction("saved texts", self.text_combo) + + self.next_action = self.action_collection.addAction("next_action") + icon = QtGui.QIcon.fromTheme(_fromUtf8("go-next-view-page")) + self.next_action.setIcon(icon) + self.next_action.setIconText("next") + self.next_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_Right)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) + + self.toolbar.addSeparator() + def closeEvent(self, event): self.stop_streaming() @@ -478,7 +481,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): public_rect = self.live_text.geometry() global_rect = QtCore.QRect(self.mapToGlobal(public_rect.topLeft()), self.mapToGlobal(public_rect.bottomRight())) self.ffserver = subprocess.Popen("ffserver -f /etc/ffserver.conf", shell=True, close_fds=True) - self.ffmpeg = subprocess.Popen("ffmpeg -f x11grab -s 768x576 -r 25 -i :0.0+%d,%d -vcodec mjpeg -pix_fmt yuvj422p -r 25 -aspect 4:3 http://localhost:8090/webcam.ffm" % (global_rect.x()+1, global_rect.y()+1), shell=True, close_fds=True) + self.ffmpeg = subprocess.Popen("ffmpeg -f x11grab -s 768x576 -r 30 -i :0.0+%d,%d -vcodec mjpeg -pix_fmt yuvj444p -r 30 -aspect 4:3 http://localhost:8090/webcam.ffm" % (global_rect.x()+5, global_rect.y()+5), shell=True, close_fds=True) self.is_streaming = True def focusChanged(self, old, new): @@ -504,6 +507,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_auto_publish(self, state): self.is_auto_publish = bool(state) + def slot_toggle_animation(self, state): + self.is_animate = bool(state) def slot_toggle_streaming(self): if self.ffserver is None: @@ -513,15 +518,21 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_next_item(self): - self.current = (self.text_combo.currentItem() + 1) % len(self.model.text_db) - self.text_combo.setCurrentItem(self.current) - self.slot_load_preview_text(self.current) + try: + self.current = (self.text_combo.currentItem() + 1) % len(self.model.text_db) + self.text_combo.setCurrentItem(self.current) + self.slot_load_preview_text(self.current) + except ZeroDivisionError: + pass def slot_previous_item(self): - self.current = (self.text_combo.currentItem() - 1) % len(self.model.text_db) - self.text_combo.setCurrentItem(self.current) - self.slot_load_preview_text(self.current) + try: + self.current = (self.text_combo.currentItem() - 1) % len(self.model.text_db) + self.text_combo.setCurrentItem(self.current) + self.slot_load_preview_text(self.current) + except ZeroDivisionError: + pass def slot_toggleToolbox(self, index): @@ -532,20 +543,19 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_publish(self): - print "publish" - #self.live_text.setTextOrHtml(self.preview_text.textOrHtml()) - self.animation.start_animation(self.preview_text.document(), self.live_text, 0) - self.slot_clear_live() + if self.is_animate: + self.animation.start_animation(self.preview_text, self.live_text, 0) + else: + self.live_text.setTextOrHtml(self.preview_text.textOrHtml()) + def slot_live_font_size(self, action): - print "font_size" self.default_size = self.live_size_action.fontSize() self.slot_set_preview_defaults() self.slot_set_live_defaults() def slot_preview_font_size(self, action): - print "font_size" self.default_size = self.preview_size_action.fontSize() self.slot_set_live_defaults() self.slot_set_preview_defaults() @@ -566,17 +576,15 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.preview_text.setFontSize(self.default_size) self.preview_text.setFont(self.font) self.preview_size_action.setFontSize(self.default_size) - #self.preview_text.document().setDefaultFont(self.font) + self.preview_text.document().setDefaultFont(self.font) def slot_set_live_defaults(self): self.live_center_action.setChecked(True) self.live_text.alignCenter() - self.font.setPointSize(self.default_size) self.live_text.setFontSize(self.default_size) - self.live_text.setFont(self.font) self.live_size_action.setFontSize(self.default_size) - #self.live_text.document().setDefaultFont(self.font) + self.live_text.document().setDefaultFont(self.font) def slot_clear_live(self): @@ -589,7 +597,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.slot_set_preview_defaults() def fill_combo_box(self): - print "fill_combo_box" self.text_combo.clear() for preview, text in self.model.text_db: self.text_combo.addAction(preview) @@ -653,20 +660,13 @@ class MainWindow(KMainWindow, Ui_MainWindow): return old_item = self.model.text_by_preview(preview) if old_item is not None: - suffix = 1 - while 1: - tmp_preview = "%s_%d" % (preview, suffix) - tmp = self.model.text_by_preview(tmp_preview) - if tmp is None: - preview = tmp_preview - break - else: - suffix += 1 - - self.model.text_db.append([preview, text]) - self.model.modelReset.emit() - action = self.text_combo.addAction(preview) - self.text_combo.setCurrentAction(action) + ix, old_preview, old_text = old_item + self.model.text_db[ix][1] = text + else: + self.model.text_db.append([preview, text]) + action = self.text_combo.addAction(preview) + self.model.modelReset.emit() + self.text_combo.setCurrentAction(action) self.db_dirty = True def slot_save(self): @@ -679,61 +679,8 @@ class MainWindow(KMainWindow, Ui_MainWindow): return else: cPickle.dump(self.model.text_db, f, cPickle.HIGHEST_PROTOCOL) + self.db_dirty = False - #def slot_valign(self): - #fm = QtGui.QFontMetrics(self.font) - ##h = fn.height() - ##max_lines = 576 / h - ##text = unicode(self.preview_text.toPlainText()) - ##text = text.strip().strip("\n") - ##lines = text.count("\n") + 1 - ##self.preview_text.setTextOrHtml("\n" * ((max_lines - lines) / 2) + text) - ##self.statusBar().showMessage("text lines = %d, line height = %d, max lines = %d" % (lines, h, max_lines)) - #text_layout = QtGui.QTextLayout(self.preview_text.textOrHtml(), self.font, self.preview_text) - - ##self.text_combo.setCurrentAction(action) - - #margin = 10. - #radius = min(self.preview_text.width()/2.0, self.preview_text.height()/2.0) - margin - #print "radius", type(radius), radius - - #lineHeight = float(fm.height()) - #print "lineHeight", type(lineHeight), lineHeight - #y = 0. - - #text_layout.beginLayout() - - #while 1: - #line = text_layout.createLine() - #if not line.isValid(): - #break - - #x1 = max(0.0, pow(pow(radius,2)-pow(radius-y,2), 0.5)) - #x2 = max(0.0, pow(pow(radius,2)-pow(radius-(y+lineHeight),2), 0.5)) - #x = max(x1, x2) + margin - #lineWidth = (self.preview_text.width() - margin) - x - - #line.setLineWidth(lineWidth) - #line.setPosition(QtCore.QPointF(x, margin+y)) - #y += line.height() - - #text_layout.endLayout() - - #painter = QtGui.QPainter() - #painter.begin(self.preview_text) - #painter.setRenderHint(QtGui.QPainter.Antialiasing) - #painter.fillRect(self.rect(), QtCore.Qt.black) - #painter.setBrush(QtGui.QBrush(QtCore.Qt.white)) - #painter.setPen(QtGui.QPen(QtCore.Qt.white)) - #text_layout.draw(painter, QtCore.QPoint(0,0)) - - #painter.setBrush(QtGui.QBrush(QtGui.QColor("#a6ce39"))) - #painter.setPen(QtGui.QPen(QtCore.Qt.black)) - #painter.drawEllipse(QtCore.QRectF(-radius, margin, 2*radius, 2*radius)) - #painter.end() - - def slot_valign(self): - self.animation = TextAnimation(self.preview_text.document(), ) def slot_open_dialog(self): self.dialog = KDialog(self) @@ -745,7 +692,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): global_width = rect.width() global_height = rect.height() x = global_width - pos_x - 10 - self.dialog.setFixedSize(x, global_height-40); + #self.dialog.setFixedSize(x, global_height-40) self.dialog.okClicked.connect(self.fill_combo_box) self.dialog.exec_() self.dialog.deleteLater() diff --git a/texter/texter/text_model.py b/texter/texter/text_model.py index 9a77880..2135be6 100644 --- a/texter/texter/text_model.py +++ b/texter/texter/text_model.py @@ -61,21 +61,16 @@ class TextModel(QtCore.QAbstractTableModel): return True def removeRows(self, row, count, parent=QtCore.QModelIndex()): - print "removeRows", row, count - print map(itemgetter(0), self.text_db) self.beginRemoveRows(QtCore.QModelIndex(), row, row+count+1) for i in range(row, row+count): - print "del", i, self.text_db[row] self.text_db.pop(row) - print "after" - print map(itemgetter(0), self.text_db) self.endRemoveRows() return True def text_by_preview(self, preview): - for title, text in self.text_db: + for ix, (title, text) in enumerate(self.text_db): if title == preview: - return title, text + return ix, title, text return None diff --git a/texter/texter/text_sorter_ui.py b/texter/texter/text_sorter_ui.py index da3d9e0..1579de3 100644 --- a/texter/texter/text_sorter_ui.py +++ b/texter/texter/text_sorter_ui.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # coding=UTF-8 # -# Generated by pykdeuic4 from texter4.ui on Sat Apr 19 19:39:29 2014 +# Generated by pykdeuic4 from texter4.ui on Mon Apr 21 01:34:50 2014 # # WARNING! All changes to this file will be lost. from PyKDE4 import kdecore @@ -25,18 +25,19 @@ except AttributeError: class Ui_TextSorterDialog(object): def setupUi(self, TextSorterDialog): TextSorterDialog.setObjectName(_fromUtf8("TextSorterDialog")) - TextSorterDialog.resize(1073, 938) + TextSorterDialog.resize(1084, 633) self.verticalLayout = QtGui.QVBoxLayout(TextSorterDialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.horizontalLayout_2 = QtGui.QHBoxLayout() - self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) - self.text_list = QtGui.QListView(TextSorterDialog) + self.splitter = QtGui.QSplitter(TextSorterDialog) + self.splitter.setOrientation(QtCore.Qt.Horizontal) + self.splitter.setObjectName(_fromUtf8("splitter")) + self.text_list = QtGui.QListView(self.splitter) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(2) + sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.text_list.sizePolicy().hasHeightForWidth()) self.text_list.setSizePolicy(sizePolicy) - self.text_list.setMinimumSize(QtCore.QSize(0, 576)) + self.text_list.setMinimumSize(QtCore.QSize(200, 576)) self.text_list.setMaximumSize(QtCore.QSize(16777215, 576)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) @@ -77,14 +78,13 @@ class Ui_TextSorterDialog(object): palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) self.text_list.setPalette(palette) self.text_list.setObjectName(_fromUtf8("text_list")) - self.horizontalLayout_2.addWidget(self.text_list) - self.text_preview = KRichTextWidget(TextSorterDialog) + self.text_preview = KRichTextWidget(self.splitter) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(8) + sizePolicy.setHorizontalStretch(100) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.text_preview.sizePolicy().hasHeightForWidth()) self.text_preview.setSizePolicy(sizePolicy) - self.text_preview.setMinimumSize(QtCore.QSize(200, 576)) + self.text_preview.setMinimumSize(QtCore.QSize(0, 576)) self.text_preview.setMaximumSize(QtCore.QSize(768, 576)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) @@ -225,8 +225,7 @@ class Ui_TextSorterDialog(object): self.text_preview.setPalette(palette) self.text_preview.setReadOnly(True) self.text_preview.setObjectName(_fromUtf8("text_preview")) - self.horizontalLayout_2.addWidget(self.text_preview) - self.verticalLayout.addLayout(self.horizontalLayout_2) + self.verticalLayout.addWidget(self.splitter) self.kbuttongroup = KButtonGroup(TextSorterDialog) self.kbuttongroup.setObjectName(_fromUtf8("kbuttongroup")) self.horizontalLayout = QtGui.QHBoxLayout(self.kbuttongroup) diff --git a/texter/texter/texter3.ui b/texter/texter/texter3.ui index 34ecd42..245650c 100644 --- a/texter/texter/texter3.ui +++ b/texter/texter/texter3.ui @@ -217,11 +217,8 @@ - - ArrowCursor - - true + false Qt::ScrollBarAlwaysOff @@ -324,14 +321,11 @@ - - Qt::ActionsContextMenu - preview text - true + false QFrame::StyledPanel diff --git a/texter/texter/texter4.ui b/texter/texter/texter4.ui index 2ff8e33..7e7b432 100644 --- a/texter/texter/texter4.ui +++ b/texter/texter/texter4.ui @@ -6,8 +6,8 @@ 0 0 - 1073 - 938 + 1084 + 633 @@ -15,588 +15,587 @@ - - - - - - 2 - 0 - - - - - 0 - 576 - - - - - 16777215 - 576 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 128 - 125 - 123 - - - - - - - 128 - 125 - 123 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - - - - - 8 - 0 - - - - - 200 - 576 - - - - - 768 - 576 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 255 - 255 - 220 - - - - - - - 0 - 0 - 0 - - - - - - - - true - - - - + + + Qt::Horizontal + + + + + 1 + 0 + + + + + 200 + 576 + + + + + 16777215 + 576 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + 128 + 125 + 123 + + + + + + + 128 + 125 + 123 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + + + + + 100 + 0 + + + + + 0 + 576 + + + + + 768 + 576 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 255 + 255 + 220 + + + + + + + 0 + 0 + 0 + + + + + + + + true + + + diff --git a/texter/texter/texter_ui.py b/texter/texter/texter_ui.py index c6f94c7..88a4b04 100644 --- a/texter/texter/texter_ui.py +++ b/texter/texter/texter_ui.py @@ -2,7 +2,7 @@ # Form implementation generated from reading ui file 'texter3.ui' # -# Created: Sat Apr 19 21:56:41 2014 +# Created: Mon Apr 21 22:38:51 2014 # by: PyQt4 UI code generator 4.10.3 # # WARNING! All changes made in this file will be lost! @@ -97,8 +97,7 @@ class Ui_MainWindow(object): brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Link, brush) self.live_text.setPalette(palette) - self.live_text.viewport().setProperty("cursor", QtGui.QCursor(QtCore.Qt.ArrowCursor)) - self.live_text.setAutoFillBackground(True) + self.live_text.setAutoFillBackground(False) self.live_text.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.live_text.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.live_text.setAcceptRichText(True) @@ -134,8 +133,7 @@ class Ui_MainWindow(object): brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) self.preview_text.setPalette(palette) - self.preview_text.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) - self.preview_text.setAutoFillBackground(True) + self.preview_text.setAutoFillBackground(False) self.preview_text.setFrameShape(QtGui.QFrame.StyledPanel) self.preview_text.setAcceptRichText(True) self.preview_text.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByKeyboard|QtCore.Qt.LinksAccessibleByMouse|QtCore.Qt.TextBrowserInteraction|QtCore.Qt.TextEditable|QtCore.Qt.TextEditorInteraction|QtCore.Qt.TextSelectableByKeyboard|QtCore.Qt.TextSelectableByMouse) From fce69b46eecf447a515475d65327da2c92bfdc40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 23 Apr 2014 14:14:02 +0200 Subject: [PATCH 03/14] added better chaosc init script to repo --- config_files/chaosc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 config_files/chaosc diff --git a/config_files/chaosc b/config_files/chaosc new file mode 100755 index 0000000..ea5b027 --- /dev/null +++ b/config_files/chaosc @@ -0,0 +1,21 @@ +#!/sbin/runscript + +depend() { + need net + use dns localmount + after bootmisc + provide chaosc +} + + +start() { + ebegin "starting chaosc" + start-stop-daemon --start --pidfile /var/run/chaosc.pid --make-pidfile --user sarah --group sarah --background --exec /usr/bin/chaosc + eend $? +} + +stop() { + ebegin "stopping chaosc" + start-stop-daemon --stop --quiet --pidfile /var/run/chaosc.pid + eend $? +} From 2effe315a71a209151f73552b8ecc8279a7bb800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 23 Apr 2014 16:31:19 +0200 Subject: [PATCH 04/14] implemented dump_grabber --- dump_grabber/dump_grabber/main.py | 273 ++++++++++++++++++++++++++++-- 1 file changed, 261 insertions(+), 12 deletions(-) diff --git a/dump_grabber/dump_grabber/main.py b/dump_grabber/dump_grabber/main.py index 4c6ab8b..f0186ca 100644 --- a/dump_grabber/dump_grabber/main.py +++ b/dump_grabber/dump_grabber/main.py @@ -6,12 +6,40 @@ import sys, os, random from PyQt4 import QtCore, QtGui - +from PyQt4.QtCore import QBuffer, QByteArray, QIODevice from dump_grabber_ui import Ui_MainWindow from PyKDE4.kdecore import ki18n, KCmdLineArgs, KAboutData from PyKDE4.kdeui import KMainWindow, KApplication +from datetime import datetime +import threading +import Queue +import traceback +import numpy as np +import string +import time +import random +import socket +import os.path +from os import curdir, sep +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from SocketServer import ThreadingMixIn, ForkingMixIn +import select +import re + +from collections import deque + +from chaosc.argparser_groups import * +from chaosc.lib import resolve_host + +try: + from chaosc.c_osc_lib import OSCMessage, decode_osc +except ImportError as e: + print(e) + from chaosc.osc_lib import OSCMessage, decode_osc + + appName = "dump_grabber" catalog = "dump_grabber" programName = ki18n("dump_grabber") @@ -23,7 +51,7 @@ KCmdLineArgs.init (sys.argv, aboutData) app = KApplication() class MainWindow(KMainWindow, Ui_MainWindow): - def __init__(self, parent=None): + def __init__(self, parent=None, columns=3): super(MainWindow, self).__init__(parent) self.setupUi(self) self.graphics_view.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) @@ -39,24 +67,245 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.font_metrics = QtGui.QFontMetrics(self.default_font) self.line_height = self.font_metrics.height() self.num_lines = 775/self.line_height - + self.graphics_scene.setFont(self.default_font) print "font", self.default_font.family(), self.default_font.pixelSize(), self.default_font.pointSize() self.brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) self.brush.setStyle(QtCore.Qt.SolidPattern) - pos_y = 0 - for i in range(self.num_lines): - text = self.graphics_scene.addSimpleText("osc address:/test/foo/bar arguments:[%d] types=[\"i\"]" % random.randint(0,255), self.default_font) - text.setBrush(self.brush) - text.setPos(0, i * self.line_height) - pos_y += self.line_height + self.column_count = columns + self.columns = [["" for j in range(self.num_lines)] + for i in range(columns)] + self.column_width = 775 / columns + self.column_heads = [self.num_lines - 1] * columns self.graphics_view.show() + def add_text(self, column, text): + head = self.column_heads[column] + text_item = self.graphics_scene.addSimpleText(text, self.default_font) + #text_item.setPen(QtCore.Qt.red) + if column == 0: + text_item.setBrush(QtCore.Qt.red) + elif column == 1: + text_item.setBrush(QtCore.Qt.green) + elif column == 2: + text_item.setBrush(QtCore.Qt.blue) + text_item.setPos(column * self.column_width, head * self.line_height) + print "head", column, head + self.columns[column][head] = text_item + self.column_heads[column] = (head - 1) % self.num_lines + + + def render(self): + image = QtGui.QImage(768, 576, QtGui.QImage.Format_ARGB32_Premultiplied) + image.fill(QtCore.Qt.black) + painter = QtGui.QPainter(image) + #painter.setPen(QtCore.Qt.white) + painter.setFont(self.default_font) + self.graphics_view.render(painter, target=QtCore.QRectF(0,0,768,576),source=QtCore.QRect(0,0,768,576)) + return image + + +class OSCThread(threading.Thread): + def __init__(self, args): + super(OSCThread, self).__init__() + self.args = args + self.running = True + + self.client_address = resolve_host(args.client_host, args.client_port, args.address_family) + + self.chaosc_address = chaosc_host, chaosc_port = resolve_host(args.chaosc_host, args.chaosc_port, args.address_family) + + self.osc_sock = socket.socket(args.address_family, 2, 17) + self.osc_sock.bind(self.client_address) + self.osc_sock.setblocking(0) + + print "%s: starting up osc receiver on '%s:%d'" % ( + datetime.now().strftime("%x %X"), self.client_address[0], self.client_address[1]) + + self.subscribe_me() + + def subscribe_me(self): + """Use this procedure for a quick'n dirty subscription to your chaosc instance. + + :param chaosc_address: (chaosc_host, chaosc_port) + :type chaosc_address: tuple + + :param receiver_address: (host, port) + :type receiver_address: tuple + + :param token: token to get authorized for subscription + :type token: str + """ + print "%s: subscribing to '%s:%d' with label %r" % (datetime.now().strftime("%x %X"), self.chaosc_address[0], self.chaosc_address[1], self.args.subscriber_label) + msg = OSCMessage("/subscribe") + msg.appendTypedArg(self.client_address[0], "s") + msg.appendTypedArg(self.client_address[1], "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.sendto(msg.encode_osc(), self.chaosc_address) + + + def unsubscribe_me(self): + if self.args.keep_subscribed: + return + + print "%s: unsubscribing from '%s:%d'" % (datetime.now().strftime("%x %X"), self.chaosc_address[0], self.chaosc_address[1]) + msg = OSCMessage("/unsubscribe") + msg.appendTypedArg(self.client_address[0], "s") + msg.appendTypedArg(self.client_address[1], "i") + msg.appendTypedArg(self.args.authenticate, "s") + self.osc_sock.sendto(msg.encode_osc(), self.chaosc_address) + + def run(self): + + while self.running: + try: + reads, writes, errs = select.select([self.osc_sock], [], [], 0.05) + except Exception, e: + print "select error", e + pass + else: + if reads: + try: + osc_input, address = self.osc_sock.recvfrom(8192) + osc_address, typetags, messages = decode_osc(osc_input, 0, len(osc_input)) + print osc_address, typetags, messages + if osc_address.find("ekg") != -1 or osc_address.find("plot") != -1: + queue.put_nowait((osc_address, messages)) + except Exception, e: + print "recvfrom error", e + else: + queue.put_nowait(("/bjoern/ekg", [0])) + queue.put_nowait(("/merle/ekg", [0])) + queue.put_nowait(("/uwe/ekg", [0])) + + self.unsubscribe_me() + print "OSCThread is going down" + + +queue = Queue.Queue() + +class MyHandler(BaseHTTPRequestHandler): + + def do_GET(self): + + try: + self.path=re.sub('[^.a-zA-Z0-9]', "",str(self.path)) + if self.path=="" or self.path==None or self.path[:1]==".": + self.send_error(403,'Forbidden') + + + if self.path.endswith(".html"): + directory = os.path.dirname(os.path.abspath(__file__)) + data = open(os.path.join(directory, self.path), "rb").read() + self.send_response(200) + self.send_header('Content-type', 'text/html') + self.end_headers() + self.wfile.write(data) + elif self.path.endswith(".mjpeg"): + self.thread = thread = OSCThread(self.server.args) + thread.daemon = True + thread.start() + window = MainWindow() + window.show() + + self.send_response(200) + self.send_header("Content-Type", "multipart/x-mixed-replace; boundary=--aaboundary") + self.end_headers() + + event_loop = QtCore.QEventLoop() + while 1: + event_loop.processEvents() + app.sendPostedEvents(None, 0) + while 1: + try: + osc_address, args = queue.get_nowait() + print osc_address, args + except Queue.Empty: + break + else: + if "merle" in osc_address: + window.add_text(0, "%s = %s" % (osc_address[7:], ", ".join([str(i) for i in args]))) + elif "uwe" in osc_address: + window.add_text(1, "%s = %s" % (osc_address[5:], ", ".join([str(i) for i in args]))) + elif "bjoern" in osc_address: + window.add_text(2, "%s = %s" % (osc_address[8:], ", ".join([str(i) for i in args]))) + + img = window.render() + buffer = QBuffer() + buffer.open(QIODevice.WriteOnly) + img.save(buffer, "JPG", 100) + img.save("/tmp/test.jpg", "JPG") + + JpegData = buffer.data() + self.wfile.write("--aaboundary\r\nContent-Type: image/jpeg\r\nContent-length: %d\r\n\r\n%s\r\n\r\n\r\n" % (len(JpegData), JpegData)) + + JpegData = None + buffer = None + img = None + + elif self.path.endswith(".jpeg"): + directory = os.path.dirname(os.path.abspath(__file__)) + data = open(os.path.join(directory, self.path), "rb").read() + self.send_response(200) + self.send_header('Content-type','image/jpeg') + self.end_headers() + self.wfile.write(data) + return + except (KeyboardInterrupt, SystemError): + print "queue size", queue.qsize() + if hasattr(self, "thread") and self.thread is not None: + self.thread.running = False + self.thread.join() + self.thread = None + except IOError, e: + print "ioerror", e, e[0] + print dir(e) + if e[0] in (32, 104): + if hasattr(self, "thread") and self.thread is not None: + self.thread.running = False + self.thread.join() + self.thread = None + else: + print '-'*40 + print 'Exception happened during processing of request from' + traceback.print_exc() # XXX But this goes to stderr! + print '-'*40 + self.send_error(404,'File Not Found: %s' % self.path) + + +class JustAHTTPServer(HTTPServer): + pass + + def main(): - window = MainWindow() - window.show() - app.exec_() + arg_parser = ArgParser("ekgplotter") + arg_parser.add_global_group() + client_group = arg_parser.add_client_group() + arg_parser.add_argument(client_group, '-x', "--http_host", default="::", + help='my host, defaults to "::"') + arg_parser.add_argument(client_group, '-X', "--http_port", default=9000, + type=int, help='my port, defaults to 9000') + arg_parser.add_chaosc_group() + arg_parser.add_subscriber_group() + args = arg_parser.finalize() + + http_host, http_port = resolve_host(args.http_host, args.http_port, args.address_family) + + server = JustAHTTPServer((http_host, http_port), MyHandler) + server.address_family = args.address_family + server.args = args + print "%s: starting up http server on '%s:%d'" % ( + datetime.now().strftime("%x %X"), http_host, http_port) + + try: + server.serve_forever() + except KeyboardInterrupt: + print '^C received, shutting down server' + server.socket.close() + sys.exit(0) if ( __name__ == '__main__' ): From 7e93c46547a061da2ddc275f47e7ac7be0e5aa89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 23 Apr 2014 17:46:14 +0200 Subject: [PATCH 05/14] fixed layout and colors --- dump_grabber/dump_grabber/main.py | 46 +++++++++++++++++++------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/dump_grabber/dump_grabber/main.py b/dump_grabber/dump_grabber/main.py index f0186ca..300ab17 100644 --- a/dump_grabber/dump_grabber/main.py +++ b/dump_grabber/dump_grabber/main.py @@ -64,6 +64,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.default_font = QtGui.QFont("Monospace", 14) self.default_font.setStyleHint(QtGui.QFont.Monospace) self.default_font.setBold(True) + self.blue_color = QtGui.QColor(47,147,235) self.font_metrics = QtGui.QFontMetrics(self.default_font) self.line_height = self.font_metrics.height() self.num_lines = 775/self.line_height @@ -72,28 +73,38 @@ class MainWindow(KMainWindow, Ui_MainWindow): print "font", self.default_font.family(), self.default_font.pixelSize(), self.default_font.pointSize() self.brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) self.brush.setStyle(QtCore.Qt.SolidPattern) + self.column_width = 775 / columns self.column_count = columns - self.columns = [["" for j in range(self.num_lines)] - for i in range(columns)] - self.column_width = 775 / columns - self.column_heads = [self.num_lines - 1] * columns + self.columns = list() + for i in range(columns): + column = list() + for j in range(self.num_lines): + text_item = self.graphics_scene.addSimpleText("", self.default_font) + if column == 0: + text_item.setBrush(QtCore.Qt.red) + elif column == 1: + text_item.setBrush(QtCore.Qt.green) + elif column == 2: + text_item.setBrush(self.blue_color) + text_item.setPos(j * self.line_height, i * self.column_width) + column.append(text_item) + self.columns.append(column) self.graphics_view.show() def add_text(self, column, text): - head = self.column_heads[column] text_item = self.graphics_scene.addSimpleText(text, self.default_font) - #text_item.setPen(QtCore.Qt.red) if column == 0: text_item.setBrush(QtCore.Qt.red) elif column == 1: text_item.setBrush(QtCore.Qt.green) elif column == 2: - text_item.setBrush(QtCore.Qt.blue) - text_item.setPos(column * self.column_width, head * self.line_height) - print "head", column, head - self.columns[column][head] = text_item - self.column_heads[column] = (head - 1) % self.num_lines + text_item.setBrush(self.blue_color) + old_item = self.columns[column].pop(0) + self.graphics_scene.removeItem(old_item) + self.columns[column].append(text_item) + for ix, text_item in enumerate(self.columns[column]): + text_item.setPos(column * self.column_width, ix * self.line_height) def render(self): @@ -162,7 +173,7 @@ class OSCThread(threading.Thread): while self.running: try: - reads, writes, errs = select.select([self.osc_sock], [], [], 0.05) + reads, writes, errs = select.select([self.osc_sock], [], [], 0.01) except Exception, e: print "select error", e pass @@ -171,15 +182,14 @@ class OSCThread(threading.Thread): try: osc_input, address = self.osc_sock.recvfrom(8192) osc_address, typetags, messages = decode_osc(osc_input, 0, len(osc_input)) - print osc_address, typetags, messages if osc_address.find("ekg") != -1 or osc_address.find("plot") != -1: queue.put_nowait((osc_address, messages)) except Exception, e: print "recvfrom error", e else: - queue.put_nowait(("/bjoern/ekg", [0])) - queue.put_nowait(("/merle/ekg", [0])) - queue.put_nowait(("/uwe/ekg", [0])) + queue.put_nowait(("/bjoern/ekg", [random.randint(0,255)])) + queue.put_nowait(("/merle/ekg", [random.randint(0,255)])) + queue.put_nowait(("/uwe/ekg", [random.randint(0,255)])) self.unsubscribe_me() print "OSCThread is going down" @@ -209,7 +219,7 @@ class MyHandler(BaseHTTPRequestHandler): thread.daemon = True thread.start() window = MainWindow() - window.show() + window.hide() self.send_response(200) self.send_header("Content-Type", "multipart/x-mixed-replace; boundary=--aaboundary") @@ -222,7 +232,6 @@ class MyHandler(BaseHTTPRequestHandler): while 1: try: osc_address, args = queue.get_nowait() - print osc_address, args except Queue.Empty: break else: @@ -245,6 +254,7 @@ class MyHandler(BaseHTTPRequestHandler): JpegData = None buffer = None img = None + time.sleep(0.03) elif self.path.endswith(".jpeg"): directory = os.path.dirname(os.path.abspath(__file__)) From 7ac50d1e79b81ea36c3f9e1b390e8d1214288ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 23 Apr 2014 17:58:50 +0200 Subject: [PATCH 06/14] done with this --- dump_grabber/dump_grabber/main.py | 4 +-- dump_grabber/setup.py | 50 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 dump_grabber/setup.py diff --git a/dump_grabber/dump_grabber/main.py b/dump_grabber/dump_grabber/main.py index 300ab17..9eb649f 100644 --- a/dump_grabber/dump_grabber/main.py +++ b/dump_grabber/dump_grabber/main.py @@ -61,7 +61,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.graphics_scene = QtGui.QGraphicsScene(self) self.graphics_scene.setSceneRect(0,0, 775, 580) self.graphics_view.setScene(self.graphics_scene) - self.default_font = QtGui.QFont("Monospace", 14) + self.default_font = QtGui.QFont("Monospace", 16) self.default_font.setStyleHint(QtGui.QFont.Monospace) self.default_font.setBold(True) self.blue_color = QtGui.QColor(47,147,235) @@ -291,7 +291,7 @@ class JustAHTTPServer(HTTPServer): def main(): - arg_parser = ArgParser("ekgplotter") + arg_parser = ArgParser("dump_grabber") arg_parser.add_global_group() client_group = arg_parser.add_client_group() arg_parser.add_argument(client_group, '-x', "--http_host", default="::", diff --git a/dump_grabber/setup.py b/dump_grabber/setup.py new file mode 100644 index 0000000..48cf6f7 --- /dev/null +++ b/dump_grabber/setup.py @@ -0,0 +1,50 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +from distribute_setup import use_setuptools +use_setuptools() + +import sys +from setuptools import find_packages, setup + +if sys.version_info >= (3,): + extras['use_2to3'] = True + +setup( + name='dump_grabber', + version="0.1", + packages=find_packages(exclude=["scripts",]), + + include_package_data = True, + + exclude_package_data = {'': ['.gitignore']}, + + # installing unzipped + zip_safe = False, + + # predefined extension points, e.g. for plugins + entry_points = """ + [console_scripts] + dump_grabber = dump_grabber.main:main + """, + # pypi metadata + author = "Stefan Kögl", + + # FIXME: add author email + author_email = "", + description = "osc messages logging terminal as mjpeg stream, uses 3 columns", + + # FIXME: add long_description + long_description = """ + """, + + # FIXME: add license + license = "LGPL", + + # FIXME: add keywords + keywords = "", + + # FIXME: add download url + url = "", + test_suite='tests' +) From 28e0cc3bc10963b8d21e44a42ff77fc0594127de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 23 Apr 2014 18:16:47 +0200 Subject: [PATCH 07/14] reduced cpu load from 104% with ffmpeg x11grab, ffserver and konsole to 32% with my implementation - yeah --- dump_grabber/dump_grabber/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dump_grabber/dump_grabber/main.py b/dump_grabber/dump_grabber/main.py index 9eb649f..3a47354 100644 --- a/dump_grabber/dump_grabber/main.py +++ b/dump_grabber/dump_grabber/main.py @@ -254,7 +254,7 @@ class MyHandler(BaseHTTPRequestHandler): JpegData = None buffer = None img = None - time.sleep(0.03) + time.sleep(0.05) elif self.path.endswith(".jpeg"): directory = os.path.dirname(os.path.abspath(__file__)) From f5352f247a4d4ebf0845d027f26e0a8974b65fd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 23 Apr 2014 18:35:15 +0200 Subject: [PATCH 08/14] reduced cpu load --- ekgplotter/ekgplotter/main.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index e4fc94c..98e7ce6 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -54,18 +54,12 @@ from pyqtgraph.widgets.PlotWidget import PlotWidget from chaosc.argparser_groups import * from chaosc.lib import resolve_host -try: - from chaosc.c_osc_lib import * -except ImportError: - from chaosc.osc_lib import * - - try: - from chaosc.c_osc_lib import decode_osc + from chaosc.c_osc_lib import OSCMessage, decode_osc except ImportError as e: print(e) - from chaosc.osc_lib import decode_osc + from chaosc.osc_lib import OSCMessage, decode_osc @@ -137,7 +131,7 @@ class OSCThread(threading.Thread): while self.running: try: - reads, writes, errs = select.select([self.osc_sock], [], [], 0.05) + reads, writes, errs = select.select([self.osc_sock], [], [], 0.01) except Exception, e: print "select error", e pass @@ -407,6 +401,7 @@ class MyHandler(BaseHTTPRequestHandler): #s = np.clip(dt*3., 0, 1) #fps = fps * (1-s) + (1.0/dt) * s #print '%0.2f fps' % fps + time.sleep(0.05) elif self.path.endswith(".jpeg"): directory = os.path.dirname(os.path.abspath(__file__)) From dcd8e49f8568f0078b4c4aaab442c88eb40ad15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 23 Apr 2014 19:19:05 +0200 Subject: [PATCH 09/14] better --- dump_grabber/dump_grabber/main.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dump_grabber/dump_grabber/main.py b/dump_grabber/dump_grabber/main.py index 3a47354..4e875d8 100644 --- a/dump_grabber/dump_grabber/main.py +++ b/dump_grabber/dump_grabber/main.py @@ -61,7 +61,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.graphics_scene = QtGui.QGraphicsScene(self) self.graphics_scene.setSceneRect(0,0, 775, 580) self.graphics_view.setScene(self.graphics_scene) - self.default_font = QtGui.QFont("Monospace", 16) + self.default_font = QtGui.QFont("Monospace", 14) self.default_font.setStyleHint(QtGui.QFont.Monospace) self.default_font.setBold(True) self.blue_color = QtGui.QColor(47,147,235) @@ -182,14 +182,11 @@ class OSCThread(threading.Thread): try: osc_input, address = self.osc_sock.recvfrom(8192) osc_address, typetags, messages = decode_osc(osc_input, 0, len(osc_input)) - if osc_address.find("ekg") != -1 or osc_address.find("plot") != -1: - queue.put_nowait((osc_address, messages)) + queue.put_nowait((osc_address, messages)) except Exception, e: print "recvfrom error", e else: - queue.put_nowait(("/bjoern/ekg", [random.randint(0,255)])) - queue.put_nowait(("/merle/ekg", [random.randint(0,255)])) - queue.put_nowait(("/uwe/ekg", [random.randint(0,255)])) + pass self.unsubscribe_me() print "OSCThread is going down" From 2837ab938908bcf6090fed0d6b1d8345bbd7480b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 24 Apr 2014 09:32:16 +0200 Subject: [PATCH 10/14] more init scripts --- config_files/dump_grabber | 21 +++++++++++++++++++++ config_files/ekgplotter | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 config_files/dump_grabber create mode 100755 config_files/ekgplotter diff --git a/config_files/dump_grabber b/config_files/dump_grabber new file mode 100755 index 0000000..287caeb --- /dev/null +++ b/config_files/dump_grabber @@ -0,0 +1,21 @@ +#!/sbin/runscript + +depend() { + need net + use dns localmount chaosc + after bootmisc + provide dump_grabber +} + + +start() { + ebegin "starting dump_grabber" + start-stop-daemon --start --pidfile /var/run/dump_grabber.pid --make-pidfile --user stefan --group stefan --background --exec env DISPLAY=:0 /usr/bin/dump_grabber + eend $? +} + +stop() { + ebegin "stopping dump_grabber" + start-stop-daemon --stop --quiet --pidfile /var/run/dump_grabber.pid + eend $? +} diff --git a/config_files/ekgplotter b/config_files/ekgplotter new file mode 100755 index 0000000..f53f3dd --- /dev/null +++ b/config_files/ekgplotter @@ -0,0 +1,21 @@ +#!/sbin/runscript + +depend() { + need net + use dns localmount chaosc + after bootmisc + provide ekgplotter +} + + +start() { + ebegin "starting ekgplotter" + start-stop-daemon --start --pidfile /var/run/ekgplotter.pid --make-pidfile --user stefan --group stefan --background --exec env DISPLAY=:0 /usr/bin/ekgplotter + eend $? +} + +stop() { + ebegin "stopping ekgplotter" + start-stop-daemon --stop --quiet --pidfile /var/run/ekgplotter.pid + eend $? +} From f3a8e8c4dd73d212d45c7abb757e3d2a19bd1ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 24 Apr 2014 09:33:43 +0200 Subject: [PATCH 11/14] cleaned up dump_grabber --- dump_grabber/dump_grabber/main.py | 125 +++++++++++++++++------------- 1 file changed, 70 insertions(+), 55 deletions(-) diff --git a/dump_grabber/dump_grabber/main.py b/dump_grabber/dump_grabber/main.py index 4e875d8..8a50453 100644 --- a/dump_grabber/dump_grabber/main.py +++ b/dump_grabber/dump_grabber/main.py @@ -2,44 +2,63 @@ # -*- coding: utf-8 -*- -import sys, os, random +# This file is part of chaosc and psychosis +# +# chaosc is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# chaosc is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with chaosc. If not, see . +# +# Copyright (C) 2014 Stefan Kögl -from PyQt4 import QtCore, QtGui -from PyQt4.QtCore import QBuffer, QByteArray, QIODevice +from __future__ import absolute_import -from dump_grabber_ui import Ui_MainWindow +import os + +from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from chaosc.argparser_groups import * +from chaosc.lib import logger, resolve_host +from collections import deque +from datetime import datetime +from dump_grabber.dump_grabber_ui import Ui_MainWindow +from os import curdir, sep from PyKDE4.kdecore import ki18n, KCmdLineArgs, KAboutData from PyKDE4.kdeui import KMainWindow, KApplication - -from datetime import datetime -import threading -import Queue -import traceback -import numpy as np -import string -import time -import random -import socket -import os.path -from os import curdir, sep -from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer +from PyQt4 import QtCore, QtGui +from PyQt4.QtCore import QBuffer, QByteArray, QIODevice from SocketServer import ThreadingMixIn, ForkingMixIn -import select + +import logging +import numpy as np + +import os.path +import Queue +import random import re - -from collections import deque - -from chaosc.argparser_groups import * -from chaosc.lib import resolve_host +import select +import socket +import string +import sys +import threading +import time +import traceback try: from chaosc.c_osc_lib import OSCMessage, decode_osc except ImportError as e: - print(e) from chaosc.osc_lib import OSCMessage, decode_osc + appName = "dump_grabber" catalog = "dump_grabber" programName = ki18n("dump_grabber") @@ -50,6 +69,11 @@ aboutData = KAboutData(appName, catalog, programName, version) KCmdLineArgs.init (sys.argv, aboutData) app = KApplication() + +fh = logging.FileHandler(os.path.expanduser("~/.chaosc/dump_grabber.log")) +fh.setLevel(logging.DEBUG) +logger.addHandler(fh) + class MainWindow(KMainWindow, Ui_MainWindow): def __init__(self, parent=None, columns=3): super(MainWindow, self).__init__(parent) @@ -70,7 +94,6 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.num_lines = 775/self.line_height self.graphics_scene.setFont(self.default_font) - print "font", self.default_font.family(), self.default_font.pixelSize(), self.default_font.pointSize() self.brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) self.brush.setStyle(QtCore.Qt.SolidPattern) self.column_width = 775 / columns @@ -108,7 +131,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): def render(self): - image = QtGui.QImage(768, 576, QtGui.QImage.Format_ARGB32_Premultiplied) + image = QtGui.QImage(768, 576, QtGui.QImage.Format_ARGB32) image.fill(QtCore.Qt.black) painter = QtGui.QPainter(image) #painter.setPen(QtCore.Qt.white) @@ -131,8 +154,7 @@ class OSCThread(threading.Thread): self.osc_sock.bind(self.client_address) self.osc_sock.setblocking(0) - print "%s: starting up osc receiver on '%s:%d'" % ( - datetime.now().strftime("%x %X"), self.client_address[0], self.client_address[1]) + logger.info("starting up osc receiver on '%s:%d'", self.client_address[0], self.client_address[1]) self.subscribe_me() @@ -148,7 +170,7 @@ class OSCThread(threading.Thread): :param token: token to get authorized for subscription :type token: str """ - print "%s: subscribing to '%s:%d' with label %r" % (datetime.now().strftime("%x %X"), self.chaosc_address[0], self.chaosc_address[1], self.args.subscriber_label) + logger.info("%s: subscribing to '%s:%d' with label %r", datetime.now().strftime("%x %X"), self.chaosc_address[0], self.chaosc_address[1], self.args.subscriber_label) msg = OSCMessage("/subscribe") msg.appendTypedArg(self.client_address[0], "s") msg.appendTypedArg(self.client_address[1], "i") @@ -162,7 +184,7 @@ class OSCThread(threading.Thread): if self.args.keep_subscribed: return - print "%s: unsubscribing from '%s:%d'" % (datetime.now().strftime("%x %X"), self.chaosc_address[0], self.chaosc_address[1]) + logger.info("unsubscribing from '%s:%d'", self.chaosc_address[0], self.chaosc_address[1]) msg = OSCMessage("/unsubscribe") msg.appendTypedArg(self.client_address[0], "s") msg.appendTypedArg(self.client_address[1], "i") @@ -175,7 +197,6 @@ class OSCThread(threading.Thread): try: reads, writes, errs = select.select([self.osc_sock], [], [], 0.01) except Exception, e: - print "select error", e pass else: if reads: @@ -184,12 +205,12 @@ class OSCThread(threading.Thread): osc_address, typetags, messages = decode_osc(osc_input, 0, len(osc_input)) queue.put_nowait((osc_address, messages)) except Exception, e: - print "recvfrom error", e + pass else: pass self.unsubscribe_me() - print "OSCThread is going down" + logger.info("OSCThread is going down") queue = Queue.Queue() @@ -242,8 +263,8 @@ class MyHandler(BaseHTTPRequestHandler): img = window.render() buffer = QBuffer() buffer.open(QIODevice.WriteOnly) - img.save(buffer, "JPG", 100) - img.save("/tmp/test.jpg", "JPG") + img.save(buffer, "JPG", 50) + img.save("/tmp/test.jpg", "JPG", 50) JpegData = buffer.data() self.wfile.write("--aaboundary\r\nContent-Type: image/jpeg\r\nContent-length: %d\r\n\r\n%s\r\n\r\n\r\n" % (len(JpegData), JpegData)) @@ -251,7 +272,7 @@ class MyHandler(BaseHTTPRequestHandler): JpegData = None buffer = None img = None - time.sleep(0.05) + time.sleep(0.06) elif self.path.endswith(".jpeg"): directory = os.path.dirname(os.path.abspath(__file__)) @@ -262,25 +283,26 @@ class MyHandler(BaseHTTPRequestHandler): self.wfile.write(data) return except (KeyboardInterrupt, SystemError): - print "queue size", queue.qsize() + #print "queue size", queue.qsize() if hasattr(self, "thread") and self.thread is not None: self.thread.running = False self.thread.join() self.thread = None except IOError, e: - print "ioerror", e, e[0] - print dir(e) + #print "ioerror", e, e[0] + #print dir(e) if e[0] in (32, 104): if hasattr(self, "thread") and self.thread is not None: self.thread.running = False self.thread.join() self.thread = None else: - print '-'*40 - print 'Exception happened during processing of request from' - traceback.print_exc() # XXX But this goes to stderr! - print '-'*40 - self.send_error(404,'File Not Found: %s' % self.path) + pass + #print '-'*40 + #print 'Exception happened during processing of request from' + #traceback.print_exc() # XXX But this goes to stderr! + #print '-'*40 + #self.send_error(404,'File Not Found: %s' % self.path) class JustAHTTPServer(HTTPServer): @@ -293,8 +315,8 @@ def main(): client_group = arg_parser.add_client_group() arg_parser.add_argument(client_group, '-x', "--http_host", default="::", help='my host, defaults to "::"') - arg_parser.add_argument(client_group, '-X', "--http_port", default=9000, - type=int, help='my port, defaults to 9000') + arg_parser.add_argument(client_group, '-X', "--http_port", default=9001, + type=int, help='my port, defaults to 9001') arg_parser.add_chaosc_group() arg_parser.add_subscriber_group() args = arg_parser.finalize() @@ -304,16 +326,9 @@ def main(): server = JustAHTTPServer((http_host, http_port), MyHandler) server.address_family = args.address_family server.args = args - print "%s: starting up http server on '%s:%d'" % ( - datetime.now().strftime("%x %X"), http_host, http_port) - - try: - server.serve_forever() - except KeyboardInterrupt: - print '^C received, shutting down server' - server.socket.close() - sys.exit(0) + logger.info("starting up http server on '%s:%d'", http_host, http_port) + server.serve_forever() if ( __name__ == '__main__' ): main() From 40ffb2e43d305d1d12ef99f0a844ab800a0aeecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 24 Apr 2014 09:34:37 +0200 Subject: [PATCH 12/14] cleaned up ekgplotter --- ekgplotter/ekgplotter/main.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index 98e7ce6..dbc1ba2 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -29,6 +29,7 @@ from datetime import datetime import threading import Queue import traceback +import logging import numpy as np import string import time @@ -52,9 +53,13 @@ import pyqtgraph as pg from pyqtgraph.widgets.PlotWidget import PlotWidget from chaosc.argparser_groups import * -from chaosc.lib import resolve_host +from chaosc.lib import logger, resolve_host +fh = logging.FileHandler(os.path.expanduser("~/.chaosc/ekgplotter.log")) +fh.setLevel(logging.DEBUG) +logger.addHandler(fh) + try: from chaosc.c_osc_lib import OSCMessage, decode_osc except ImportError as e: @@ -92,7 +97,7 @@ class OSCThread(threading.Thread): print "%s: starting up osc receiver on '%s:%d'" % ( datetime.now().strftime("%x %X"), self.client_address[0], self.client_address[1]) - self.subscribe_me() + #self.subscribe_me() def subscribe_me(self): """Use this procedure for a quick'n dirty subscription to your chaosc instance. @@ -140,16 +145,15 @@ class OSCThread(threading.Thread): try: osc_input, address = self.osc_sock.recvfrom(8192) osc_address, typetags, messages = decode_osc(osc_input, 0, len(osc_input)) - if osc_address.find("ekg") != -1 or osc_address.find("plot") != -1: - queue.put_nowait((osc_address, messages)) + queue.put_nowait((osc_address, messages)) except Exception, e: print "recvfrom error", e - else: - queue.put_nowait(("/bjoern/ekg", [0])) - queue.put_nowait(("/merle/ekg", [0])) - queue.put_nowait(("/uwe/ekg", [0])) + #else: + #queue.put_nowait(("/bjoern/ekg", [0])) + #queue.put_nowait(("/merle/ekg", [0])) + #queue.put_nowait(("/uwe/ekg", [0])) - self.unsubscribe_me() + #self.unsubscribe_me() print "OSCThread is going down" @@ -246,7 +250,7 @@ class EkgPlot(object): self.plot.showGrid(False, False) self.plot.setYRange(0, 255) self.plot.setXRange(0, num_data) - self.plot.resize(1280, 720) + self.plot.resize(768, 576) ba = self.plot.getAxis("bottom") bl = self.plot.getAxis("left") @@ -380,10 +384,12 @@ class MyHandler(BaseHTTPRequestHandler): plotter.update(osc_address, args[0]) exporter = pg.exporters.ImageExporter.ImageExporter(plotter.plot.plotItem) + exporter.parameters()['width'] = 768 img = exporter.export("tmpfile", True) buffer = QBuffer() buffer.open(QIODevice.WriteOnly) - img.save(buffer, "JPG", 100) + img.save(buffer, "JPG") + img.save("/tmp/test2.jpg", "JPG") JpegData = buffer.data() self.wfile.write("--aaboundary\r\nContent-Type: image/jpeg\r\nContent-length: %d\r\n\r\n%s\r\n\r\n\r\n" % (len(JpegData), JpegData)) From 8f57a6d36a12953ecb768e9fa0bf10a1f2b7b3d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 24 Apr 2014 10:49:54 +0200 Subject: [PATCH 13/14] fade animation --- texter/texter/main.py | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/texter/texter/main.py b/texter/texter/main.py index 01762ee..1ed9459 100644 --- a/texter/texter/main.py +++ b/texter/texter/main.py @@ -109,6 +109,63 @@ class TextSorterDialog(QtGui.QWidget, Ui_TextSorterDialog): self.text_list.setCurrentIndex(index) self.text_list.clicked.emit(index) +class FadeAnimation(QtCore.QObject): + animation_started = QtCore.pyqtSignal() + animation_finished = QtCore.pyqtSignal() + animation_stopped = QtCore.pyqtSignal() + + def __init__(self, live_text, fade_steps=6, parent=None): + super(FadeAnimation, self).__init__(parent) + self.live_text = live_text + self.fade_steps = fade_steps + self.current_alpha = 255 + self.timer = None + + + def start_animation(self): + print "start_animation" + self.animation_started.emit() + + if self.current_alpha == 255: + self.fade_delta = 255 / self.fade_steps + else: + self.fade_delta = -255 / self.fade_steps + self.timer = QtCore.QTimer(self) + self.timer.timeout.connect(self.slot_animate) + self.timer.start(100) + + + def slot_animate(self): + print "slot_animate" + print "current_alpha", self.current_alpha + if self.fade_delta > 0: + if self.current_alpha > 0: + self.live_text.setStyleSheet("color:%d, %d, %d;" % (self.current_alpha, self.current_alpha,self.current_alpha)) + self.current_alpha -= self.fade_delta + else: + self.live_text.setStyleSheet("color:black;") + self.current_alpha = 0 + self.timer.stop() + self.timer.timeout.disconnect(self.slot_animate) + self.timer.deleteLater() + self.timer = None + self.animation_finished.emit() + print "animation_finished" + else: + if self.current_alpha < 255: + self.live_text.setStyleSheet("color:%d,%d, %d;" % (self.current_alpha, self.current_alpha,self.current_alpha)) + self.current_alpha -= self.fade_delta + else: + self.live_text.setStyleSheet("color:white") + self.current_alpha = 255 + self.timer.stop() + self.timer.timeout.disconnect(self.slot_animate) + self.timer.deleteLater() + self.timer = None + self.animation_finished.emit() + print "animation_finished" + + class TextAnimation(QtCore.QObject): animation_started = QtCore.pyqtSignal() @@ -229,10 +286,13 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.animation = TextAnimation(self) self.db_dirty = False self.is_animate = False + self.fade_animation = None self.is_auto_publish = False self.setupUi(self) + + self.fade_animation = FadeAnimation(self.live_text, 6, self) self.font = QtGui.QFont("monospace", self.default_size) self.font.setStyleHint(QtGui.QFont.TypeWriter) @@ -274,6 +334,7 @@ class MainWindow(KMainWindow, Ui_MainWindow): self.preview_size_action.triggered[QtGui.QAction].connect(self.slot_preview_font_size) self.live_size_action.triggered[QtGui.QAction].connect(self.slot_live_font_size) + self.fade_action.triggered.connect(self.slot_fade) self.next_action.triggered.connect(self.slot_next_item) self.previous_action.triggered.connect(self.slot_previous_item) @@ -433,6 +494,12 @@ class MainWindow(KMainWindow, Ui_MainWindow): spacer = KToolBarSpacerAction(self.action_collection) self.action_collection.addAction("1_spacer", spacer) + + self.fade_action = self.action_collection.addAction("fade_action") + #icon = QtGui.QIcon.fromTheme(_fromUtf8("go-previous-view-page")) + #self.fade_action.setIcon(icon) + self.fade_action.setIconText("fade") + self.fade_action.setShortcut(KShortcut(QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F)), KAction.ShortcutTypes(KAction.ActiveShortcut | KAction.DefaultShortcut)) self.previous_action = self.action_collection.addAction("previous_action") icon = QtGui.QIcon.fromTheme(_fromUtf8("go-previous-view-page")) @@ -595,6 +662,10 @@ class MainWindow(KMainWindow, Ui_MainWindow): def slot_clear_preview(self): self.preview_text.clear() self.slot_set_preview_defaults() + + def slot_fade(self): + if self.fade_animation.timer is None: + self.fade_animation.start_animation() def fill_combo_box(self): self.text_combo.clear() From eaaddd80f28dc97ba4a5233dec4be191be229861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Thu, 24 Apr 2014 14:20:10 +0200 Subject: [PATCH 14/14] minor ekplotter update --- ekgplotter/ekgplotter/main.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ekgplotter/ekgplotter/main.py b/ekgplotter/ekgplotter/main.py index dbc1ba2..601d196 100644 --- a/ekgplotter/ekgplotter/main.py +++ b/ekgplotter/ekgplotter/main.py @@ -97,7 +97,7 @@ class OSCThread(threading.Thread): print "%s: starting up osc receiver on '%s:%d'" % ( datetime.now().strftime("%x %X"), self.client_address[0], self.client_address[1]) - #self.subscribe_me() + self.subscribe_me() def subscribe_me(self): """Use this procedure for a quick'n dirty subscription to your chaosc instance. @@ -148,12 +148,12 @@ class OSCThread(threading.Thread): queue.put_nowait((osc_address, messages)) except Exception, e: print "recvfrom error", e - #else: - #queue.put_nowait(("/bjoern/ekg", [0])) - #queue.put_nowait(("/merle/ekg", [0])) - #queue.put_nowait(("/uwe/ekg", [0])) + else: + queue.put_nowait(("/bjoern/ekg", [0])) + queue.put_nowait(("/merle/ekg", [0])) + queue.put_nowait(("/uwe/ekg", [0])) - #self.unsubscribe_me() + self.unsubscribe_me() print "OSCThread is going down" @@ -245,6 +245,7 @@ class EkgPlot(object): def __init__(self, actor_names, num_data, colors): self.plot = pg.PlotWidget() self.plot.hide() + #self.plot.show() #self.plot.setLabel('left', "

Amplitude

") #self.plot.setLabel('bottom', "

Time

") self.plot.showGrid(False, False) @@ -256,6 +257,8 @@ class EkgPlot(object): bl = self.plot.getAxis("left") ba.setTicks([]) bl.setTicks([]) + ba.hide() + bl.hide() self.active_actors = list() self.actors = dict()