diff --git a/pixelocr/gui/glyphedit.py b/pixelocr/gui/glyphedit.py new file mode 100644 index 0000000..9a44a69 --- /dev/null +++ b/pixelocr/gui/glyphedit.py @@ -0,0 +1,57 @@ +# Copyright (C) 2014 Andrey Golovizin +# +# This program 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. +# +# This program 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 this program. If not, see . + + +from PyQt4.QtCore import ( + signal, + slot, +) + +from PyQt4.QtGui import ( + QHBoxLayout, + QLineEdit, + QToolButton, + QWidget, +) + + +class GlyphEdit(QWidget): + letterEntered = signal([str]) + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.layout = QHBoxLayout(self) + self.layout.setSpacing(0) + self.layout.setContentsMargins(0, 0, 0, 0) + + self.bold = QToolButton(self) + self.bold.setText('B') + self.bold.setCheckable(True) + self.bold.setShortcut('Ctrl+b') + + self.italic = QToolButton(self) + self.italic.setText('I') + self.italic.setCheckable(True) + self.italic.setShortcut('Ctrl+i') + + self.text = QLineEdit(self) + self.text.returnPressed.connect(self.sendLetter) + + self.layout.addWidget(self.bold) + self.layout.addWidget(self.italic) + self.layout.addWidget(self.text) + + def sendLetter(self): + self.letterEntered.emit(self.text.text())