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

Add a way to close the window #181

Open
1 of 2 tasks
sunjay opened this issue May 26, 2020 · 1 comment · Fixed by #245
Open
1 of 2 tasks

Add a way to close the window #181

sunjay opened this issue May 26, 2020 · 1 comment · Fixed by #245

Comments

@sunjay
Copy link
Owner

sunjay commented May 26, 2020

Currently, there is no way to close the window programmatically opened by Turtle::new() or Drawing::new(). We should add a fn destroy(self) method to Drawing which allows for this.

Implementation: The destroy method can send a request to the renderer process which uses EventLoopNotifier to tell the event loop to exit. (More mentoring instructions can be provided if requested.)

To-Do

  • Bikeshed the name. destroy() was the best I could come up with
    • close() only works when Drawing represents a window, but that won't always be the case
    • quit() might work, but it might confuse some people who expect that to end the entire process
    • bye() is used by the Python turtle module and some LOGO implementation, but calling drawing.bye() probably doesn't read very well...
    • Other suggestions are welcome!
  • Resolve TODO comment in examples/runtest.rs (needs to be tested on MacOS)
    • The window currently stays open even after process::exit because the subprocess gets orphaned when using the multiprocessed backend
    • To test on any platform, you can force the multiprocessed backend by changing backend.rs to contain the following:
cfg_if::cfg_if! {
    if #[cfg(any(feature = "test", test))] {
        mod test;
        pub use test::*;

    // } else if #[cfg(target_os = "macos")] {
    } else {
        mod multiprocessed;
        pub use multiprocessed::*;
    //
    // } else {
    //     mod multithreaded;
    //     pub use multithreaded::*;
    }
}
@sunjay
Copy link
Owner Author

sunjay commented Jul 16, 2021

Re-opening until this method is stabilized. We need to decide on the name (destroy is fine for now but maybe there is a better option?), and we need to expand on the docs and test the panic that occurs when you use a turtle after its drawing has been destroyed (make sure the panic message is helpful).

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

Successfully merging a pull request may close this issue.

1 participant