{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9d27ff54",
   "metadata": {},
   "source": [
    "# 16-12 · tk и ttk\n",
    "\n",
    "Практика к разделу [«tk и ttk»](../../site/chapters/glava-16/16-12-tk-i-ttk.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3c8c4c48",
   "metadata": {},
   "source": [
    "## Цель\n",
    "\n",
    "Собрать форму из классических и тематизированных виджетов вместе."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa4ee0ad",
   "metadata": {},
   "source": [
    "## Про mainloop() в этом ноутбуке\n",
    "\n",
    "В обычном `.py`-файле приложение запускают через `root.mainloop()` — эта команда «замирает» и ждёт, пока пользователь не закроет окно. В автоматически выполняемом ноутбуке нет живого пользователя за окном, поэтому здесь вместо `root.mainloop()` мы вызовем `root.update()` (обрабатывает события один раз, без ожидания) и затем `root.destroy()` — интерфейс строится точно так же, просто без бесконечного ожидания в конце."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9a0d252b",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T21:45:10.259155Z",
     "iopub.status.busy": "2026-08-18T21:45:10.259025Z",
     "iopub.status.idle": "2026-08-18T21:45:10.373727Z",
     "shell.execute_reply": "2026-08-18T21:45:10.373203Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Text Label Button\n"
     ]
    }
   ],
   "source": [
    "import tkinter as tk\n",
    "from tkinter import ttk\n",
    "\n",
    "root = tk.Tk()\n",
    "\n",
    "text_widget = tk.Text(root, height=3, width=20)\n",
    "text_widget.pack()\n",
    "\n",
    "ttk_label = ttk.Label(root, text=\"ttk.Label\")\n",
    "ttk_label.pack()\n",
    "\n",
    "ttk_button = ttk.Button(root, text=\"ttk.Button\")\n",
    "ttk_button.pack()\n",
    "\n",
    "root.update()\n",
    "print(type(text_widget).__name__, type(ttk_label).__name__, type(ttk_button).__name__)\n",
    "root.destroy()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ffbbd608",
   "metadata": {},
   "source": [
    "## Задание ★ Базовая практика\n",
    "\n",
    "Добавьте ttk.Entry в ту же форму."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "872625d3",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T21:45:10.374972Z",
     "iopub.status.busy": "2026-08-18T21:45:10.374833Z",
     "iopub.status.idle": "2026-08-18T21:45:10.437356Z",
     "shell.execute_reply": "2026-08-18T21:45:10.436838Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Entry\n"
     ]
    }
   ],
   "source": [
    "root = tk.Tk()\n",
    "entry = ttk.Entry(root)\n",
    "entry.pack()\n",
    "root.update()\n",
    "print(type(entry).__name__)\n",
    "root.destroy()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
