---
name: "EventInit"
section: "2"
platform: "linux"
package: "perl-tk"
version: "b11.02-5"
release: "Debian 1.3 (Bo)"
platforms: ["linux"]
url: "https://new.carta.tech/EventInit"
---

# EventInit(2)

Use the Tk event loop without the rest of Tk

## NAME

Tk\_EventInit - Use the Tk event loop without the rest of Tk

## SYNOPSIS

```
#include <tk.h>

int
Tk_EventInit(interp)
```

## ARGUMENTS

Interpreter in which event-related Tk commands are to be created.

## DESCRIPTION

This procedure may be invoked to use the Tk event management functions without the rest of Tk (e.g., in applications that do not have access to a display). **Tk\_EventInit** creates the **after** and **fileevent** commands in *interp*. It also creates versions of the **tkwait** and **update** commands with reduced functionality:  the **tkwait** command supports only the **variable** option, not **visibility** or **window**, and **update** does not check for X events. **Tk\_EventInit** always returns **TCL\_OK** to signal that it completed successfully.

The event-management procedures in Tk are divided into two groups, those that can be used stand-alone and those that require the full Tk library to be present. The following procedures may be used stand-alone: **Tk\_CreateFileHandler**, **Tk\_CreateFileHandler2**, **Tk\_DeleteFileHandler**, **Tk\_CreateTimerHandler**, **Tk\_DeleteTimerHandler**, **Tk\_DoWhenIdle**, **Tk\_CancelIdleCall**, **Tk\_DoOneEvent**, **Tk\_Sleep**, and **Tk\_BackgroundError**. Note that **Tk\_MainLoop** cannot be used without the full Tk library, since it checks to see if windows are still open. If an application uses the event procedures stand-alone, it must include its own main loop that invokes **Tk\_DoOneEvent** repeatedly.

**Tk\_EventInit** is typically called from an application's **Tcl\_AppInit** procedure;  it should not be invoked in applications that use the full Tk library (e.g., those that have already invoked **Tk\_CreateMainWindow**). However, it is OK for an application to start up using **Tk\_EventInit**, compute without X for a while, and later invoke **Tk\_CreateMainWindow**. When **Tk\_CreateMainWindow** is invoked, the full suite of windowing Tcl commands will become available, and the full-blown versions of **tkwait** and **update** will replace the abridged versions created with **Tk\_EventInit**.

## KEYWORDS

event management, Tcl\_AppInit
