Skip to content

Prevent the display being closed when a function returns #855

@CsatiZoltan

Description

@CsatiZoltan

I separated my visualization functionality to a separate function, like this:

from OCC.Display.SimpleGui import init_display

def core:
    # Set up a `TopoDS_Shape` object, called `shape`
    # ...
    # Call the plotting function
    plot_shape(shape)

def plot_shape(shape):
    display, start_display, add_menu, add_function_to_menu = init_display()
    display.DisplayShape(shape, update=True)
    input("Press Enter to continue...")

The last line is there to prevent the figure from being closed. However, this is not a good solution because

  • the program termination is paused
  • I cannot focus on the figure, so I cannot rotate, zoom, pan, etc.

Activity

efirvida

efirvida commented on Jun 15, 2020

@efirvida

try;

def plot_shape(shape):
    display, start_display, add_menu, add_function_to_menu = init_display()
    display.DisplayShape(shape, update=True)
    start_display()
CsatiZoltan

CsatiZoltan commented on Jun 16, 2020

@CsatiZoltan
Author

@efirvida Thanks, that works. However, the execution is suspended until I keep the window open. Is there a way to make the display independent of the main program thread?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @tpaviot@efirvida@CsatiZoltan

        Issue actions

          Prevent the display being closed when a function returns · Issue #855 · tpaviot/pythonocc-core