Untitled
unknown
python
3 years ago
2.4 kB
4
Indexable
import os import sys from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import ( QApplication, QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit, QPushButton, QVBoxLayout ) class Window(QDialog): def __init__(self, parent=None): super(Window, self).__init__(parent) groupBox1 = QGroupBox('Group 1') groupBox1.setCheckable(False) groupBox1.setChecked(False) self.imageLabel = QLabel() pixmap = QPixmap('test.jpg') self.imageLabel.setPixmap(pixmap) layout = QVBoxLayout() layout.addWidget(self.imageLabel) layout.addStretch(1) groupBox1.setLayout(layout) groupBox2 = QGroupBox('Group 2') groupBox2.setCheckable(False) groupBox2.setChecked(False) debugLabel = QLabel() lineEdit = QLineEdit('s3cRe7') lineEdit.textChanged[str].connect(self.onLineEditTextChanged) drawButton = QPushButton('Draw') drawButton.clicked.connect(self.onDrawButtonClicked) layout = QVBoxLayout() layout.addWidget(debugLabel) layout.addWidget(lineEdit) layout.addWidget(drawButton) layout.addStretch(1) groupBox2.setLayout(layout) main_layout = QGridLayout() main_layout.addWidget(groupBox1, 0, 0, 1, 2) main_layout.addWidget(groupBox2, 1, 0, 1, 2) self.setLayout(main_layout) self.setWindowTitle("BlackMetalPro 1.0") def onLineEditTextChanged(self, text): print(text) def onDrawButtonClicked(self): print('clicked') filename = 'output' ly_string = '' with open('template.ly') as f: for line in f.readlines(): ly_string += line ly_string += "\\new TabStaff \\relative c' {\n" ly_string += " a,8 a' <c e> a\n" ly_string += " d,8 a' <d f> a\n" ly_string += "}\n" try: fname = filename + '.ly' f = open(fname, 'w') f.write(ly_string) f.close() except: print(f'Error while writing {fname}') return False command = f'lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts --png {fname}' print(command) print(f"Executing: {command}") os.system(command) pixmap = QPixmap('output.png') self.imageLabel.setPixmap(pixmap) os.remove('output-1.eps') os.remove('output-systems.count') os.remove('output-systems.tex') os.remove('output-systems.texi') os.remove('output.png') app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec())
Editor is loading...