diff --git a/.gitignore b/.gitignore index b6e4761..91939da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*~ + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/README.md b/README.md index 6044a6e..59b9a66 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# beeref -BeeRef Reference Image Viewer +# BeeRef — A Simple Reference Image Viewer + +View your references while you art! diff --git a/assets/logo.png b/assets/logo.png new file mode 100644 index 0000000..0068613 Binary files /dev/null and b/assets/logo.png differ diff --git a/assets/logo.svg b/assets/logo.svg new file mode 100644 index 0000000..9595239 --- /dev/null +++ b/assets/logo.svg @@ -0,0 +1,421 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/beeref.py b/beeref.py new file mode 100755 index 0000000..b59151d --- /dev/null +++ b/beeref.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 + +import logging +import os.path +import signal +import sys + +from PyQt6 import QtCore, QtGui, QtWidgets + +from lib.view import BeeGraphicsView + + +logger = logging.getLogger('BeeRef') + + +class BeeRefMainWindow(QtWidgets.QWidget): + + def __init__(self, filename=None): + super().__init__() + self.setWindowTitle('BeeRef') + self.setWindowIcon(QtGui.QIcon(os.path.join('assets', 'logo.png'))) + view = BeeGraphicsView(app, self, filename) + layout = QtWidgets.QVBoxLayout() + layout.setContentsMargins(QtCore.QMargins(0, 0, 0, 0)) + layout.addWidget(view) + self.setLayout(layout) + self.resize(500, 300) + self.show() + + +def safe_timer(timeout, func, *args, **kwargs): + """Create a timer that is safe against garbage collection and + overlapping calls. + See: http://ralsina.me/weblog/posts/BB974.html + """ + def timer_event(): + try: + func(*args, **kwargs) + finally: + QtCore.QTimer.singleShot(timeout, timer_event) + QtCore.QTimer.singleShot(timeout, timer_event) + + +def handle_sigint(signum, frame): + logger.info('Received interrupt. Exiting...') + QtWidgets.QApplication.quit() + + +if __name__ == '__main__': + logger = logging.getLogger('BeeRef') + logging.basicConfig(level=logging.DEBUG) + app = QtWidgets.QApplication(sys.argv) + + filename = sys.argv[1] if len(sys.argv) > 1 else None + bee = BeeRefMainWindow(filename) + + signal.signal(signal.SIGINT, handle_sigint) + # Repeatedly run python-noop to give the interpreter time to + # handel signals + safe_timer(50, lambda: None) + + app.exec() diff --git a/requirements/app.txt b/requirements/app.txt new file mode 100644 index 0000000..86eab23 --- /dev/null +++ b/requirements/app.txt @@ -0,0 +1 @@ +pyQt6==6.0.3 diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 0000000..42dbe4d --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,2 @@ +flake8==3.9.0 +pytest==6.2.2