ztk::platform
Gives the name of the backend that runs the app, the operating system, or the form of the device. tk windowingsystem gives the value of Tk for the same platform: x11, win32, or aqua.
Synopsis
ztk::platform
ztk::platform os
ztk::platform form
Arguments
| Name | Type | Default | Description |
|---|---|---|---|
os |
subcommand | Gives the operating system of the program. | |
form |
subcommand | Gives the form of the device. |
With no argument, the command gives the backend.
Return value
With no argument, the backend:
| Value | Backend |
|---|---|
wayland |
A Wayland compositor on Linux or BSD. |
x11 |
An X server on Linux or BSD. |
windows |
Win32 on Windows. |
macos |
AppKit on macOS. |
ios |
UIKit on iOS and iPadOS. |
android |
An Android app. |
web |
The web build in a browser or in Node.js. |
direct |
The screen of Linux with no display server (KMS or the frame buffer). |
headless |
No screen: --headless, the tests, and the pictures of the docs. |
tk windowingsystem gives x11 for wayland, x11, direct, ios, android, and web, the value that a script of Tk treats as the general case. A script that needs the real backend asks ztk::platform.
ztk::platform os gives the system that the program was built for: linux, macos, windows, ios, android, or web. The headless backend gives the system of the program, such as linux. A program for another system gives its name, such as freebsd.
ztk::platform form gives desktop, phone, or tablet. A backend with no touch screen (tk touchscreen gives 0) gives desktop. On a touch screen, the form is phone when the shorter side of the screen is under 600 logical pixels, and tablet from 600 on: a phone in landscape is still a phone. The screen is the window of ., which fills the screen of a phone or a tablet. In the headless backend, ztk --headless --touch --size WxH sets the screen, so a test can run the phone and the tablet paths.
Errors
| Error | When |
|---|---|
wrong # args: should be "ztk::platform ?os|form?" |
More than one argument. |
bad option "x": must be form or os |
An argument that is not os or form. |
Platforms
Each backend gives its own name. The web build gives desktop for form, because tk touchscreen gives 0 there (#897).
Example
switch [ztk::platform form] {
phone { puts "one column" }
tablet { puts "a list beside its detail" }
default { puts "the desktop window on [ztk::platform os]" }
}
puts "the backend is [ztk::platform], and Tk says [tk windowingsystem]"