Add GlyphEdit class.

This commit is contained in:
Andrey Golovizin 2014-08-15 18:09:20 +02:00
parent 34d7d123d1
commit 6c3c93a39d

57
pixelocr/gui/glyphedit.py Normal file
View file

@ -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 <http://www.gnu.org/licenses/>.
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())