Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rethink the display mechanisms #269

Closed
leouieda opened this issue Jan 22, 2019 · 1 comment · Fixed by #529
Closed

Rethink the display mechanisms #269

leouieda opened this issue Jan 22, 2019 · 1 comment · Fixed by #529
Labels
feature request New feature wanted help wanted Helping hands are appreciated
Milestone

Comments

@leouieda
Copy link
Member

Description of the desired feature

Currently, there many ways of displaying a PyGMT figure:

  • Calling Figure.show() in the notebook returns an IPython PNG display object for the jupyter notebook
  • Putting the Figure object at the end of a notebook cell displays the figure as PNG
  • Calling Figure.show(external=True) will open a preview in an external PDF viewer or the browser. The external viewer is non-blocking so this doesn't work for a script.
  • Calling Figure.savefig(..., show=True) will save the figure and open it on an external viewer

This is not ideal. It would be better to have:

  • Calling Figure.show() opens a preview of the figure and halts the Python process until the viewer is closed. It can also return self so that if it's called at the end of a notebook cell it would get displayed on the notebook as well.
  • Putting the Figure at the end of a notebook cell displays a PNG preview.
  • Having some way of tell Figure.show() to not open the viewer. This is required when using a notebook or when building the docs (we don't want windows opening when we build the gallery or tutorials). This can be done through a function pygmt.enable_notebook which would set a flag to tell show not to do anything and/or through an environment variable PYGMT_DISPLAY which can be set to none or other options that the user might want. Ideally, we should have both. The env variable will be useful when building the docs.
@leouieda leouieda added the feature request New feature wanted label Jan 22, 2019
@leouieda
Copy link
Member Author

After #268 we'll need one notebook tutorial that shows how to use PyGMT with the notebook. This can be placed in doc and included in the toctree in doc/index.rst. It will be converted automatically with nbsphinx.

@weiji14 weiji14 added the help wanted Helping hands are appreciated label May 5, 2020
seisman added a commit that referenced this issue Jul 15, 2020
This is a new design of the PyGMT display mechanism, following the
discussions in #269, with some changes.

**It's working now but not finished yet.**
seisman added a commit that referenced this issue Jul 15, 2020
This is a new design of the PyGMT display mechanism, following the
discussions in #269, with some changes.

**It's working now but not finished yet.**
seisman added a commit that referenced this issue Sep 13, 2020
This is a new design of the PyGMT display mechanism, following the
discussions in #269, with some changes.

**It's working now but not finished yet.**
seisman added a commit that referenced this issue Oct 1, 2020
This is a new design of the PyGMT display mechanism, following the
discussions in #269, with some changes.

**It's working now but not finished yet.**
seisman added a commit that referenced this issue Oct 1, 2020
This is a new design of the PyGMT display mechanism, following the
discussions in #269, with some changes.

**It's working now but not finished yet.**
seisman added a commit that referenced this issue Oct 1, 2020
This is a new design of the PyGMT display mechanism, following the
discussions in #269, with some changes.

**It's working now but not finished yet.**
@weiji14 weiji14 added this to the 0.4.0 milestone Nov 22, 2020
seisman added a commit that referenced this issue Feb 22, 2021
This PR improves the `launch_external_viewer` function to open images
using the associated application (just like double-click the images) on
Windows.

The implemention is done by calling the
[`os.startfile`](https://docs.python.org/3/library/os.html#os.startfile)
function.

`os.startfile` is only available on Windows, so need to disable the pylint
error `no-member`.

The code was originall written in #269 by @leouieda, re-used in #529.
seisman added a commit that referenced this issue Feb 23, 2021
This PR improves the `launch_external_viewer` function to open images
using the associated application (just like double-click the images) on
Windows.

The implemention is done by calling the
[`os.startfile`](https://docs.python.org/3/library/os.html#os.startfile)
function.

`os.startfile` is only available on Windows, so need to disable the pylint
error `no-member`.

The code was originall written in #269 by @leouieda, re-used in #529.
sixy6e pushed a commit to sixy6e/pygmt that referenced this issue Dec 21, 2022
…ingTools#952)

This PR improves the `launch_external_viewer` function to open images
using the associated application (just like double-click the images) on
Windows.

The implemention is done by calling the
[`os.startfile`](https://docs.python.org/3/library/os.html#os.startfile)
function.

`os.startfile` is only available on Windows, so need to disable the pylint
error `no-member`.

The code was originall written in GenericMappingTools#269 by @leouieda, re-used in GenericMappingTools#529.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted help wanted Helping hands are appreciated
Projects
None yet
2 participants