def METHOD_NAME(
    callable: Callable[..., T], args: Tuple[Any] = None, timeout: int = None, kwargs: Optional[Dict[str, Any]] = None
) -> T:
    """
    Schedules the given callable to be executed on the GUI thread. If the current thread is the GUI thread, the callable
    is executed immediately.
    :raises: Any exception raised by the callable.
    :returns: The result of the callable, or None if the callable timed out.
    """
    if kwargs is None:
        kwargs = {}
    if is_gui_thread():
        if args is None:
            return callable(**kwargs)
        else:
            return callable(*args, **kwargs)
    event = ExecuteCodeEvent(callable, args=args, kwargs=kwargs)
    if GlobalInfo.is_test:
        GlobalInfo.add_event_during_test(event)
    else:
        try:
            QCoreApplication.postEvent(GlobalInfo.main_window, event)
        except RuntimeError:
            # the application is exiting and the main window has been destroyed. just let it go
            return None
    event.event.wait(timeout=timeout)  # TODO: unsafe. to be fixed later.
    if not event.event.is_set():
        # it timed out without getting scheduled to execute...
        return None
    if event.exception is not None:
        raise event.exception
    return event.result