From adb405b30f740757ac669bfb6662d7590c6ddba2 Mon Sep 17 00:00:00 2001 From: spacerest Date: Sun, 19 Apr 2020 14:46:52 +0300 Subject: [PATCH] use matplotlib instead of cv2 for showing image on terminal, update readme --- README.md | 2 -- moon/terminal_ui.py | 16 +++++++++------- setup.py | 7 ++++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c550178..644dc4a 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,6 @@ from moon.terminal_ui import TerminalUi ui = TerminalUi() ui.set_moon_phase() #defaults to today's date -ui.set_moon_image() ui.show() ``` @@ -32,7 +31,6 @@ from moon.jupyter_ui import JupyterUi ui = JupyterUi() ui.set_moon_phase() #defaults to today's date -ui.set_moon_image() ui.show() ``` diff --git a/moon/terminal_ui.py b/moon/terminal_ui.py index 65026c7..0850c2d 100644 --- a/moon/terminal_ui.py +++ b/moon/terminal_ui.py @@ -1,12 +1,14 @@ from moon.dialamoon import Moon import cv2 +import matplotlib.pyplot as plt class TerminalUi(Moon): def show(self): - print("☽ the image will open up in a new window. It might be behind your terminal window. To close the image, press any key while it's open.") - cv2.imshow(str(self.datetime), self.image) - cv2.waitKey(0) - print("Closing image...") - cv2.destroyAllWindows() - - + print("☽ the image will open up in a new window. It might be behind your terminal window.") + try: + plt.imshow(cv2.cvtColor(self.image, cv2.COLOR_BGR2RGB)) + plt.show() + print("Image closed.") + except: + e = sys.exc_info()[1] + print("Error: %s" % e) diff --git a/setup.py b/setup.py index 202bfd7..83d3ff1 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name = 'moon', packages = find_packages(), - version = '1.0.6', + version = '1.0.7', license='MIT', description = 'Gets moon visualizations courtesy of NASA/Ernie Wright', long_description_content_type="text/markdown", @@ -16,11 +16,12 @@ author = 'Sadie Parker', author_email = 'sadiemparker@gmail.com', url = 'https://github.com/spacerest/moon', - download_url = 'https://github.com/spacerest/moon/archive/v_1_0_6.tar.gz', + download_url = 'https://github.com/spacerest/moon/archive/v_1_0_7.tar.gz', keywords = ['MOON', 'ART'], install_requires=[ 'numpy~=1.16', - 'opencv-python~=4.1.1.26' + 'opencv-python~=4.2.0.34', + 'matplotlib~=3.2.1', ], classifiers=[ 'Development Status :: 4 - Beta',