pixelocr/pixelocr/gui/guiproxy.py
2014-09-11 12:16:38 +02:00

55 lines
1.5 KiB
Python

# 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 queue import Queue
from PyQt4.QtCore import (
signal,
slot,
QObject,
)
from PyQt4.QtGui import (
qApp,
)
from ..ui import BaseUI
from ..page import Page, Glyph
class GUIProxy(QObject, BaseUI):
unknownGlyph = signal([Glyph, bool, bool])
pageChanged = signal([Page])
def __init__(self):
super().__init__()
self.help_queue = Queue()
def turn_page(self, page):
self.pageChanged.emit(page)
def process_events(self):
qApp.processEvents()
def ask_for_help(self, unknown_glyph):
self.unknownGlyph.emit(unknown_glyph, self.last_style.bold, self.last_style.italic)
return self.receive_help()
def give_help(self, *args):
self.help_queue.put(args)
def receive_help(self):
return self.help_queue.get()