| 339 | // TODO: Fix arguments |
| 340 | #[pymethod] |
| 341 | fn mainloop(&self, threshold: Option<i32>) -> PyResult<()> { |
| 342 | let threshold = threshold.unwrap_or(0); |
| 343 | // self.dispatching = true; |
| 344 | QUIT_MAIN_LOOP.store(false, Ordering::Relaxed); |
| 345 | while unsafe { tk_sys::Tk_GetNumMainWindows() } > threshold |
| 346 | && !QUIT_MAIN_LOOP.load(Ordering::Relaxed) |
| 347 | && !ERROR_IN_CMD.load(Ordering::Relaxed) |
| 348 | { |
| 349 | if self.threaded { |
| 350 | unsafe { tk_sys::Tcl_DoOneEvent(0 as _) }; |
| 351 | } else { |
| 352 | unsafe { tk_sys::Tcl_DoOneEvent(tk_sys::TCL_DONT_WAIT as _) }; |
| 353 | // TODO: sleep for the proper time |
| 354 | std::thread::sleep(std::time::Duration::from_millis(1)); |
| 355 | } |
| 356 | } |
| 357 | Ok(()) |
| 358 | } |
| 359 | |
| 360 | #[pymethod] |
| 361 | fn quit(&self) { |