Skip to content

Allow users to set the waiting time when displaying a preview image using an external viewer#1618

Merged
seisman merged 4 commits intomainfrom
Figure-show-waiting
Nov 22, 2021
Merged

Allow users to set the waiting time when displaying a preview image using an external viewer#1618
seisman merged 4 commits intomainfrom
Figure-show-waiting

Conversation

@seisman
Copy link
Member

@seisman seisman commented Nov 8, 2021

Description of proposed changes

See #1061 for the detailed issue report and discussions.

This PR adds the waiting parameter to the launch_external_viewer function. The default value is 0, so no waiting by default.

As mentioned in #1061 (comment), the launch_external_viewer function is used at two places, one in the Figure.show() function, another in the Figure.savefig() function.

  • The function call in the Figure.show() opens the preview image in the temporary directory, thus we need to set the waiting time to a non-zero value (waiting=0.5 works for most users) so the external viewer can open the preview image before the PyGMT session exits.
  • The function call in the Figure.savefig() opens the image that was already saved in the current directory or elsewhere, and won't be deleted when the PyGMT session exits. Thus there is no need to set the waiting time here.

Fixes #1061.

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@seisman seisman changed the title Allow users to set the waiting time when showing the preview using an external viewer Allow users to set the waiting time when displaying a preview image using an external viewer Nov 8, 2021
@seisman seisman force-pushed the Figure-show-waiting branch from 42b457f to e8c8f56 Compare November 8, 2021 15:08
@seisman seisman added the enhancement Improving an existing feature label Nov 8, 2021
@seisman seisman added this to the 0.6.0 milestone Nov 8, 2021
Co-authored-by: Will Schlitzer <schlitzer90@gmail.com>
@weiji14 weiji14 added the final review call This PR requires final review and approval from a second reviewer label Nov 20, 2021
@seisman seisman merged commit 2cc1171 into main Nov 22, 2021
@seisman seisman deleted the Figure-show-waiting branch November 22, 2021 00:31
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Nov 22, 2021
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…sing an external viewer (GenericMappingTools#1618)

Co-authored-by: Will Schlitzer <schlitzer90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fail to open images in external viewer programs if running PyGMT in a Python script

4 participants