pixelocr/pixelocr/gui/window.py
2014-08-12 20:28:28 +02:00

65 lines
1.8 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 PyQt4.QtCore import (
Qt,
QSettings,
QSize,
)
from PyQt4.QtGui import (
QMainWindow,
QPushButton,
QVBoxLayout,
QWidget,
)
from .pageview import PageScene, PageView
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle('PixelOCR')
centralWidget = QWidget(self)
self.setCentralWidget(centralWidget)
self.pageScene = PageScene(self)
self.page = PageView(self.pageScene, centralWidget)
layout = QVBoxLayout(centralWidget)
layout.addWidget(self.page)
layout.setContentsMargins(0, 0, 0, 0)
self.readSettings()
def sizeHint(self):
return QSize(800, 600)
def closeEvent(self, event):
self.saveSettings()
super().closeEvent(event)
def saveSettings(self):
settings = QSettings()
settings.setValue('windowGeometry', self.saveGeometry())
settings.setValue('windowState', self.saveState())
def readSettings(self):
settings = QSettings()
self.restoreGeometry(settings.value("windowGeometry") or b'')
self.restoreState(settings.value("windowState") or b'')