diff --git a/InterceptEscapeWhenEditingTableCell.py b/InterceptEscapeWhenEditingTableCell.py deleted file mode 100755 index 40d1490..0000000 --- a/InterceptEscapeWhenEditingTableCell.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python3 - -from PyQt6.QtCore import Qt, QEvent, QObject -from PyQt6.QtWidgets import ( - QAbstractItemView, - QApplication, - QMainWindow, - QMessageBox, - QPlainTextEdit, - QStyledItemDelegate, - QTableWidget, - QTableWidgetItem, -) - -from PyQt6.QtGui import QKeyEvent - -from typing import cast - - -class EscapeDelegate(QStyledItemDelegate): - def __init__(self, parent=None): - super().__init__(parent) - - def createEditor(self, parent, option, index): - return QPlainTextEdit(parent) - - def eventFilter(self, editor: QObject, event: QEvent): - """By default, QPlainTextEdit doesn't handle enter or return""" - - print("EscapeDelegate event handler") - if event.type() == QEvent.Type.KeyPress: - key_event = cast(QKeyEvent, event) - if key_event.key() == Qt.Key.Key_Return: - if key_event.modifiers() == (Qt.KeyboardModifier.ControlModifier): - print("save data") - self.commitData.emit(editor) - self.closeEditor.emit(editor) - return True - elif key_event.key() == Qt.Key.Key_Escape: - discard_edits = QMessageBox.question( - self.parent(), "Abandon edit", "Discard changes?" - ) - if discard_edits == QMessageBox.StandardButton.Yes: - print("abandon edit") - self.closeEditor.emit(editor) - return True - return False - - -class MyTableWidget(QTableWidget): - def __init__(self, parent=None): - super().__init__(parent) - self.setItemDelegate(EscapeDelegate(self)) - # self.setEditTriggers(QAbstractItemView.EditTrigger.DoubleClicked) - - -class MainWindow(QMainWindow): - def __init__(self, parent=None): - super().__init__(parent) - self.table_widget = MyTableWidget(self) - self.table_widget.setRowCount(2) - self.table_widget.setColumnCount(2) - for row in range(2): - for col in range(2): - item = QTableWidgetItem() - item.setText(f"Row {row}, Col {col}") - self.table_widget.setItem(row, col, item) - self.setCentralWidget(self.table_widget) - - self.table_widget.resizeColumnsToContents() - self.table_widget.resizeRowsToContents() - - -if __name__ == "__main__": - app = QApplication([]) - window = MainWindow() - window.show() - app.exec() diff --git a/InterceptEscapeWhenEditingTableCellInView.py b/InterceptEscapeWhenEditingTableCellInView.py deleted file mode 100755 index c00488f..0000000 --- a/InterceptEscapeWhenEditingTableCellInView.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python3 - -from PyQt6.QtCore import Qt, QEvent, QObject, QVariant, QAbstractTableModel -from PyQt6.QtWidgets import ( - QApplication, - QMainWindow, - QMessageBox, - QPlainTextEdit, - QStyledItemDelegate, - QTableView, -) - -from PyQt6.QtGui import QKeyEvent - -from typing import cast - - -class EscapeDelegate(QStyledItemDelegate): - def __init__(self, parent=None): - super().__init__(parent) - - def createEditor(self, parent, option, index): - return QPlainTextEdit(parent) - - def eventFilter(self, editor: QObject, event: QEvent): - """By default, QPlainTextEdit doesn't handle enter or return""" - - if event.type() == QEvent.Type.KeyPress: - key_event = cast(QKeyEvent, event) - print(key_event.key()) - if key_event.key() == Qt.Key.Key_Return: - if key_event.modifiers() == (Qt.KeyboardModifier.ControlModifier): - print("save data") - self.commitData.emit(editor) - self.closeEditor.emit(editor) - return True - elif key_event.key() == Qt.Key.Key_Escape: - discard_edits = QMessageBox.question( - self.parent(), "Abandon edit", "Discard changes?" - ) - if discard_edits == QMessageBox.StandardButton.Yes: - print("abandon edit") - self.closeEditor.emit(editor) - return True - return False - - -class MyTableWidget(QTableView): - def __init__(self, parent=None): - super().__init__(parent) - self.setItemDelegate(EscapeDelegate(self)) - self.setModel(MyModel()) - - -class MyModel(QAbstractTableModel): - def columnCount(self, index): - return 2 - - def rowCount(self, index): - return 2 - - def data(self, index, role): - if not index.isValid() or not (0 <= index.row() < 2): - return QVariant() - - row = index.row() - column = index.column() - if role == Qt.ItemDataRole.DisplayRole: - return QVariant(f"Row {row}, Col {column}") - return QVariant() - - def flags(self, index): - return ( - Qt.ItemFlag.ItemIsEnabled - | Qt.ItemFlag.ItemIsSelectable - | Qt.ItemFlag.ItemIsEditable - ) - - -class MainWindow(QMainWindow): - def __init__(self, parent=None): - super().__init__(parent) - self.table_widget = MyTableWidget(self) - self.setCentralWidget(self.table_widget) - - self.table_widget.resizeColumnsToContents() - self.table_widget.resizeRowsToContents() - - -if __name__ == "__main__": - app = QApplication([]) - window = MainWindow() - window.show() - app.exec() diff --git a/audacity_tester.py b/audacity_tester.py deleted file mode 100755 index 0a76005..0000000 --- a/audacity_tester.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -"""Tests the audacity pipe. -Keep pipe_test.py short!! -You can make more complicated longer tests to test other functionality -or to generate screenshots etc in other scripts. -Make sure Audacity is running first and that mod-script-pipe is enabled -before running this script. -Requires Python 2.7 or later. Python 3 is strongly recommended. -""" - -import os -import sys - - -if sys.platform == 'win32': - print("pipe-test.py, running on windows") - TONAME = '\\\\.\\pipe\\ToSrvPipe' - FROMNAME = '\\\\.\\pipe\\FromSrvPipe' - EOL = '\r\n\0' -else: - print("pipe-test.py, running on linux or mac") - TONAME = '/tmp/audacity_script_pipe.to.' + str(os.getuid()) - FROMNAME = '/tmp/audacity_script_pipe.from.' + str(os.getuid()) - EOL = '\n' - -print("Write to \"" + TONAME + "\"") -if not os.path.exists(TONAME): - print(" does not exist. Ensure Audacity is running with mod-script-pipe.") - sys.exit() - -print("Read from \"" + FROMNAME + "\"") -if not os.path.exists(FROMNAME): - print(" does not exist. Ensure Audacity is running with mod-script-pipe.") - sys.exit() - -print("-- Both pipes exist. Good.") - -TOFILE = open(TONAME, 'w') -print("-- File to write to has been opened") -FROMFILE = open(FROMNAME, 'rt') -print("-- File to read from has now been opened too\r\n") - - -def send_command(command): - """Send a single command.""" - print("Send: >>> \n"+command) - TOFILE.write(command + EOL) - TOFILE.flush() - - -def get_response(): - """Return the command response.""" - result = '' - line = '' - while True: - result += line - line = FROMFILE.readline() - if line == '\n' and len(result) > 0: - break - return result - - -def do_command(command): - """Send one command, and return the response.""" - send_command(command) - response = get_response() - print("Rcvd: <<< \n" + response) - return response - - -do_command('Import2: Filename=/home/kae/git/musicmuster/archive/boot.flac') diff --git a/devnotes.txt b/devnotes.txt deleted file mode 100644 index 08ac9e3..0000000 --- a/devnotes.txt +++ /dev/null @@ -1 +0,0 @@ -Run Flake8 and Black diff --git a/mmimport b/mmimport deleted file mode 100755 index fa48fe0..0000000 --- a/mmimport +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# cd /home/kae/mm -# MYSQL_CONNECT="mysql+mysqldb://musicmuster:musicmuster@localhost/musicmuster_prod" ROOT="/home/kae/music" direnv exec . -for file in "$@"; do - app/songdb.py -i "$file" -done