Plug glyph db editor into the main menu.
This commit is contained in:
parent
95b0c62927
commit
34f58f0471
3 changed files with 35 additions and 12 deletions
|
|
@ -39,14 +39,12 @@ def main():
|
||||||
QApplication.setOrganizationName("PixelOCR");
|
QApplication.setOrganizationName("PixelOCR");
|
||||||
QApplication.setApplicationName("PixelOCR");
|
QApplication.setApplicationName("PixelOCR");
|
||||||
|
|
||||||
win = MainWindow()
|
|
||||||
win.show()
|
|
||||||
|
|
||||||
ocr = OCREngine(sys.argv[1])
|
ocr = OCREngine(sys.argv[1])
|
||||||
ocr.pageChanged.connect(win.pageScene.setPage)
|
|
||||||
ocr.unknownGlyph.connect(win.unknownGlyph)
|
|
||||||
win.glyphEntered.connect(ocr.give_help)
|
|
||||||
app.aboutToQuit.connect(ocr.save_glyphdb)
|
app.aboutToQuit.connect(ocr.save_glyphdb)
|
||||||
|
|
||||||
|
win = MainWindow(ocr)
|
||||||
|
win.glyphEntered.connect(ocr.give_help)
|
||||||
|
win.show()
|
||||||
ocr.start()
|
ocr.start()
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ from collections import defaultdict
|
||||||
from PyQt4.QtCore import (
|
from PyQt4.QtCore import (
|
||||||
Qt,
|
Qt,
|
||||||
QAbstractTableModel,
|
QAbstractTableModel,
|
||||||
|
QSize,
|
||||||
)
|
)
|
||||||
|
|
||||||
from PyQt4.QtGui import (
|
from PyQt4.QtGui import (
|
||||||
|
|
@ -101,16 +102,23 @@ class GlyphTableView(QTableView):
|
||||||
return super().keyPressEvent(event)
|
return super().keyPressEvent(event)
|
||||||
|
|
||||||
|
|
||||||
|
class GlyphDBEdit(GlyphTableView):
|
||||||
|
def __init__(self, glyphdb, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
model = GlyphDBModel(glyphdb, parent=self)
|
||||||
|
self.setModel(model)
|
||||||
|
|
||||||
|
def sizeHint(self):
|
||||||
|
return QSize(640, 480)
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
dirname = argv[1]
|
dirname = argv[1]
|
||||||
|
|
||||||
app = QApplication(argv)
|
app = QApplication(argv)
|
||||||
glyphdb = GlyphDB(dirname)
|
glyphdb = GlyphDB(dirname)
|
||||||
view = GlyphTableView()
|
win = GlyphDBEdit(glyphdb)
|
||||||
model = GlyphDBModel(glyphdb, parent=view)
|
win.show()
|
||||||
view.setModel(model)
|
|
||||||
view.resize(640, 480)
|
|
||||||
view.show()
|
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,20 @@ from PyQt4.QtGui import (
|
||||||
|
|
||||||
from .pageview import PageScene, PageView
|
from .pageview import PageScene, PageView
|
||||||
from .glyphedit import GlyphEdit
|
from .glyphedit import GlyphEdit
|
||||||
|
from .glypheditor import GlyphDBEdit
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
|
dbedit = None
|
||||||
|
|
||||||
glyphEntered = signal([str])
|
glyphEntered = signal([str])
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, ocr):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.setWindowTitle('PixelOCR')
|
self.setWindowTitle('PixelOCR')
|
||||||
|
|
||||||
|
self.ocr = ocr
|
||||||
|
|
||||||
centralWidget = QWidget(self)
|
centralWidget = QWidget(self)
|
||||||
self.setCentralWidget(centralWidget)
|
self.setCentralWidget(centralWidget)
|
||||||
self.pageScene = PageScene(self)
|
self.pageScene = PageScene(self)
|
||||||
|
|
@ -50,6 +55,8 @@ class MainWindow(QMainWindow):
|
||||||
self.glyphEdit = GlyphEdit(centralWidget)
|
self.glyphEdit = GlyphEdit(centralWidget)
|
||||||
self.glyphEdit.glyphEntered.connect(self.glyphEntered)
|
self.glyphEdit.glyphEntered.connect(self.glyphEntered)
|
||||||
self.glyphEdit.glyphEntered.connect(self.pageScene.clearHighlight)
|
self.glyphEdit.glyphEntered.connect(self.pageScene.clearHighlight)
|
||||||
|
ocr.pageChanged.connect(self.pageScene.setPage)
|
||||||
|
ocr.unknownGlyph.connect(self.unknownGlyph)
|
||||||
|
|
||||||
layout = QVBoxLayout(centralWidget)
|
layout = QVBoxLayout(centralWidget)
|
||||||
layout.setSpacing(0)
|
layout.setSpacing(0)
|
||||||
|
|
@ -68,6 +75,11 @@ class MainWindow(QMainWindow):
|
||||||
quit.triggered.connect(qApp.closeAllWindows)
|
quit.triggered.connect(qApp.closeAllWindows)
|
||||||
fileMenu.addAction(quit)
|
fileMenu.addAction(quit)
|
||||||
|
|
||||||
|
fileMenu = self.menuBar().addMenu('&Tools')
|
||||||
|
glyphDBEdit = QAction('Edit glyph database', self)
|
||||||
|
glyphDBEdit.triggered.connect(self.showGlyphDBEdit)
|
||||||
|
fileMenu.addAction(glyphDBEdit)
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
return QSize(800, 600)
|
return QSize(800, 600)
|
||||||
|
|
||||||
|
|
@ -90,3 +102,8 @@ class MainWindow(QMainWindow):
|
||||||
self.glyphEdit.setEnabled(True)
|
self.glyphEdit.setEnabled(True)
|
||||||
self.glyphEdit.text.clear()
|
self.glyphEdit.text.clear()
|
||||||
self.glyphEdit.text.setFocus()
|
self.glyphEdit.text.setFocus()
|
||||||
|
|
||||||
|
def showGlyphDBEdit(self):
|
||||||
|
if self.dbedit is None:
|
||||||
|
self.dbedit = GlyphDBEdit(self.ocr.glyphdb)
|
||||||
|
self.dbedit.show()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue